Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Ensure unique study programmes #242

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions eprihlaska/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

DIR = os.path.dirname(os.path.abspath(__file__))

SELECT_STUDY_PROGRAMME = _('Vyberte si, prosím, aspoň prvý študijný program')
NO_ACCESS_MSG = _('Nemáte oprávnenie pre prístup k danému prístupovému bodu')
SELECT_STUDY_PROGRAMME = _('Vyberte si, prosím, aspoň prvý študijný program') # noqa
SELECT_STUDY_PROGRAMME_ONCE = _('Vyberte si, prosím, študijný program najviac jeden krát') # noqa
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tvinar I am not really sure what the proper spelling would be, so I'd be very happy to take any suggestions 🙂

NO_ACCESS_MSG = _('Nemáte oprávnenie pre prístup k danému prístupovému bodu') # noqa
DEAN_LIST_MSG = _('Na základe listu dekana nie je potrebné zadávať údaje o prospechu na strednej škole.') # noqa
LOGIN_CONGRATS_MSG = _('Gratulujeme, boli ste prihlásení do prostredia ePrihlaska!') # noqa
PASSWD_CHANGED_MSG = _('Gratulujeme, Vaše heslo bolo nastavené! Prihláste sa ním, prosím, nižšie.') # noqa
Expand Down
8 changes: 8 additions & 0 deletions eprihlaska/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,14 @@ def study_programme():

session['study_programme'] = study_programme

set_ssp = set([x for x in study_programme if x != '_'])
list_ssp = list([x for x in study_programme if x != '_'])

# Ensure there are no duplicates within the study_programme list
if len(set_ssp) != len(list_ssp):
flash(consts.SELECT_STUDY_PROGRAMME_ONCE, 'error')
return redirect(url_for('study_programme'))

# Select at least one study programme
if study_programme[0] == '_':
flash(consts.SELECT_STUDY_PROGRAMME, 'error')
Expand Down