Commit e2f6773146d04da9349ad06910a37e4bfc5f9052

Authored by Sergio Oliveira
1 parent 141b0875

Fixing message sending

src/super_archives/templates/superarchives/includes/message.html
@@ -53,7 +53,7 @@ @@ -53,7 +53,7 @@
53 <form method="POST"> 53 <form method="POST">
54 {% csrf_token %} 54 {% csrf_token %}
55 <p> 55 <p>
56 - <textarea placeholder="{% trans 'Send a message' %}" rows="5" class="form-control"></textarea> 56 + <textarea name="emailbody" placeholder="{% trans 'Send a message' %}" rows="5" class="form-control"></textarea>
57 </p> 57 </p>
58 <div class="col-lg-9 col-md-8 col-sm-8 col-xs-7"> 58 <div class="col-lg-9 col-md-8 col-sm-8 col-xs-7">
59 <p class="quiet">{% trans "After sending a message it will take few minutes before it shows up in here. Why don't you grab a coffee?" %}</p> 59 <p class="quiet">{% trans "After sending a message it will take few minutes before it shows up in here. Why don't you grab a coffee?" %}</p>
src/super_archives/views.py
@@ -79,10 +79,10 @@ def thread_post(request, mailinglist, thread_token): @@ -79,10 +79,10 @@ def thread_post(request, mailinglist, thread_token):
79 raise http.Http404 79 raise http.Http404
80 80
81 data = {} 81 data = {}
82 - data['email_from'] = '{} <{}>'.format(request.user.get_full_name(), 82 + data['from'] = '{} <{}>'.format(request.user.get_full_name(),
83 request.user.email) 83 request.user.email)
84 data['subject'] = thread.message_set.first().subject_clean 84 data['subject'] = thread.message_set.first().subject_clean
85 - data['body'] = request.POST.get('body', '').strip() 85 + data['body'] = request.POST.get('emailbody', '').strip()
86 86
87 url = urlparse.urljoin(settings.MAILMAN_API_URL, mailinglist + '/sendmail') 87 url = urlparse.urljoin(settings.MAILMAN_API_URL, mailinglist + '/sendmail')
88 88
@@ -103,10 +103,13 @@ def thread_post(request, mailinglist, thread_token): @@ -103,10 +103,13 @@ def thread_post(request, mailinglist, thread_token):
103 "in the meanwhile.")) 103 "in the meanwhile."))
104 else: 104 else:
105 if not error_msg: 105 if not error_msg:
106 - if resp and resp.status_code == 400:  
107 - error_msg = _('You cannot send an empty email') 106 + if resp is not None:
  107 + if resp.status_code == 400:
  108 + error_msg = _('You cannot send an empty email')
  109 + elif resp.status_code == 404:
  110 + error_msg = _('Mailing list does not exist')
108 else: 111 else:
109 - error_msg = _('Unkown error trying to connect to Mailman API') 112 + error_msg = _('Unkown error trying to connect to Mailman API')
110 messages.error(request, error_msg) 113 messages.error(request, error_msg)
111 114
112 return thread_get(request, mailinglist, thread_token) 115 return thread_get(request, mailinglist, thread_token)