Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Hotfix] Ajustes no plugin de pressão #127

Merged
merged 2 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion app/contrib/actions/pressure/cms_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,20 @@ def get_settings(self, obj):
"title": "Envie um e-mail mandando seu recado",
"button": "Pressionar",
"count": "pessoas já pressionaram",
"main_color": None,
}

if obj:
settings["title"] = obj.settings.get("title_text", settings["title"])
settings["title"] = (
obj.settings.get("call_to_action")
or obj.settings.get("title_text")
or settings["title"]
)
settings["button"] = obj.settings.get("button_text", settings["button"])
settings["count"] = obj.settings.get("count_text", settings["count"])
settings["main_color"] = obj.settings.get(
"main_color", settings["main_color"]
)

settings["targets"] = list(
map(
Expand Down
15 changes: 11 additions & 4 deletions app/contrib/actions/pressure/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class PressureAjaxForm(StyledBaseForm):
reference_id = forms.IntegerField(widget=forms.HiddenInput)
referrer_path = forms.CharField(widget=forms.HiddenInput)

email_address = forms.EmailField(label="Seu e-mail")
name = forms.CharField(label="Seu nome", max_length=80)
email_address = forms.EmailField(label="Seu e-mail*")
name = forms.CharField(label="Seu nome*", max_length=80)
phone_number = forms.CharField(label="Seu telefone", max_length=15, required=False)
email_subject = forms.CharField(label="Assunto", max_length=100)
email_body = forms.CharField(label="Corpo do e-mail", widget=forms.Textarea)
Expand Down Expand Up @@ -64,10 +64,17 @@ def submit(self):
"widget_id": self.cleaned_data["reference_id"],
}

resp = requests.post(settings.BONDE_ACTION_API_URL, json={"query": query, "variables": variables})
resp = requests.post(
settings.BONDE_ACTION_API_URL,
json={"query": query, "variables": variables},
)
if resp.status_code == 200:
print(resp.json())
else:
raise Exception("Query failed to run by returning code of {}. {}".format(resp.status_code, query))
raise Exception(
"Query failed to run by returning code of {}. {}".format(
resp.status_code, query
)
)
except requests.ConnectionError:
raise Exception("ConnectionError")
Original file line number Diff line number Diff line change
@@ -1,13 +1,33 @@
{% load cms_tags sekizai_tags static %}

{% addtoblock "css" %}
{% if settings.main_color %}
<style>
#pressureWrapper h3 {
color: {{ settings.main_color }};
}
#pressureForm input:focus, #pressureForm textarea:focus {
border: 1px solid {{ settings.main_color }};
}
#pressureForm button[type="submit"] {
color: white;
igr-santos marked this conversation as resolved.
Show resolved Hide resolved
background-color: {{ settings.main_color }};
}
#pressureForm .counter {
color: {{ settings.main_color }};
}
</style>
{% endif %}
{% endaddtoblock %}

{% addtoblock "js" %}
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
<script type="text/javascript" src="{% static 'pressure/js/pressure.js' %}"></script>
{% endaddtoblock %}

<div id="pressureWrapper" class="container pressure-plugin plugin">
<div class="bg-white rounded-lg">
<h3 class="px-4 pt-4 text-lg font-bold text-center">{{settings.title}}</h3>
<h3 class="px-4 pt-4 text-lg font-bold text-center mb-2">{{settings.title}}</h3>
<div class="px-6 py-4 bg-gray-200">
{% with settings.targets|length as targets_size %}
<p class="mb-2">Quem você vai pressionar? ({{targets_size}} alvo{% if targets_size > 1 %}s{% endif %})</p>
Expand Down Expand Up @@ -43,7 +63,7 @@ <h3 class="px-4 pt-4 text-lg font-bold text-center">{{settings.title}}</h3>
<p class="text-xs">Ao inserir seus dados, você concorda em ter seus dados compartilhados com os organizadores
dessa página e aceita receber emails de atualização, conforme descrito na política de privacidade. Você pode
cancelar o recebimento desses e-mails a qualquer momento.</p>
<p class="py-4 text-sm text-center text-bold">{{ size }} {{ settings.count }}</p>
<p class="counter py-4 text-sm text-center font-bold">{{ size }} {{ settings.count }}</p>
</div>
</form>
</div>
Expand Down
1 change: 1 addition & 0 deletions app/tailwind/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def __init__(self, *args, **kwargs):

# Add readonly fields
if visible.name in self.Meta.readonly_fields:
visible.field.widget.attrs["disabled"] = True
visible.field.widget.attrs["readonly"] = True

# Add placeholder to use focus animation label
Expand Down
Loading