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

Commit

Permalink
Trial to trigger the registration confirmation per email
Browse files Browse the repository at this point in the history
  • Loading branch information
lioneltrebuchon committed Dec 1, 2019
1 parent 6dbf668 commit 09ff765
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ variable `AMIVAPI_CONFIG` to specify the config path in the container.)
If you have installed AMIV API locally, you can use the CLI to start it.

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

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

```sh
./run_tests.sh
./run_tests.sh # potentially try with sudo
```

By default, this will start a container with mongodb, and run
Expand Down
10 changes: 6 additions & 4 deletions amivapi/events/email_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
from bson import ObjectId
from eve.methods.delete import deleteitem_internal
from eve.methods.patch import patch_internal
from flask import Blueprint, current_app, redirect, request, make_response, render_template, g
from flask import Blueprint, current_app, redirect, make_response,\
render_template
from itsdangerous import BadSignature, URLSafeSerializer

from amivapi.events.queue import update_waiting_list
Expand Down Expand Up @@ -78,7 +79,7 @@ def on_delete_signup(token):
query = {'_id': signup_id}
data_signup = current_app.data.driver.db['eventsignups'].find_one(query)
if data_signup is None:
error_msg = "This event might not exist anymore, or the link is broken, or we made a mistake."
error_msg = "This event might not exist anymore or the link is broken."
user = data_signup['user']
if user is None:
user = data_signup['email']
Expand All @@ -95,7 +96,8 @@ def on_delete_signup(token):
if data_event["time_start"] is None:
event_date = "a yet undefined day."
else:
event_date = datetime.strftime(data_event["time_start"], '%Y-%m-%d %H:%M')
event_date = datetime.strftime(data_event["time_start"],
'%Y-%m-%d %H:%M')
# Serve the unregister_event page
response = make_response(render_template("unregister_event.html",
user=user,
Expand All @@ -107,7 +109,7 @@ def on_delete_signup(token):
return response


@email_blueprint.route('/delete_confirmed/<token>', methods = ['POST'])
@email_blueprint.route('/delete_confirmed/<token>', methods=['POST'])
def on_delete_confirmed(token):
try:
s = URLSafeSerializer(get_token_secret())
Expand Down
2 changes: 1 addition & 1 deletion amivapi/events/templates/unregister_event.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ <h1>
Is that ok?
{% else %}
You clicked on a opt-out link of the AMIV at ETHZ student organization. We cannot process your request,
because we either do <em>{not}</em> know the event you wish to unregister from, or your user name, or both.
because we either do <em>not</em> know the event you wish to unregister from, or your user name, or both.
{% endif %}
</p>

Expand Down
5 changes: 3 additions & 2 deletions amivapi/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,14 @@
REMOTE_MAILING_LIST_ADDRESS = None
REMOTE_MAILING_LIST_KEYFILE = None
REMOTE_MAILING_LIST_DIR = './' # Use home directory on remote by default
# Signups via email (@email_blueprint.route('/delete_signup/<token>') in email_links.py)
# Signups via email (@email_blueprint.route('/delete_signup/<token>')
# in email_links.py)
# DEFINITIVE_DELETE = ''

# SMTP server defaults
API_MAIL = '[email protected]'
API_MAIL_SUBJECT = "[AMIV] {subject}"
SMTP_HOST = 'localhost' # None in case you want to accept that no mails get sent (local testing)
SMTP_HOST = 'localhost'
SMTP_PORT = 587
SMTP_TIMEOUT = 10

Expand Down
4 changes: 3 additions & 1 deletion amivapi/tests/events/test_emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ def test_email_signup_delete(self):

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

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

0 comments on commit 09ff765

Please sign in to comment.