Skip to content

Commit

Permalink
Merge branch 'release/0.1.3' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvw committed Jul 2, 2024
2 parents 6f8d9e7 + cd0ae6a commit 0e1b3f8
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repos:
rev: 24.4.2
hooks:
- id: black
language_version: python3.11
language_version: python3.12

- repo: https://github.com/pycqa/flake8
rev: 7.1.0
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ To use ``QaReportNote`` with your QA report, declare the QA Report admin class w
from django.contrib import admin
from edc_model_admin.dashboard import ModelAdminDashboardMixin
from edc_model_admin.mixins import TemplatesModelAdminMixin
from edc_qareports.admin import ReportWithNoteModelAdminMixin
from edc_qareports.admin import QaReportWithNoteModelAdminMixin
from edc_sites.admin import SiteModelAdminMixin
from edc_visit_schedule.admin import ScheduleStatusListFilter
Expand All @@ -173,7 +173,7 @@ To use ``QaReportNote`` with your QA report, declare the QA Report admin class w
@admin.register(MyViewInSql, site=meta_reports_admin)
class MyViewInSqlAdmin(
ReportWithNoteModelAdminMixin,
QaReportWithNoteModelAdminMixin,
SiteModelAdminMixin,
ModelAdminDashboardMixin,
TemplatesModelAdminMixin,
Expand Down
5 changes: 3 additions & 2 deletions edc_qareports/admin/qa_report_with_note_modeladmin_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class QaReportWithNoteModelAdminMixin:
"""

qa_report_log_enabled = True
qa_report_list_display_insert_pos = 3

def update_qa_report_log(self, request) -> None:
QaReportLog.objects.create(
Expand All @@ -32,8 +33,8 @@ def changelist_view(self, request, extra_context=None):
def get_list_display(self, request):
list_display = super().get_list_display(request)
list_display = list(list_display)
list_display.insert(3, "notes")
list_display.insert(3, "status")
list_display.insert(self.qa_report_list_display_insert_pos, "notes")
list_display.insert(self.qa_report_list_display_insert_pos, "status")
return tuple(list_display)

def get_list_filter(self, request):
Expand Down
2 changes: 2 additions & 0 deletions edc_qareports/auth_objects.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# group names
QA_REPORTS = "QA_REPORTS"
QA_REPORTS_AUDIT = "QA_REPORTS_AUDIT"

# role names
QA_REPORTS_ROLE = "qa_reports_role"
QA_REPORTS_AUDIT_ROLE = "qa_reports_audit_role"

qa_reports_codenames = [
"edc_qareports.add_qareportnote",
Expand Down
4 changes: 4 additions & 0 deletions edc_qareports/auths.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from .auth_objects import (
QA_REPORTS,
QA_REPORTS_AUDIT,
QA_REPORTS_AUDIT_ROLE,
QA_REPORTS_ROLE,
custom_codename_tuples,
qa_reports_codenames,
Expand All @@ -14,7 +16,9 @@

# groups
site_auths.add_group(*qa_reports_codenames, name=QA_REPORTS)
site_auths.add_group(*qa_reports_codenames, name=QA_REPORTS_AUDIT, view_only=True)


# roles
site_auths.add_role(QA_REPORTS, name=QA_REPORTS_ROLE)
site_auths.add_role(QA_REPORTS_AUDIT, name=QA_REPORTS_AUDIT_ROLE)
1 change: 1 addition & 0 deletions edc_qareports/forms/qa_report_note_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Meta:
fields = "__all__"
help_text = {"subject_identifier": "(read-only)", "name": "(read-only)"}
widgets = {
"report_model": forms.TextInput(attrs={"readonly": "readonly"}),
"subject_identifier": forms.TextInput(attrs={"readonly": "readonly"}),
"name": forms.TextInput(attrs={"readonly": "readonly"}),
}
15 changes: 13 additions & 2 deletions edc_qareports/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ def read_unmanaged_model_sql(
) -> str:
if not fullpath:
fullpath = Path(settings.BASE_DIR) / app_name / "models" / "unmanaged" / filename
else:
fullpath = Path(fullpath)

parsed_sql = []
with fullpath.open("r") as f:
sql = f.read()
return sql.replace("\n", " ")
for line in f:
line = line.split("#", maxsplit=1)[0]
line = line.split("-- ", maxsplit=1)[0]
line = line.replace("\n", "")
line = line.strip()
if line:
parsed_sql.append(line)

return " ".join(parsed_sql)
8 changes: 3 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ version_file="_version.py"

[tool.black]
line-length = 95
target-version = ["py311"]
target-version = ["py312"]
extend-exclude = '''^(.*\/)*\b(migrations)\b($|\/.*$)'''

[tool.isort]
profile = "black"
py_version = "311"
py_version = "312"
skip = [".tox", ".eggs", "migrations"]

[tool.coverage.run]
Expand All @@ -35,15 +35,13 @@ exclude_lines = [
legacy_tox_ini = """
[tox]
envlist =
py{311}-dj{42,50},
py{312}-dj{50,dev},
py{312}-dj{42,50,dev},
lint
isolated_build = true
[gh-actions]
python =
3.11: py311
3.12: py312, lint
[gh-actions:env]
Expand Down

0 comments on commit 0e1b3f8

Please sign in to comment.