Skip to content
This repository was archived by the owner on Nov 21, 2024. It is now read-only.

Commit f10dc1d

Browse files
Trial to trigger the registration confirmation per email
1 parent 6dbf668 commit f10dc1d

5 files changed

Lines changed: 17 additions & 10 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ variable `AMIVAPI_CONFIG` to specify the config path in the container.)
191191
If you have installed AMIV API locally, you can use the CLI to start it.
192192

193193
First, change `MONGO_HOST = 'mongodb'` in `config.py` to `'MONGO_HOST = 'localhost'`.
194-
Then, in CLI:
194+
Then, in CLI (with the environment active):
195195

196196
```sh
197197
amivapi run dev # Start development server
@@ -210,7 +210,7 @@ amivapi run --help
210210
If you have docker installed you can simply run the tests in a Docker instance:
211211

212212
```sh
213-
./run_tests.sh
213+
./run_tests.sh # potentially try with sudo
214214
```
215215

216216
By default, this will start a container with mongodb, and run

amivapi/events/email_links.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
from bson import ObjectId
1212
from eve.methods.delete import deleteitem_internal
1313
from eve.methods.patch import patch_internal
14-
from flask import Blueprint, current_app, redirect, request, make_response, render_template, g
14+
from flask import Blueprint, current_app, redirect, make_response,\
15+
render_template
1516
from itsdangerous import BadSignature, URLSafeSerializer
1617

1718
from amivapi.events.queue import update_waiting_list
@@ -78,7 +79,7 @@ def on_delete_signup(token):
7879
query = {'_id': signup_id}
7980
data_signup = current_app.data.driver.db['eventsignups'].find_one(query)
8081
if data_signup is None:
81-
error_msg = "This event might not exist anymore, or the link is broken, or we made a mistake."
82+
error_msg = "This event might not exist anymore or the link is broken."
8283
user = data_signup['user']
8384
if user is None:
8485
user = data_signup['email']
@@ -95,7 +96,8 @@ def on_delete_signup(token):
9596
if data_event["time_start"] is None:
9697
event_date = "a yet undefined day."
9798
else:
98-
event_date = datetime.strftime(data_event["time_start"], '%Y-%m-%d %H:%M')
99+
event_date = datetime.strftime(data_event["time_start"],
100+
'%Y-%m-%d %H:%M')
99101
# Serve the unregister_event page
100102
response = make_response(render_template("unregister_event.html",
101103
user=user,
@@ -107,7 +109,7 @@ def on_delete_signup(token):
107109
return response
108110

109111

110-
@email_blueprint.route('/delete_confirmed/<token>', methods = ['POST'])
112+
@email_blueprint.route('/delete_confirmed/<token>', methods=['POST'])
111113
def on_delete_confirmed(token):
112114
try:
113115
s = URLSafeSerializer(get_token_secret())

amivapi/events/templates/unregister_event.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ <h1>
3333
Is that ok?
3434
{% else %}
3535
You clicked on a opt-out link of the AMIV at ETHZ student organization. We cannot process your request,
36-
because we either do <em>{not}</em> know the event you wish to unregister from, or your user name, or both.
36+
because we either do <em>not</em> know the event you wish to unregister from, or your user name, or both.
3737
{% endif %}
3838
</p>
3939

amivapi/settings.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,14 @@
6262
REMOTE_MAILING_LIST_ADDRESS = None
6363
REMOTE_MAILING_LIST_KEYFILE = None
6464
REMOTE_MAILING_LIST_DIR = './' # Use home directory on remote by default
65-
# Signups via email (@email_blueprint.route('/delete_signup/<token>') in email_links.py)
65+
# Signups via email (@email_blueprint.route('/delete_signup/<token>')
66+
# in email_links.py)
6667
# DEFINITIVE_DELETE = ''
6768

6869
# SMTP server defaults
6970
API_MAIL = 'api@amiv.ethz.ch'
7071
API_MAIL_SUBJECT = "[AMIV] {subject}"
71-
SMTP_HOST = 'localhost' # None in case you want to accept that no mails get sent (local testing)
72+
SMTP_HOST = 'localhost'
7273
SMTP_PORT = 587
7374
SMTP_TIMEOUT = 10
7475

amivapi/tests/events/test_emails.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ def test_email_signup_delete(self):
5656

5757
# With redirect set
5858
self.app.config['SIGNUP_DELETED_REDIRECT'] = "somewhere"
59-
self.api.get('/delete_signup/%s' % token, status_code=302)
59+
self.api.get('/eventsignups/%s' % signup['_id'], status_code=200)
60+
self.api.get('/delete_signup/%s' % token, status_code=200)
61+
self.api.post('/delete_confirmed/%s' % token, status_code=302)
6062

6163
# Check that signup was deleted
6264
self.api.get('/eventsignups/%s' % signup['_id'], status_code=404)
@@ -72,7 +74,9 @@ def test_email_signup_delete(self):
7274

7375
# Without redirect set
7476
self.app.config.pop('SIGNUP_DELETED_REDIRECT')
77+
self.api.get('/eventsignups/%s' % signup['_id'], status_code=200)
7578
self.api.get('/delete_signup/%s' % token, status_code=200)
79+
self.api.post('/delete_confirmed/%s' % token, status_code=302)
7680

7781
# Check that signup was deleted
7882
self.api.get('/eventsignups/%s' % signup['_id'], status_code=404)

0 commit comments

Comments
 (0)