Moments before the disaster of adding EquipmentRoles
This commit is contained in:
1
TODO.md
1
TODO.md
@@ -1,3 +1,4 @@
|
||||
- [ ] Complete info_map in the SubmissionTypeCreator widget.
|
||||
- [ ] Update Artic and add in equipment listings... *sigh*.
|
||||
- [x] Fix WastewaterAssociations not in Session error.
|
||||
- Done... I think?
|
||||
|
||||
@@ -12,6 +12,7 @@ from typing import List
|
||||
from pandas import ExcelFile
|
||||
from pathlib import Path
|
||||
from . import Base, BaseClass, Organization
|
||||
from tools import Settings
|
||||
|
||||
logger = logging.getLogger(f'submissions.{__name__}')
|
||||
|
||||
@@ -671,7 +672,8 @@ class SubmissionType(BaseClass):
|
||||
pass
|
||||
return query_return(query=query, limit=limit)
|
||||
|
||||
def save(self):
|
||||
@check_authorization
|
||||
def save(self, ctx:Settings):
|
||||
"""
|
||||
Adds this instances to the database and commits.
|
||||
"""
|
||||
@@ -952,7 +954,8 @@ class SubmissionTypeEquipmentAssociation(BaseClass):
|
||||
raise ValueError(f'Invalid required value {value}. Must be 0 or 1.')
|
||||
return value
|
||||
|
||||
def save(self):
|
||||
@check_authorization
|
||||
def save(self, ctx:Settings):
|
||||
self.__database_session__.add(self)
|
||||
self.__database_session__.commit()
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ from .submission_table import SubmissionsSheet
|
||||
from .submission_widget import SubmissionFormContainer
|
||||
from .controls_chart import ControlsViewer
|
||||
from .kit_creator import KitAdder
|
||||
from .submission_type_creator import SubbmissionTypeAdder
|
||||
from .submission_type_creator import SubmissionTypeAdder
|
||||
|
||||
|
||||
logger = logging.getLogger(f'submissions.{__name__}')
|
||||
@@ -242,7 +242,7 @@ class AddSubForm(QWidget):
|
||||
self.tab2.layout.addWidget(self.controls_viewer)
|
||||
self.tab2.setLayout(self.tab2.layout)
|
||||
# create custom widget to add new tabs
|
||||
ST_adder = SubbmissionTypeAdder(self)
|
||||
ST_adder = SubmissionTypeAdder(self)
|
||||
self.tab3.layout = QVBoxLayout(self)
|
||||
self.tab3.layout.addWidget(ST_adder)
|
||||
self.tab3.setLayout(self.tab3.layout)
|
||||
|
||||
@@ -19,7 +19,7 @@ from .functions import select_open_file
|
||||
|
||||
logger = logging.getLogger(f"submissions.{__name__}")
|
||||
|
||||
class SubbmissionTypeAdder(QWidget):
|
||||
class SubmissionTypeAdder(QWidget):
|
||||
|
||||
def __init__(self, parent) -> None:
|
||||
super().__init__(parent)
|
||||
@@ -77,13 +77,16 @@ class SubbmissionTypeAdder(QWidget):
|
||||
def submit(self):
|
||||
info = self.parse_form()
|
||||
ST = SubmissionType(name=self.st_name.text(), info_map=info)
|
||||
try:
|
||||
with open(self.template_path, "rb") as f:
|
||||
ST.template_file = f.read()
|
||||
logger.debug(ST.__dict__)
|
||||
except FileNotFoundError:
|
||||
logger.error(f"Could not find template file: {self.template_path}")
|
||||
ST.save(ctx=self.app.ctx)
|
||||
|
||||
def parse_form(self):
|
||||
widgets = [widget for widget in self.findChildren(QWidget) if isinstance(widget, InfoWidget)]
|
||||
return [{widget.objectName():widget.parse_form()} for widget in widgets]
|
||||
return {widget.objectName():widget.parse_form() for widget in widgets}
|
||||
|
||||
def get_template_path(self):
|
||||
self.template_path = select_open_file(obj=self, file_extension="xlsx")
|
||||
|
||||
Reference in New Issue
Block a user