Commit e2f6773146d04da9349ad06910a37e4bfc5f9052
1 parent
141b0875
Exists in
master
and in
39 other branches
Fixing message sending
Showing
2 changed files
with
9 additions
and
6 deletions
Show diff stats
src/super_archives/templates/superarchives/includes/message.html
... | ... | @@ -53,7 +53,7 @@ |
53 | 53 | <form method="POST"> |
54 | 54 | {% csrf_token %} |
55 | 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 | 57 | </p> |
58 | 58 | <div class="col-lg-9 col-md-8 col-sm-8 col-xs-7"> |
59 | 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 | 79 | raise http.Http404 |
80 | 80 | |
81 | 81 | data = {} |
82 | - data['email_from'] = '{} <{}>'.format(request.user.get_full_name(), | |
82 | + data['from'] = '{} <{}>'.format(request.user.get_full_name(), | |
83 | 83 | request.user.email) |
84 | 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 | 87 | url = urlparse.urljoin(settings.MAILMAN_API_URL, mailinglist + '/sendmail') |
88 | 88 | |
... | ... | @@ -103,10 +103,13 @@ def thread_post(request, mailinglist, thread_token): |
103 | 103 | "in the meanwhile.")) |
104 | 104 | else: |
105 | 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 | 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 | 113 | messages.error(request, error_msg) |
111 | 114 | |
112 | 115 | return thread_get(request, mailinglist, thread_token) | ... | ... |