Skip to content

Commit

Permalink
Merge pull request #214 from mrf345/development
Browse files Browse the repository at this point in the history
Add option to hide ticket index number, Resolves #188
  • Loading branch information
mrf345 authored Aug 31, 2020
2 parents 3ef9110 + 61a2cc0 commit db45c90
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 5 deletions.
5 changes: 4 additions & 1 deletion app/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@ class Display_store(db.Model, Mixin):
prefix = db.Column(db.Boolean, default=False)
always_show_ticket_number = db.Column(db.Boolean, default=False)
wait_for_announcement = db.Column(db.Boolean)
hide_ticket_index = db.Column(db.Boolean)
# adding repeat announcement value
r_announcement = db.Column(db.Boolean)
akey = db.Column(db.Integer, db.ForeignKey("media.id",
Expand All @@ -573,7 +574,8 @@ def __init__(self, id=0, title="FQM Queue Management",
sfont="Amiri", mduration="3000", rrate="2000",
announce="en-us", ikey=4, vkey=None, akey=None,
anr=2, anrt="each", bgcolor="rgb(0,0,0)", tmp=1,
wait_for_announcement=True):
wait_for_announcement=True,
hide_ticket_index=False):
self.id = 0
self.tfont = tfont
self.hfont = hfont
Expand Down Expand Up @@ -606,6 +608,7 @@ def __init__(self, id=0, title="FQM Queue Management",
self.vkey = vkey
self.akey = akey
self.wait_for_announcement = wait_for_announcement
self.hide_ticket_index = hide_ticket_index


# -- Slides storage table
Expand Down
1 change: 1 addition & 0 deletions app/forms/customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class DisplayScreenForm(LocalizedForm):
prefix = BooleanField('Attach prefix office letter: ')
always_show_ticket_number = BooleanField('Always show ticket number: ')
wait_for_announcement = BooleanField('Wait for announcement to finish:')
hide_ticket_index = BooleanField('Hide ticket index number:')
submit = SubmitField('Apply')

for shortcode in get_tts_safely().keys():
Expand Down
8 changes: 6 additions & 2 deletions app/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,22 +323,26 @@ def on_hold(ticket, redirect_to):
def feed(office_id=None):
''' stream list of waiting tickets and current ticket. '''
single_row = data.Settings.get().single_row
hide_ticket_index = data.Display_store.get().hide_ticket_index
current_ticket = data.Serial.get_last_pulled_ticket(office_id)
empty_text = gtranslator.translate('Empty', dest=[session.get('lang')])
current_ticket_text = current_ticket and current_ticket.display_text or empty_text
current_ticket_office_name = current_ticket and current_ticket.office.display_text or empty_text
current_ticket_task_name = current_ticket and current_ticket.task.name or empty_text

def _resolve_ticket_index(_index):
return '' if hide_ticket_index else f'{_index + 1}. '

if single_row:
waiting_list_parameters = {
f'w{_index + 1}': f'{_index + 1}. {number}'
f'w{_index + 1}': f'{_resolve_ticket_index(_index)}{number}'
for _index, number in enumerate(range(getattr(current_ticket, 'number', 1) + 1,
getattr(current_ticket, 'number', 1) + 10))}
else:
waiting_tickets = (data.Serial.get_waiting_list_tickets(office_id) + ([None] * 9))[:9]
waiting_list_parameters = {
f'w{_index + 1}':
f'{_index + 1}. {ticket.display_text}' if ticket else empty_text
f'{_resolve_ticket_index(_index)}{ticket.display_text}' if ticket else empty_text
for _index, ticket in enumerate(waiting_tickets)}

# NOTE: Ensure `waiting_list_parameters` last value is as distinct as the `current_ticket`
Expand Down
2 changes: 2 additions & 0 deletions app/views/customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ def displayscreen_c(stab):
touch_s.prefix = form.prefix.data
touch_s.always_show_ticket_number = form.always_show_ticket_number.data
touch_s.wait_for_announcement = form.wait_for_announcement.data
touch_s.hide_ticket_index = form.hide_ticket_index.data

if not form.background.data:
touch_s.bgcolor = form.bgcolor.data
Expand Down Expand Up @@ -490,6 +491,7 @@ def displayscreen_c(stab):
form.prefix.data = touch_s.prefix
form.always_show_ticket_number.data = touch_s.always_show_ticket_number
form.wait_for_announcement.data = touch_s.wait_for_announcement
form.hide_ticket_index.data = touch_s.hide_ticket_index

if touch_s.bgcolor[:3] == 'rgb':
form.bgcolor.data = touch_s.bgcolor
Expand Down
21 changes: 21 additions & 0 deletions gt_cached.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@
"fr": "5 fois",
"it": "5 volte"
},
"6 times": {
"ar": "6 \u0645\u0631\u0627\u062a",
"en": "6 times",
"es": "6 veces",
"fr": "6 fois",
"it": "6 volte"
},
"7 times": {
"ar": "7 \u0645\u0631\u0627\u062a",
"en": "7 times",
Expand Down Expand Up @@ -1274,6 +1281,13 @@
"fr": "Masquer cette t\u00e2che:",
"it": "Nascondere questo compito:"
},
"Hide ticket index number:": {
"ar": "\u0625\u062e\u0641\u0627\u0621 \u0627\u0644\u0631\u0642\u0645 \u0627\u0644\u0642\u064a\u0627\u0633\u064a \u062a\u0630\u0643\u0631\u0629:",
"en": "Hide ticket index number:",
"es": "Ocultar n\u00famero de \u00edndice de entradas:",
"fr": "Cacher num\u00e9ro d'index de billets:",
"it": "Nascondi numero indice del biglietto:"
},
"ID . Name": {
"ar": "\u0647\u0648\u064a\u0629 \u0634\u062e\u0635\u064a\u0629 . \u0627\u0633\u0645",
"en": "ID . Name",
Expand Down Expand Up @@ -3693,6 +3707,13 @@
"fr": "choisissez la police de titre de titre principal:",
"it": "scegli il carattere del biglietto principale:"
},
"choose main heading ticket font size :": {
"ar": "\u0627\u062e\u062a\u064a\u0627\u0631 \u0627\u0644\u0631\u0626\u064a\u0633\u064a\u0629 \u062d\u062c\u0645 \u062a\u0630\u0643\u0631\u0629 \u0639\u0646\u0648\u0627\u0646 \u0627\u0644\u062e\u0637:",
"en": "choose main heading ticket font size :",
"es": "elegir el tama\u00f1o de la fuente principal de entradas t\u00edtulo:",
"fr": "choisir la taille principale de police billet intitul\u00e9:",
"it": "sceglie il formato principale del carattere intestazione biglietto:"
},
"choose main heading ticket font size : ": {
"ar": "\u0627\u062e\u062a\u0631 \u062d\u062c\u0645 \u062e\u0637 \u062a\u0630\u0643\u0631\u0629 \u0627\u0644\u0639\u0646\u0648\u0627\u0646 \u0627\u0644\u0631\u0626\u064a\u0633\u064a:",
"en": "choose main heading ticket font size :",
Expand Down
27 changes: 27 additions & 0 deletions migrations/versions/69efa7247067_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""Add hide_ticket_index option to Display Customization.
Revision ID: 69efa7247067
Revises: ec3035d61f8b
Create Date: 2020-08-31 22:05:00.672787
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '69efa7247067'
down_revision = 'ec3035d61f8b'
branch_labels = None
depends_on = None


def upgrade():
try:
op.add_column('displays', sa.Column('hide_ticket_index', sa.Boolean(), nullable=True))
except Exception:
pass

def downgrade():
with op.batch_alter_table('displays') as batch:
batch.drop_column('hide_ticket_index')
3 changes: 2 additions & 1 deletion templates/display_screen.html
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ <h3 class="text text-muted text-center mt-2 ar2">
<hr>
{{ render_field(form.ssize, class="form-control") }}
{{ render_field(form.scolor, class="sp") }}
{{ render_field(form.sfont, class="form-control") }}
{{ render_field(form.sfont, class="form-control") }}
{{ render_field(form.hide_ticket_index, class="form-control") }}
<p class="pb-9"></p>
{{ unique_btns(translate('Previous', 'en', [defLang]), translate('Apply', 'en', [defLang]), translate('Next', 'en', [defLang])) }}
<p class="pb-3"></p>
Expand Down
3 changes: 2 additions & 1 deletion tests/customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,8 @@ def test_display_screen_customization(c):
'repeats': '2',
'prefix': True,
'always_show_ticket_number': True,
'bgcolor': 'testing'
'bgcolor': 'testing',
'hide_ticket_index': True
}
data = {f'check{s}': True for s in get_tts_safely().keys()}
data.update({'display': 1,
Expand Down

0 comments on commit db45c90

Please sign in to comment.