def __init__(self, defLang='en', *args, **kwargs): super(Multimedia, self).__init__(*args, **kwargs) self.mf.label = gtranslator.translate("Select multimedia file :", 'en', [defLang]) self.mf.validators = [ FileAllowed( reduce(lambda sum, group: sum + group, SUPPORTED_MEDIA_FILES), gtranslator.translate( 'make sure you followed the given conditions !', 'en', [defLang])) ]
def __init__(self, defLang='en', *args, **kwargs): super(U_admin, self).__init__(*args, **kwargs) self.password.label = gtranslator.translate("Enter password : "******"Password must be at least of 5 and at most 15 letters", 'en', [defLang])), Length(5, 15) ]
def __init__(self, defLang='en', *args, **kwargs): super(CSV, self).__init__(*args, **kwargs) self.headers.label = gtranslator.translate( 'Show headers in the CSV file :', 'en', [defLang]) self.headers.choices = [(t[0], gtranslator.translate(t[1], 'en', [defLang])) for t in [(1, 'Enable'), (0, 'Disable')]] self.delimiter.label = gtranslator.translate( 'Character to separate the CSV fields with :', 'en', [defLang]) self.delimiter.choices = list(export_options.items()) self.table.label = gtranslator.translate( 'Select table to download its csv :', 'en', [defLang]) self.table.choices = [(e[0], gtranslator.translate(e[1], 'en', [defLang])) for e in export_tabels]
def __init__(self, defLang='en', common=False, *args, **kwargs): super(Task_a, self).__init__(*args, **kwargs) self.name.label = gtranslator.translate( "Enter unique title for the task : ", 'en', [defLang]) self.name.validators = [ InputRequired( gtranslator.translate( "Required not less than 5 nor more than 300 letters", 'en', [defLang])), Length(5, 300) ] if common: for office in data.Office.query.all(): self['check%i' % office.id].label = '%s %i:' % (gtranslator.translate( "Office", 'en', [defLang]), office.name)
def get_translation(text, language): translated = gtranslator.translate(text, dest=[language]) if language == 'en': translated = get_with_alias().get(text) or translated return translated
def feed(office_id=None): ''' stream list of waiting tickets and current ticket. ''' 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 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 for _index, ticket in enumerate(waiting_tickets) } # NOTE: Ensure `waiting_list_parameters` last value is as distinct as the `current_ticket` # To fix `uniqueness` not picking up the change in passed waiting list waiting_list_parameters[f'w{len(waiting_list_parameters)}'] = ( current_ticket.name if current_ticket.n else current_ticket.number) if current_ticket else empty_text return jsonify(con=current_ticket_office_name, cot=current_ticket_text, cott=current_ticket_task_name, **waiting_list_parameters)
def __init__(self, defLang='en', *args, **kwargs): super(Touch_name, self).__init__(*args, **kwargs) self.name.validators = [ InputRequired( gtranslator.translate( "Required not less than 5 nor more than 300 letters", 'en', [defLang])), Length(3, 300) ]
def feed(office_id=None): ''' stream list of waiting tickets and current ticket. ''' display_settings = data.Display_store.get() single_row = data.Settings.get().single_row 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 display_settings.hide_ticket_index else f'{_index + 1}. ' if single_row: tickets_parameters = { 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] tickets_parameters = { f'w{_index + 1}': f'{_resolve_ticket_index(_index)}{ticket.display_text}' if ticket else empty_text for _index, ticket in enumerate(waiting_tickets) } # NOTE: Add last 10 processed tickets, for supported template. if display_settings.tmp == 3: processed_tickets = ( data.Serial.get_processed_tickets(office_id, offset=1) + ([None] * 9))[:9] tickets_parameters.update({ f'p{_index + 1}': f'{_resolve_ticket_index(_index)}{ticket.display_text}' if ticket else empty_text for _index, ticket in enumerate(processed_tickets) }) # NOTE: Ensure `tickets_parameters` last value is as distinct as the `current_ticket` # To fix `uniqueness` not picking up the change in passed waiting list tickets_parameters[f'w{len(tickets_parameters)}'] = ( current_ticket.name if current_ticket.n else current_ticket.number) if current_ticket else empty_text return jsonify(con=current_ticket_office_name, cot=current_ticket_text, cott=current_ticket_task_name, **tickets_parameters)
def __init__(self, inspected_printers_from_view, lp_printing, defLang='en', *args, **kwargs): super(Printer_f, self).__init__(*args, **kwargs) self.kind.label = gtranslator.translate( "Select type of ticket to use : ", 'en', [defLang]) self.kind.choices = [(t[0], gtranslator.translate(t[1], 'en', [defLang])) for t in [(1, 'Registered'), (2, 'Printed')]] self.value.label = gtranslator.translate( "Select a value of registering : ", 'en', [defLang]) self.value.choices = [(t[0], gtranslator.translate(t[1], 'en', [defLang])) for t in [(1, 'Name'), (2, 'Number')]] self.langu.label = gtranslator.translate( "Select language of printed ticket : ", 'en', [defLang]) self.printers.label = gtranslator.translate('Select a usb printer : ', 'en', [defLang]) self.scale.label = gtranslator.translate( 'Select font scaling measurement for printed tickets :', 'en', [defLang]) self.scale.choices = [(i, f'x{i}') for i in PRINTED_TICKET_SCALES] printer_choices = [] if inspected_printers_from_view: for printer in inspected_printers_from_view: if name == 'nt' or lp_printing: printer_choices.append( (f'{printer}', f'Printer Name: {printer}')) else: vendor, product = printer.get('vendor'), printer.get( 'product') in_ep, out_ep = printer.get('in_ep'), printer.get('out_ep') identifier = f'{vendor}_{product}' if in_ep and out_ep: identifier += f'_{in_ep}_{out_ep}' printer_choices.append( (identifier, f'Printer ID: {vendor}_{product}')) else: printer_choices.append( ('00', gtranslator.translate("No printers were found", 'en', [defLang]))) self.printers.choices = printer_choices
def __init__(self, defLang='en', *args, **kwargs): super(Login, self).__init__(*args, **kwargs) self.name.label = gtranslator.translate('Enter user name : ', 'en', [defLang]) self.name.validators = [ InputRequired( gtranslator.translate( "Required not less than 5 nor more than 200 letters", 'en', [defLang])), Length(5, 200) ] self.password.label = gtranslator.translate("Enter password : "******"Password must be at least of 5 and at most 15 letters", 'en', [defLang])), Length(5, 15) ] self.rm.label = gtranslator.translate("Remember me : ", 'en', [defLang])
def __init__(self, defLang='en', *args, **kwargs): super(Search_s, self).__init__(*args, **kwargs) self.number.label = gtranslator.translate( "Please enter a ticket number : ", 'en', [defLang]) self.tl.label = gtranslator.translate("Select ticket prefix : ", 'en', [defLang]) self.tl.validators = [ InputRequired( gtranslator.translate("You must select a prefix to search for", 'en', [defLang])) ] self.date.label = gtranslator.translate("Select date to search for : ", 'en', [defLang]) prf = [] prf.append( (0, gtranslator.translate("Without a prefix", 'en', [defLang]))) for v in data.Office.query: p = data.Office.query.filter_by(id=v.id).first() if p is not None: prf.append( (p.id, p.prefix + str(p.name) + " , Prefix: " + p.prefix)) self.tl.choices = prf
def translate(self, text, _from='en'): '''Convinant helper to translate text. Parameters ---------- text : str text to be translated. Returns ------- str translated text. ''' with current_app.app_context(): language = session.get('lang', 'en') return translator.translate(text, _from, [language])
def __init__(self, inspected_printers_from_view, defLang='en', *args, **kwargs): super(Printer_f, self).__init__(*args, **kwargs) self.kind.label = gtranslator.translate( "Select type of ticket to use : ", 'en', [defLang]) self.kind.choices = [(t[0], gtranslator.translate(t[1], 'en', [defLang])) for t in [(1, 'Registered'), (2, 'Printed')]] self.value.label = gtranslator.translate( "Select a value of registering : ", 'en', [defLang]) self.value.choices = [(t[0], gtranslator.translate(t[1], 'en', [defLang])) for t in [(1, 'Name'), (2, 'Number')]] self.langu.label = gtranslator.translate( "Select language of printed ticket : ", 'en', [defLang]) self.printers.label = gtranslator.translate('Select a usb printer : ', 'en', [defLang]) self.scale.label = gtranslator.translate( 'Select font scaling measurement for printed tickets :', 'en', [defLang]) self.scale.choices = [(i, f'x{i}') for i in PRINTED_TICKET_SCALES] printers = [] inspected_printers = inspected_printers_from_view if len(inspected_printers) >= 1: for printer in inspected_printers: if name == 'nt': printers.append( (str(printer), 'Printer Name: ' + str(printer))) else: ful = str(printer[0]) + '_' + str(printer[1]) ful += '_' + str(printer[2]) + '_' + str(printer[3]) printers.append((ful, 'Printer ID : ' + str(printer[0]) + '_' + str(printer[1]))) else: printers.append(('00', gtranslator.translate("No printers were found", 'en', [defLang]))) self.printers.choices = printers
def __init__(self, defLang='en', *args, **kwargs): super(User_a, self).__init__(*args, **kwargs) self.name.label = gtranslator.translate("Enter a unique user name : ", 'en', [defLang]) self.name.validators = [ InputRequired( gtranslator.translate( "Required not less than 5 nor more than 200 letters", 'en', [defLang])), Length(5, 200) ] self.password.label = gtranslator.translate("Enter password : "******"Password must be at least of 5 and at most 15 letters", 'en', [defLang])), Length(5, 15) ] self.role.label = gtranslator.translate( "Select a role for the user : "******"You must select a role to add user in", 'en', [defLang])) ] self.offices.label = gtranslator.translate( "Select office to assing the operator to : ", 'en', [defLang]) self.offices.validators = [Optional()] self.role.choices = [(v.id, v.name) for v in data.Roles.query if v.id != 3] self.offices.choices = [(o.id, 'Office : ' + str(o.name) + o.prefix) for o in data.Office.query] # Hide operators role, if no offices created yet if data.Office.query.count() > 0: self.role.choices += [ (3, data.Roles.query.filter_by(id=3).first().name) ]
def __init__(self, defLang='en', *args, **kwargs): super(Alias, self).__init__(*args, **kwargs) self.office.validators = self.task.validators = self.ticket.validators = self.name.validators = self.number.validators = [ InputRequired( gtranslator.translate( "Alias must be at least of 2 and at most 10 letters", 'en', [defLang])), Length(2, 10) ] self.office.label = gtranslator.translate('Enter alias for office : ', 'en', [defLang]) self.task.label = gtranslator.translate('Enter alias for task : ', 'en', [defLang]) self.ticket.label = gtranslator.translate('Enter alias for ticket : ', 'en', [defLang]) self.name.label = gtranslator.translate('Enter alias for name : ', 'en', [defLang]) self.number.label = gtranslator.translate('Enter alias for number : ', 'en', [defLang])
def get_translation(self, text): current_language = list(self.languages.keys())[self.languages_list.currentIndex()] return gtranslator.translate(text, dest=[current_language])
def __init__(self, defLang='en', *args, **kwargs): super(Video, self).__init__(*args, **kwargs) self.video.label = gtranslator.translate( "Select uploaded video to use : ", 'en', [defLang]) self.video.validators = [ InputRequired( gtranslator.translate("You must select a video to be used", 'en', [defLang])) ] self.enable.label = gtranslator.translate("Enable or disable video : ", 'en', [defLang]) self.enable.choices = [(t[0], gtranslator.translate(t[1], 'en', [defLang])) for t in [(1, "Enable"), (2, "Disable")]] self.ar.label = gtranslator.translate("Auto replaying the video : ", 'en', [defLang]) self.ar.choices = [(t[0], gtranslator.translate(t[1], 'en', [defLang])) for t in [(1, "Enable"), (2, "Disable")]] self.controls.label = gtranslator.translate( "Enable or disable video controls : ", 'en', [defLang]) self.controls.choices = [(t[0], gtranslator.translate(t[1], 'en', [defLang])) for t in [(1, "Enable"), (2, "Disable")]] self.mute.label = gtranslator.translate("Mute sound : ", 'en', [defLang]) self.mute.choices = [(t[0], gtranslator.translate(t[1], 'en', [defLang])) for t in [(1, "Enable"), (2, "Disable")]] vds = [] if data.Media.query.filter_by(vid=True).count() >= 1: for v in data.Media.query.filter_by(vid=True): vds.append((v.id, str(v.id) + ". " + v.name)) vds.append((00, gtranslator.translate("Do not assign video", 'en', [defLang]))) else: vds.append((00, gtranslator.translate("No videos were found", 'en', [defLang]))) self.video.choices = vds
def __init__(self, defLang='en', *args, **kwargs): super(Display_c, self).__init__(*args, **kwargs) self.display.label = gtranslator.translate( 'Select a template for Display screen : ', 'en', [defLang]) self.display.choices = [ (t[0], gtranslator.translate(t[1], 'en', [defLang])) for t in tms ] self.title.label = gtranslator.translate('Enter a title : ', 'en', [defLang]) self.title.validators = [ InputRequired( gtranslator.translate("Title should be maximum of 300 letters", 'en', [defLang])), Length(0, 300) ] self.background.label = gtranslator.translate('Select a background : ', 'en', [defLang]) self.hsize.label = gtranslator.translate('Choose title font size : ', 'en', [defLang]) self.hsize.choices = [(t[0], gtranslator.translate(t[1], 'en', [defLang])) for t in font_sizes] self.hcolor.label = gtranslator.translate('Choose title font color : ', 'en', [defLang]) self.hfont.label = gtranslator.translate('Choose title font : ', 'en', [defLang]) self.hbg.label = gtranslator.translate( 'Choose title background color : ', 'en', [defLang]) self.tsize.label = gtranslator.translate( "choose main heading office font size :", 'en', [defLang]) self.tsize.choices = [(t[0], gtranslator.translate(t[1], 'en', [defLang])) for t in font_sizes] self.tcolor.label = gtranslator.translate( "choose main heading office color : ", 'en', [defLang]) self.tfont.label = gtranslator.translate( "choose main heading office font : ", 'en', [defLang]) self.h2color.label = gtranslator.translate( "choose main heading ticket color : ", 'en', [defLang]) self.h2size.label = gtranslator.translate( "choose main heading ticket font size : ", 'en', [defLang]) self.h2size.choices = [(t[0], gtranslator.translate(t[1], 'en', [defLang])) for t in font_sizes] self.h2font.label = gtranslator.translate( "choose main heading ticket font : ", 'en', [defLang]) self.ssize.label = gtranslator.translate( "choose secondary heading font size : ", 'en', [defLang]) self.ssize.choices = [(t[0], gtranslator.translate(t[1], 'en', [defLang])) for t in font_sizes] self.scolor.label = gtranslator.translate( "choose secondary heading color : ", 'en', [defLang]) self.sfont.label = gtranslator.translate( "choose secondary heading font :", 'en', [defLang]) self.mduration.label = gtranslator.translate( "choose motion effect duration of appearing : ", 'en', [defLang]) self.mduration.choices = [ (t[0], gtranslator.translate(t[1], 'en', [defLang])) for t in durations ] self.rrate.label = gtranslator.translate("choose page refresh rate : ", 'en', [defLang]) self.rrate.choices = [(t[0], gtranslator.translate(t[1], 'en', [defLang])) for t in durations] self.effect.label = gtranslator.translate( "choose visual motion effect for notification : ", 'en', [defLang]) self.effect.choices = [ (t[0], gtranslator.translate(t[1], 'en', [defLang])) for t in [("fade", "fade"), ("blind", "blind"), ( "bounce", "bounce"), ("clip", "clip"), ( "drop", "drop"), ("explode", "explode"), ( "fold", "fold"), ("highlight", "highlight"), ("puff", "puff"), ("pulsate", "pulsate"), ("scale", "scale"), ("shake", "shake"), ("size", "size"), ("slide", "slide")] ] self.repeats.label = gtranslator.translate( "choose motion effect number of repeats : ", 'en', [defLang]) self.repeats.choices = [ (t[0], gtranslator.translate(t[1], 'en', [defLang])) for t in [("1", "1 time"), ("2", "2 times"), ( "3", "3 times"), ("4", "4 times"), ("5", "5 times"), ( "7", "7 times"), ("8", "8 times"), ("9", "9 times"), ("10", "10 times")] ] self.announce.label = gtranslator.translate("Verbal announcement : ", 'en', [defLang]) self.anr.label = gtranslator.translate( 'Number of announcement repeating : ', 'en', [defLang]) self.anr.choices = [ (t[0], gtranslator.translate(t[1], 'en', [defLang])) for t in [(1, 'One time'), (2, 'Two times'), ( 3, 'Three times'), (4, 'Four time'), (5, 'Five times')] ] self.anrt.label = gtranslator.translate( 'Type of announcement and notification repeating :', 'en', [defLang]) self.anrt.choices = [( t[0], gtranslator.translate(t[1], 'en', [defLang]) ) for t in [ ('each', 'Each: to repeat each announcement and notification'), ('whole', 'Whole: to repeat all the announcements and notification as whole' ) ]] self.naudio.label = gtranslator.translate( "Select audio notification : ", 'en', [defLang]) self.bgcolor.label = gtranslator.translate( "Select a background color : ", 'en', [defLang]) self.prefix.label = gtranslator.translate( "Attach prefix office letter: ", 'en', [defLang]) self.submit.label = gtranslator.translate('Apply', 'en', [defLang]) bgs = [] aud = [] bgs.append( (00, gtranslator.translate("Use color selection", 'en', [defLang]))) aud.append((00, gtranslator.translate("Disable audio notification", 'en', [defLang]))) if data.Media.query.count() >= 1: for v in data.Media.query.filter_by(img=True): bgs.append((v.id, str(v.id) + ". " + v.name)) for v in data.Media.query.filter_by(audio=True): aud.append((v.id, str(v.id) + ". " + v.name)) self.naudio.choices = aud self.background.choices = bgs
def __init__(self, defLang=None, *args, **kwargs): super(Touch_c, self).__init__(*args, **kwargs) self.touch.label = gtranslator.translate( "Select a template for Touch screen :", 'en', [defLang]) self.touch.choices = [ (t[0], gtranslator.translate(t[1], 'en', [defLang])) for t in tms ] self.title.label = gtranslator.translate("Enter a title :", 'en', [defLang]) self.title.validators = [ InputRequired( gtranslator.translate( "Must enter at least 5 letters and Title " + "should be maximum of 300 letters", 'en', [defLang])), Length(5, 300) ] self.hsize.label = gtranslator.translate("Choose title font size :", 'en', [defLang]) self.hsize.choices = [(t[0], gtranslator.translate(t[1], 'en', [defLang])) for t in font_sizes] self.hcolor.label = gtranslator.translate("Select title font color :", 'en', [defLang]) self.hfont.label = gtranslator.translate("choose a font for title :", 'en', [defLang]) self.hbg.label = gtranslator.translate( "Select heading background color :", 'en', [defLang]) self.tsize.label = gtranslator.translate("choose task font size :", 'en', [defLang]) self.tsize.choices = [(t[0], gtranslator.translate(t[1], 'en', [defLang])) for t in font_sizes] self.tcolor.label = gtranslator.translate("choose tasks color :", 'en', [defLang]) self.tcolor.choices = [(t[0], gtranslator.translate(t[1], 'en', [defLang])) for t in btn_colors] self.tfont.label = gtranslator.translate("choose tasks font :", 'en', [defLang]) self.msize.label = gtranslator.translate("choose message font size :", 'en', [defLang]) self.msize.choices = [(t[0], gtranslator.translate(t[1], 'en', [defLang])) for t in font_sizes] self.mcolor.label = gtranslator.translate( "Select message font color :", 'en', [defLang]) self.mfont.label = gtranslator.translate("Choose message font :", 'en', [defLang]) self.mduration.label = gtranslator.translate( "choose motion effect duration of appearing :", 'en', [defLang]) self.mduration.choices = [ (t[0], gtranslator.translate(t[1], 'en', [defLang])) for t in durations ] self.mbg.label = gtranslator.translate( "Select message background color :", 'en', [defLang]) self.message.label = gtranslator.translate( 'Enter a notification message :', 'en', [defLang]) self.message.validators = [ InputRequired( gtranslator.translate( "Must enter at least 5" + " letter and Message should" + " be maximum of 300 letters ..", 'en', [defLang])), Length(5, 300) ] self.background.label = gtranslator.translate('Select background : ', 'en', [defLang]) self.bcolor.label = gtranslator.translate( 'Select a background color : ', 'en', [defLang]) self.naudio.label = gtranslator.translate( 'Select audio notification : ', 'en', [defLang]) self.submit.label = gtranslator.translate('Apply', 'en', [defLang]) bgs = [] aud = [] bgs.append( (00, gtranslator.translate("Use color selection", 'en', [defLang]))) aud.append((00, gtranslator.translate("Disable audio notification", 'en', [defLang]))) if data.Media.query.count() >= 1: for v in data.Media.query.filter_by(img=True): bgs.append((v.id, str(v.id) + ". " + v.name)) for v in data.Media.query.filter_by(audio=True): aud.append((v.id, str(v.id) + ". " + v.name)) self.naudio.choices = aud self.background.choices = bgs
def __init__(self, defLang='en', *args, **kwargs): super(Slide_a, self).__init__(*args, **kwargs) self.title.label = gtranslator.translate("Enter a slide title :", 'en', [defLang]) self.hsize.label = gtranslator.translate("Select a title font size :", 'en', [defLang]) self.hsize.choices = [(t[0], gtranslator.translate(t[1], 'en', [defLang])) for t in font_sizes] self.hcolor.label = gtranslator.translate( "Select a title font color :", 'en', [defLang]) self.hfont.label = gtranslator.translate("Select a title font :", 'en', [defLang]) self.hbg.label = gtranslator.translate( "Select title background color :", 'en', [defLang]) self.subti.label = gtranslator.translate("Enter a subtitle :", 'en', [defLang]) self.tsize.label = gtranslator.translate("Select subtitle font size :", 'en', [defLang]) self.tsize.choices = [(t[0], gtranslator.translate(t[1], 'en', [defLang])) for t in font_sizes] self.tcolor.label = gtranslator.translate("Select sub title color :", 'en', [defLang]) self.tfont.label = gtranslator.translate("Select subtitle font :", 'en', [defLang]) self.tbg.label = gtranslator.translate( "Select subtitle background color :", 'en', [defLang]) self.background.label = gtranslator.translate("Select background : ", 'en', [defLang]) self.bgcolor.label = gtranslator.translate( "Select background color : ", 'en', [defLang]) self.submit.label = gtranslator.translate('Add a slide', 'en', [defLang]) bgs = [] bgs.append( (00, gtranslator.translate("Use color selection", 'en', [defLang]))) if data.Media.query.count() >= 1: for v in data.Media.query.filter_by(img=True): bgs.append((v.id, str(v.id) + ". " + v.name)) self.background.choices = bgs