Implement Core Business Logic, Authorization, and Workflow State Management#1908
Implement Core Business Logic, Authorization, and Workflow State Management#1908Mohithreddy70 wants to merge 5 commits into
Conversation
…plication system - Implemented end-to-end tests for various workflows (submission, revision, budget approval, director assignment, fee payment, and external filing) in est_workflows.py. - Created a custom Django test runner in setup_tests.py that generates CSV reports for test execution, defect logs, and artifact evaluations. - Added scaffolding for YAML specifications to facilitate structured test design documentation. - Ensured proper directory structure and initialization for test modules.
Patent management v2
|
Congratulations for making your first Pull Request at Fusion!! 🎉 Someone from our team will review it soon. |
vikrantwiz02
left a comment
There was a problem hiding this comment.
Code Review — Patent Management System Core Logic (Backend)
The architecture is the strongest part: services/selectors split is clean, TextChoices for status, custom exceptions with HTTP codes, audit logging, and a real test suite with YAML specs and CSV reports are all well above the bar. The issues are concentrated in role resolution (fuzzy matching, single-designation lookup) and a dangerous test DB config in development.py. See inline comments.
| super().__init__(message, code=409) | ||
|
|
||
|
|
||
| # --------------------------------------------------------------------------- |
There was a problem hiding this comment.
_get_user_designation only checks the first designation — users with multiple roles will be misidentified. .first() returns an arbitrary single row. A user who holds both "Professor" and "PCC Admin" designations may have their PCC Admin role missed entirely, depending on query order. Check all designations:
def is_pcc_admin(user):
return HoldsDesignation.objects.filter(
user=user,
designation__name__icontains="PCC",
).exists()
def is_director(user):
return HoldsDesignation.objects.filter(
user=user,
designation__name__iexact="Director",
).exists()| # Role Helpers (BR-PMS-002) | ||
| # --------------------------------------------------------------------------- | ||
|
|
||
| def _get_user_designation(user): |
There was a problem hiding this comment.
Fuzzy role check: "PCC" in designation.upper() is too broad. Any designation whose name happens to contain the letters "PCC" (e.g. a hypothetical "DPCC Officer") would be granted PCC Admin access. Use an exact or prefix match:
return designation.strip().lower() == "pcc admin"| def is_director(user): | ||
| designation = _get_user_designation(user) | ||
| return designation and "director" in designation.lower() | ||
|
|
There was a problem hiding this comment.
BR-PMS-003 (COI) is only enforced for the Director — not for PCC Admin. _check_director_conflict prevents a Director who is an inventor from reviewing, but there is no equivalent guard for assert_pcc_admin operations. If a PCC Admin is also listed as an inventor, they can review, forward, and manage the application without any COI block. Add a _check_pcc_admin_conflict call in the PCC review service functions.
| @@ -0,0 +1,698 @@ | |||
| """ | |||
There was a problem hiding this comment.
Migration instructions in a module docstring. The file-level docstring includes cd FusionIIIT && python manage.py makemigrations ... and raw SQL. Docstrings appear in help(), IDEs, and generated docs — they are not the right place for deployment instructions. Move these to the PR description, a CONTRIBUTING.md, or a standalone migration file.
| 'ENGINE': 'django.db.backends.postgresql_psycopg2', | ||
| 'NAME': 'fusionlab', | ||
| 'HOST': os.environ.get("DB_HOST", default='localhost'), | ||
| 'PORT': '5433', |
There was a problem hiding this comment.
PORT: '5433' is a personal dev machine setting — the standard Postgres port is 5432. Committing a non-standard port breaks every other developer's local setup without any explanation. Remove this line; if your local Postgres runs on a different port, override it via an environment variable:
'PORT': os.environ.get('DB_PORT', '5432'),| ] | ||
|
|
||
| CRONTAB_DJANGO_MANAGE_PATH = '/home/owlman/Desktop/Fuse/Fusion/FusionIIIT/manage.py' No newline at end of file | ||
| CRONTAB_DJANGO_MANAGE_PATH = '/home/owlman/Desktop/Fuse/Fusion/FusionIIIT/manage.py' |
There was a problem hiding this comment.
DATABASES['default']['TEST'] = {'MIRROR': 'default'} is dangerous. The MIRROR key tells Django to run tests against the live default database instead of creating an isolated test database. Running manage.py test with this config will read from and potentially write to real data. Remove this block entirely — without MIRROR, Django creates a separate test_fusionlab database automatically.
|
|
||
| dependencies = [ | ||
| ('programme_curriculum', '0025_update_minority_values'), | ||
| ('academic_procedures', '0001_initial') |
There was a problem hiding this comment.
Unrelated migration in a different app modified by this PR. A new dependency ('academic_procedures', '0001_initial') is added to programme_curriculum's migration 0026, which originally had no such dependency. This is unrelated to the patent system. Any branch that lacks academic_procedures 0001_initial will now fail to migrate. Revert this change to programme_curriculum/migrations/0026_add_database_indexes.py — it should not be part of a patent module PR.
| @@ -0,0 +1,287 @@ | |||
| import os | |||
There was a problem hiding this comment.
Code-generation script committed to repo root. setup_tests.py is a script that writes the content of runner.py to disk. It should not be in the repo — runner.py is already committed directly. Remove this file.
Backend Implementation: Patent Management System (PMS) Core Logic
Description
This PR establishes the foundational backend architecture for the Patent Management System, focusing on enforcing business rules, securing data access, and managing complex application workflows.
Key Changes
PMS-WF-101), supporting transitions fromDrafttoSubmitted,Under Review, andApproved/Rejected/Needs Revision.BR-PMS-001to ensure all mandatory fields (title, abstract, claims, etc.) are present before submission.BR-PMS-004, ensuring applications are director-approved before attorney assignment.BR-PMS-008).BR-PMS-002) that restricts operations based on user roles such as Applicant, Director, orPCC_ADMIN.BR-PMS-006) to prevent applicants from editing documents unless the status is specifically 'Awaiting Revision'.BR-PMS-003).Testing