Skip to content
Snippets Groups Projects
Commit e766d00e authored by Anders H. Rebner's avatar Anders H. Rebner
Browse files

#101 popup bruker ikke lengre subklasse-konstanter

parent 3cd8dace
No related branches found
No related tags found
1 merge request!67#101 & #121 kodetabell-innstillings-popup og db/DB->database i GUI
Pipeline #82520 failed
......@@ -12,9 +12,6 @@ from PySide2.QtWidgets import (
)
from PySide2.QtCore import Qt
AUTHENTICATIONBOARD_MODULE = "AuthenticationBoardModule"
SUBTRACTORCODES_MODULE = "SubtractorcodesModule"
class CodeTableSettings(QDialog):
"""Setup of either AuthenticationBoardModule or SubtractorcodesModule.
......@@ -22,7 +19,8 @@ class CodeTableSettings(QDialog):
Parameters
----------
code_table_base : soitool.modules.code_table_base.CodeTableBase
Is used to pre-select the modules default values.
Is used to fetch the modules default values, so that these are
pre-selected.
"""
def __init__(self, code_table_base):
......@@ -41,12 +39,8 @@ class CodeTableSettings(QDialog):
# Number of codes
self.label_no_of_codes = QLabel("Antall koder")
self.combo_no_of_codes = QComboBox()
if code_table_base.type == AUTHENTICATIONBOARD_MODULE:
for i in range(2, 27): # Maximum number is len(A-Z)
self.combo_no_of_codes.addItem(str(i))
else:
for i in range(2, 14): # Maximum number is len(A-Z) / 2
self.combo_no_of_codes.addItem(str(i))
for i in range(2, code_table_base.maximum_no_of_codes + 1):
self.combo_no_of_codes.addItem(str(i))
self.combo_no_of_codes.setCurrentIndex(
code_table_base.start_no_of_codes - 2
)
......@@ -70,7 +64,7 @@ class CodeTableSettings(QDialog):
# Space amount
self.label_space_amount = QLabel("Mellomrom per intervall")
self.combo_space_amount = QComboBox()
for i in range(0, 6):
for i in range(6):
self.combo_space_amount.addItem(str(i))
self.combo_space_amount.setCurrentIndex(code_table_base.space_amount)
......
......@@ -7,7 +7,12 @@ from PySide2.QtCore import Qt
from soitool.modules.module_base import resize_table
from soitool.modules.code_table_base import CodeTableBase
# Maximum number of codes is len(ROW_IDENTIFIERS)
# Characters for first column,
# it's length determines maximum number of codes (rows).
ROW_IDENTIFIERS = string.ascii_uppercase
# Maximum number of codes depends on ROW_IDENTIFIERS
MAXIMUM_NO_OF_CODES = len(ROW_IDENTIFIERS)
START_NO_OF_CODES = 10
CODE_LENGTH = 25
......@@ -18,9 +23,6 @@ CODE_CHARACTER_TYPE = "ascii"
# Font for authentication codes, should be a monospaced font
CODE_FONT = QtGui.QFont("Consolas", 10, QtGui.QFont.SansSerif)
# Characters for first column,
# it's length determines maximum number of codes (rows).
ROW_IDENTIFIERS = string.ascii_uppercase
# Adds space between sets of characters, 0 => no spaces
# If code is 123456 and interval is 2, code will be 12 34 56
......@@ -58,6 +60,12 @@ class AuthenticationBoardModule(CodeTableBase):
def __init__(self, size=None, data=None):
self.type = "AuthenticationBoardModule"
if START_NO_OF_CODES > MAXIMUM_NO_OF_CODES:
raise ValueError(
"Invalid value for CONSTANT 'START_NO_OF_CODES': "
"'{}'".format(START_NO_OF_CODES)
)
if CODE_CHARACTER_TYPE == "ascii":
self.code_characters = string.ascii_uppercase
elif CODE_CHARACTER_TYPE == "digits":
......@@ -70,6 +78,7 @@ class AuthenticationBoardModule(CodeTableBase):
"'{}'".format(CODE_CHARACTER_TYPE)
)
self.code_font = CODE_FONT
self.maximum_no_of_codes = MAXIMUM_NO_OF_CODES
# Set default values for table to be generated
if size is None and data is None:
......
......@@ -6,21 +6,23 @@ from PySide2.QtCore import Qt
from soitool.modules.module_base import resize_table
from soitool.modules.code_table_base import CodeTableBase
# Maximum number of codes is len(ROW_IDENTIFIERS)/2 columns = 13
START_NO_OF_CODES = 7
CODE_LENGTH = 8
# Font for subtractorcodes
CODE_FONT = QtGui.QFont("Arial", 10, QtGui.QFont.SansSerif)
# Characters for first and second column
ROW_IDENTIFIERS = string.ascii_uppercase
# Adds space between sets of characters, 0 => no spaces.
# Maximum number of codes is: number of row identifiers / 2 columns
# = 13 if identifiers are A-Z
MAXIMUM_NO_OF_CODES = len(ROW_IDENTIFIERS) // 2
START_NO_OF_CODES = 7
CODE_LENGTH = 8
# Adds space between sets of characters, 0 => no spaces
# If code is 12345678 and interval is 2, code will be 1234 5678
SPACE_INTERVAL = 4
SPACE_AMOUNT = 3
# Font for subtractorcodes
CODE_FONT = QtGui.QFont("Arial", 10, QtGui.QFont.SansSerif)
HEADLINE_TEXT = "Subtraktorkoder"
......@@ -48,13 +50,14 @@ class SubtractorcodesModule(CodeTableBase):
def __init__(self, size=None, data=None):
self.type = "SubtractorcodesModule"
if START_NO_OF_CODES > 13:
if START_NO_OF_CODES > MAXIMUM_NO_OF_CODES:
raise ValueError(
"Invalid value for CONSTANT 'START_NO_OF_CODES': "
"'{}'".format(START_NO_OF_CODES)
)
self.code_character_type = "digits"
self.code_font = CODE_FONT
self.maximum_no_of_codes = MAXIMUM_NO_OF_CODES
# Set default values for table to be generated
if size is None and data is None:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment