Added signing ability to submission details
This commit is contained in:
@@ -1,3 +1,8 @@
|
|||||||
|
## 202404.02
|
||||||
|
|
||||||
|
- Various bug fixes.
|
||||||
|
- Added ability to sign off on submission in submission details.
|
||||||
|
|
||||||
## 202403.03
|
## 202403.03
|
||||||
|
|
||||||
- Automated version construction.
|
- Automated version construction.
|
||||||
|
|||||||
@@ -138,20 +138,6 @@ class PydReagent(BaseModel):
|
|||||||
# NOTE: this will now be done only in the reporting phase to account for potential changes in end-of-life extensions
|
# NOTE: this will now be done only in the reporting phase to account for potential changes in end-of-life extensions
|
||||||
return reagent, report
|
return reagent, report
|
||||||
|
|
||||||
# def toForm(self, parent:QWidget, extraction_kit:str) -> QComboBox:
|
|
||||||
# """
|
|
||||||
# Converts this instance into a form widget
|
|
||||||
|
|
||||||
# Args:
|
|
||||||
# parent (QWidget): Parent widget of the constructed object
|
|
||||||
# extraction_kit (str): Name of extraction kit used
|
|
||||||
|
|
||||||
# Returns:
|
|
||||||
# QComboBox: Form object.
|
|
||||||
# """
|
|
||||||
# from frontend.widgets.submission_widget import ReagentFormWidget
|
|
||||||
# return ReagentFormWidget(parent=parent, reagent=self, extraction_kit=extraction_kit)
|
|
||||||
|
|
||||||
class PydSample(BaseModel, extra='allow'):
|
class PydSample(BaseModel, extra='allow'):
|
||||||
|
|
||||||
submitter_id: str
|
submitter_id: str
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ from PyQt6.QtWebChannel import QWebChannel
|
|||||||
from PyQt6.QtCore import Qt, pyqtSlot
|
from PyQt6.QtCore import Qt, pyqtSlot
|
||||||
|
|
||||||
from backend.db.models import BasicSubmission, BasicSample
|
from backend.db.models import BasicSubmission, BasicSample
|
||||||
from tools import check_if_app
|
from tools import check_if_app, check_authorization, is_power_user
|
||||||
from .functions import select_save_file
|
from .functions import select_save_file
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from tempfile import TemporaryFile, TemporaryDirectory
|
from tempfile import TemporaryFile, TemporaryDirectory
|
||||||
@@ -92,10 +92,18 @@ class SubmissionDetails(QDialog):
|
|||||||
logger.debug(f"Making platemap...")
|
logger.debug(f"Making platemap...")
|
||||||
self.base_dict['platemap'] = submission.make_plate_map()
|
self.base_dict['platemap'] = submission.make_plate_map()
|
||||||
self.base_dict, self.template = submission.get_details_template(base_dict=self.base_dict)
|
self.base_dict, self.template = submission.get_details_template(base_dict=self.base_dict)
|
||||||
self.html = self.template.render(sub=self.base_dict)
|
self.html = self.template.render(sub=self.base_dict, signing_permission=is_power_user())
|
||||||
self.webview.setHtml(self.html)
|
self.webview.setHtml(self.html)
|
||||||
self.setWindowTitle(f"Submission Details - {submission.rsl_plate_num}")
|
self.setWindowTitle(f"Submission Details - {submission.rsl_plate_num}")
|
||||||
|
|
||||||
|
@pyqtSlot(str)
|
||||||
|
def sign_off(self, submission:str|BasicSubmission):
|
||||||
|
logger.debug(f"Signing off on {submission}")
|
||||||
|
if isinstance(submission, str):
|
||||||
|
submission = BasicSubmission.query(rsl_number=submission)
|
||||||
|
submission.uploaded_by = getuser()
|
||||||
|
submission.save()
|
||||||
|
|
||||||
def export(self):
|
def export(self):
|
||||||
"""
|
"""
|
||||||
Renders submission to html, then creates and saves .pdf file to user selected file.
|
Renders submission to html, then creates and saves .pdf file to user selected file.
|
||||||
|
|||||||
@@ -116,6 +116,12 @@
|
|||||||
<img height="300px" width="650px" src="data:image/jpeg;base64,{{ sub['export_map'] | safe }}">
|
<img height="300px" width="650px" src="data:image/jpeg;base64,{{ sub['export_map'] | safe }}">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
{% if signing_permission %}
|
||||||
|
<button type="button" id="sign_btn">Sign Off</button>
|
||||||
|
{% endif %}
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
</body>
|
</body>
|
||||||
<script>
|
<script>
|
||||||
var backend;
|
var backend;
|
||||||
@@ -127,5 +133,8 @@
|
|||||||
backend.sample_details("{{ sample['Submitter ID'] }}");
|
backend.sample_details("{{ sample['Submitter ID'] }}");
|
||||||
});
|
});
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
document.getElementById("sign_btn").addEventListener("click", function(){
|
||||||
|
backend.sign_off("{{ sub['Plate Number'] }}");
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -537,6 +537,9 @@ def rreplace(s, old, new):
|
|||||||
|
|
||||||
ctx = get_config(None)
|
ctx = get_config(None)
|
||||||
|
|
||||||
|
def is_power_user() -> bool:
|
||||||
|
return getpass.getuser() in ctx.power_users
|
||||||
|
|
||||||
def check_authorization(func):
|
def check_authorization(func):
|
||||||
"""
|
"""
|
||||||
Decorator to check if user is authorized to access function
|
Decorator to check if user is authorized to access function
|
||||||
@@ -546,7 +549,7 @@ def check_authorization(func):
|
|||||||
"""
|
"""
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
logger.debug(f"Checking authorization")
|
logger.debug(f"Checking authorization")
|
||||||
if getpass.getuser() in ctx.power_users:
|
if is_power_user():
|
||||||
return func(*args, **kwargs)
|
return func(*args, **kwargs)
|
||||||
else:
|
else:
|
||||||
logger.error(f"User {getpass.getuser()} is not authorized for this function.")
|
logger.error(f"User {getpass.getuser()} is not authorized for this function.")
|
||||||
|
|||||||
Reference in New Issue
Block a user