From fbbcbfc099cf51cd13463d3c94c9b59d44e66a22 Mon Sep 17 00:00:00 2001 From: Mohamed Feddad Date: Mon, 10 Feb 2020 00:18:05 +0300 Subject: [PATCH] Add pull random ticket. And small housekeeping. --- .gitignore | 6 ++++++ app/database.py | 1 + app/views/core.py | 30 ++++++++++++++++++++++++++++++ gt_cached.json | 7 +++++++ templates/all_offices.html | 24 +++++++++++++++++++----- templates/offices.html | 24 +++++++++++++++++++----- templates/tasks.html | 24 +++++++++++++++++++----- tests/core.py | 14 ++++++++++++++ todo_now.md | 2 +- 9 files changed, 116 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 51b162a..860da5f 100644 --- a/.gitignore +++ b/.gitignore @@ -105,3 +105,9 @@ installiation/ # editor .vscode/ + +# database +data.sqlite + +# audio files +*.mp3 diff --git a/app/database.py b/app/database.py index 772fadb..cfc3b17 100644 --- a/app/database.py +++ b/app/database.py @@ -198,6 +198,7 @@ def pull(self, office_id): self.pulledBy = getattr(current_user, 'id', None) self.office_id = office_id + db.session.add(self) db.session.commit() diff --git a/app/views/core.py b/app/views/core.py index 4b498a0..d5273ed 100644 --- a/app/views/core.py +++ b/app/views/core.py @@ -269,6 +269,36 @@ def operators_not_allowed(): return general_redirection +@core.route('/pull_unordered//', defaults={'office_id': None}) +@core.route('/pull_unordered///') +@login_required +@refill_waiting_list +def pull_unordered(ticket_id, redirect_to, office_id=None): + office = data.Office.get(office_id) + ticket = data.Serial.query.filter_by(id=ticket_id).first() + strict_pulling = data.Settings.get().strict_pulling + show_prefix = data.Display_store.get().prefix + + if not ticket: + flash('Error: wrong entry, something went wrong', 'danger') + return redirect(url_for('core.root')) + + if is_operator() and not (is_office_operator(ticket.office_id) + if strict_pulling else + is_common_task_operator(ticket.task_id)): + flash('Error: operators are not allowed to access the page ', 'danger') + return redirect(url_for('core.root')) + + office = office or ticket.office + + data.Waiting_c.assume(ticket, office, ticket.task, show_prefix) + ticket.pull(office.id) + data.Waiting.drop([ticket]) + + flash('Notice: Ticket has been pulled ..', 'info') + return redirect(f'{redirect_to}'.replace('(', '/')) + + @core.route('/feed') def feed(): ''' stream list of waiting tickets and current ticket. ''' diff --git a/gt_cached.json b/gt_cached.json index 59f47a8..8122a48 100644 --- a/gt_cached.json +++ b/gt_cached.json @@ -1973,6 +1973,13 @@ "fr": "Trait\u00e9", "it": "Processed" }, + "Pull": { + "ar": "\u0633\u062d\u0628. \u0634\u062f", + "en": "Pull", + "es": "Halar", + "fr": "Tirer", + "it": "Tirare" + }, "Pull a ticket": { "ar": "\u0633\u062d\u0628 \u062a\u0630\u0643\u0631\u0629", "en": "Pull a ticket", diff --git a/templates/all_offices.html b/templates/all_offices.html index 23d3f10..c223495 100644 --- a/templates/all_offices.html +++ b/templates/all_offices.html @@ -67,13 +67,13 @@

{{ translate('All tickets', 'en', [defLang