Skip to content

Commit

Permalink
Enable messages
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelmv committed Jun 28, 2017
1 parent 864bcaa commit 20214bb
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,4 @@ ENV/
/site

# End of https://www.gitignore.io/api/django,python,pycharm,intellij
staticfiles/
12 changes: 7 additions & 5 deletions home/templates/home/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@ <h2>
Enviar nuevo mensaje:
</h2>

{% if messages %}
{% for message in messages %}
<h3{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</h3>
{% endfor %}
{% endif %}

<form method="POST" enctype="multipart/form-data">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Submit</button>
<button type="submit">Enviar</button>
</form>

{% else %}
Expand All @@ -23,10 +29,6 @@ <h2>

{% endif %}

{% for number in all_numbers %}
<p>{{ number.phone_number }}</p>
{% endfor %}

<a href="{% url "home:new" %}" class="link">Agregar número</a> |
<a href="{% url "home:number_list" %}" class="link">Números actuales</a>

Expand Down
6 changes: 6 additions & 0 deletions home/templates/home/new_number.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

<h2>Agregar número telefónico</h2>

{% if messages %}
{% for message in messages %}
<h3{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</h3>
{% endfor %}
{% endif %}

<form method="POST" enctype="multipart/form-data">
{% csrf_token %}
{{ form.as_p }}
Expand Down
2 changes: 1 addition & 1 deletion home/templates/home/number_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ <h2>Números registrados</h2>

{% endif %}

<a href="{% url "home:new" %}" class="link">Agregar número</a> |
<a href="{% url "home:new" %}" class="link">Agregar número</a> |
<a href="{% url "home:hello" %}" class="link">Enviar mensaje</a>


Expand Down
3 changes: 3 additions & 0 deletions home/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from django.views.generic import ListView
from django.contrib.auth.decorators import login_required
from django.contrib.auth.mixins import LoginRequiredMixin
from django.contrib import messages


from .forms import NumberForm, MessageForm
Expand Down Expand Up @@ -48,6 +49,7 @@ def index(request):
from_="+12092088123",
body=str(body_message))

messages.success(request, 'Mensaje enviado.')
return HttpResponseRedirect('/')
else:
form = MessageForm()
Expand All @@ -67,6 +69,7 @@ def new_number(request):
if form.is_valid():
number = form.save(commit=False)
number.save()
messages.success(request, 'Número guardado.')
return HttpResponseRedirect('/numbers')
else:
form = NumberForm()
Expand Down
4 changes: 4 additions & 0 deletions static/css/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ footer.wrapper .link {
color: #ff004e;
}

.wrapper .success {
color: #14d814;
}

@media (min-width: 800px) {
.wrapper {
width: 25%;
Expand Down

0 comments on commit 20214bb

Please sign in to comment.