Skip to content

Commit

Permalink
Updating the content of an answer
Browse files Browse the repository at this point in the history
  • Loading branch information
Felipe Álvarez committed Jul 31, 2014
1 parent 869a22b commit 357bae9
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 5 deletions.
21 changes: 17 additions & 4 deletions nuntium/templates/nuntium/profiles/message_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,28 +50,41 @@
</dl>

<div class="col-md-4">
<button class="btn btn-primary" data-toggle="modal" data-target="#createAnswer" class="createAnswer" href="{% url 'create_answer' pk=message.pk %}"><i class="fa fa-plus"></i> {% trans "Create an answer" %}</button>
<button class="btn btn-primary" data-toggle="modal" data-target="#editAnswer" class="editAnswer" href="{% url 'create_answer' pk=message.pk %}"><i class="fa fa-plus"></i> {% trans "Create an answer" %}</button>
</div>
<div class="col-md-8">
<table class="table">
<tr>
<th>{% trans "Person" %}</th>
<th>{% trans "Content" %}</th>
<th></th>
<th>{% trans "Actions" %}</th>
</tr>
{% for answer in message.answers.all %}
<tr>
<td>{{answer.person}}</td>
<td>{{answer.content|truncatechars:50|linebreaksbr}}</td>
<td></td>
<td><a data-toggle="modal" data-target="#updateAnswer-{{answer.id}}" href="{% url 'update_answer' pk=answer.pk %}" alt="{% trans 'Edit Answer' %}"><i class="fa fa-pencil"></i> </a></td>
</tr>

<div class="modal fade" id="updateAnswer-{{answer.id}}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content b-color">
</div>
</div>
</div>
{% endfor %}
</table>
</div>
</div>
</div>

<div class="modal fade" id="createAnswer" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal fade" id="editAnswer" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content b-color">
</div>
</div>
</div>
<div class="modal fade" id="updateAnswer" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content b-color">
</div>
Expand Down
25 changes: 25 additions & 0 deletions nuntium/templates/nuntium/profiles/update_answer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{% load i18n %}
{% load subdomainurls %}
{% load staticfiles %}
<div class="modal-dialog modal-lg">
<div class="modal-content b-color">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="myModalLabel">{% blocktrans with person=answer.person message=answer.message.subject|linebreaksbr %}Update answer by {{person}} for message "{{ message }}"{% endblocktrans %}</h4>
</div>
<form action="{% url 'update_answer' pk=answer.pk %}" method="POST">{% csrf_token %}
<div class="modal-body">
{{ form.non_field_errors }}
<div class="fieldWrapper">
{{ form.content.errors }}
<label for="id_subject">{{ form.content.label_tag }}</label>
{{ form.content }}
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{% trans "Close" %}</button>
<button type="submit" class="btn btn-primary">{% trans "Update" %}</button>
</div>
</div>
</form>
</div>
9 changes: 8 additions & 1 deletion nuntium/user_section/tests/manually_create_answers_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,14 @@ def test_posting_as_non_the_owner(self):

self.assertEquals(response.status_code, 404)


def test_get_the_edit_form(self):
'''Getting the update form'''
url = reverse('update_answer', kwargs={'pk':self.answer.pk})
c = Client()
c.login(username=self.writeitinstance.owner.username, password='admin')
response = c.get(url)
self.assertEquals(response.status_code, 200)
self.assertTemplateUsed(response, 'nuntium/profiles/update_answer.html')

class DeleteMessageView(UserSectionTestCase):
def setUp(self):
Expand Down

0 comments on commit 357bae9

Please sign in to comment.