Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/refactor-workflow' into test
Browse files Browse the repository at this point in the history
  • Loading branch information
frjo committed Jan 7, 2025
2 parents 60e779e + a60dad4 commit 2f9e94e
Show file tree
Hide file tree
Showing 43 changed files with 1,698 additions and 1,540 deletions.
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ JS_ESM_DIR = ./hypha/static_src/javascript/esm

# Check if uv is installed then use it, else fallback to pip
PIP := $(shell (command -v uv > /dev/null 2>&1 && echo "uv pip") || (command -v pip > /dev/null 2>&1 && echo "pip"))

UV_RUN := $(shell (command -v uv > /dev/null 2>&1 && echo "uv run ") || echo "")

.PHONY: help
help: ## Show this help menu with a list of available commands and their descriptions
Expand All @@ -16,29 +16,29 @@ help: ## Show this help menu with a list of available commands and their descrip
.PHONY: serve
serve: .cache/tandem .cache/py-packages .cache/dev-build-fe ## Run Django server, docs preview, and watch frontend changes
@.cache/tandem \
'python manage.py runserver_plus --settings=$(DJANGO_SETTINGS_MODULE)' \
'${UV_RUN}python manage.py runserver_plus --settings=$(DJANGO_SETTINGS_MODULE)' \
'npm:watch:*' \
'mkdocs serve'
'${UV_RUN}mkdocs serve'

.PHONY: test
test: lint py-test cov-html ## Run all tests (linting, Python tests) and generate coverage report


.PHONY: fmt
fmt: .cache/dev-build-fe ## Run code formatters on all code using pre-commit
@pre-commit run --all-files
${UV_RUN}pre-commit run --all-files


.PHONY: lint
lint: .cache/dev-build-fe ## Run all linters
@echo "Running linters"
@pre-commit run --all-files
${UV_RUN}pre-commit run --all-files


.PHONY: py-test
py-test: .cache/py-packages ## Run Python tests with pytest, including coverage report
@echo "Running python tests"
pytest --reuse-db --cov --cov-report term:skip-covered
${UV_RUN}pytest --reuse-db --cov --cov-report term:skip-covered

@echo "Removing test files generated during test"
@find media/ -iname 'test_*.pdf' -o -iname 'test_image*' -o -iname '*.dat' -delete
Expand All @@ -51,7 +51,7 @@ cov-html: ## Generate HTML coverage report from previous test run
ifneq ("$(wildcard .coverage)","")
@rm -rf htmlcov
@echo "Generate html coverage report…"
coverage html
${UV_RUN}coverage html
@echo "Open 'htmlcov/index.html' in your browser to see the report."
else
$(error Unable to generate html coverage report, please run 'make test' or 'make py-test')
Expand Down
2 changes: 1 addition & 1 deletion hypha/apply/activity/adapters/activity_feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from hypha.apply.activity.models import ALL, APPLICANT, TEAM
from hypha.apply.activity.options import MESSAGES
from hypha.apply.funds.workflow import PHASE_BG_COLORS
from hypha.apply.funds.workflows.constants import PHASE_BG_COLORS
from hypha.apply.projects.utils import (
get_invoice_public_status,
get_invoice_status_display_value,
Expand Down
2 changes: 1 addition & 1 deletion hypha/apply/activity/adapters/emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def extra_kwargs(self, message_type, source, sources, **kwargs):
}

def handle_transition(self, old_phase, source, **kwargs):
from hypha.apply.funds.workflow import PHASES
from hypha.apply.funds.workflows import PHASES

submission = source
# Retrieve status index to see if we are going forward or backward.
Expand Down
2 changes: 1 addition & 1 deletion hypha/apply/dashboard/views_partials.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.views.decorators.http import require_GET

from hypha.apply.funds.models.submissions import ApplicationSubmission
from hypha.apply.funds.workflow import active_statuses
from hypha.apply.funds.workflows import active_statuses
from hypha.apply.projects.models import Project


Expand Down
2 changes: 1 addition & 1 deletion hypha/apply/determinations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from wagtail.fields import RichTextField, StreamField

from hypha.apply.funds.models.mixins import AccessFormData
from hypha.apply.funds.workflow import Concept, Proposal, Request
from hypha.apply.funds.workflows.models.stage import Concept, Proposal, Request

from .blocks import (
DeterminationBlock,
Expand Down
2 changes: 1 addition & 1 deletion hypha/apply/determinations/options.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.utils.translation import gettext_lazy as _

from hypha.apply.funds.workflow import DETERMINATION_OUTCOMES
from hypha.apply.funds.workflows import DETERMINATION_OUTCOMES

REJECTED = 0
NEEDS_MORE_INFO = 1
Expand Down
3 changes: 2 additions & 1 deletion hypha/apply/determinations/permissions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .options import DETERMINATION_OUTCOMES
from hypha.apply.funds.workflows import DETERMINATION_OUTCOMES

from .utils import determination_actions, transition_from_outcome


Expand Down
3 changes: 2 additions & 1 deletion hypha/apply/determinations/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
from hypha.apply.activity.messaging import MESSAGES, messenger
from hypha.apply.activity.models import Activity
from hypha.apply.funds.models import ApplicationSubmission
from hypha.apply.funds.workflow import DETERMINATION_OUTCOMES, Concept
from hypha.apply.funds.workflows import DETERMINATION_OUTCOMES
from hypha.apply.funds.workflows.models.stage import Concept
from hypha.apply.projects.models import Project
from hypha.apply.review.models import Review
from hypha.apply.stream_forms.models import BaseStreamForm
Expand Down
2 changes: 1 addition & 1 deletion hypha/apply/funds/admin_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from wagtail.admin.forms import WagtailAdminModelForm, WagtailAdminPageForm

from .models.submissions import ApplicationSubmission
from .workflow import WORKFLOWS
from .workflows import WORKFLOWS


class WorkflowFormAdminForm(WagtailAdminPageForm):
Expand Down
2 changes: 1 addition & 1 deletion hypha/apply/funds/management/commands/drafts_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.utils import timezone

from hypha.apply.funds.models.submissions import ApplicationSubmission
from hypha.apply.funds.workflow import DRAFT_STATE
from hypha.apply.funds.workflows import DRAFT_STATE


def check_not_negative(value) -> int:
Expand Down
2 changes: 1 addition & 1 deletion hypha/apply/funds/management/commands/migration_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from hypha.apply.categories.models import Category, Option
from hypha.apply.funds.models import ApplicationSubmission, FundType, LabType, Round
from hypha.apply.funds.models.forms import LabBaseForm, RoundBaseForm
from hypha.apply.funds.workflow import INITIAL_STATE
from hypha.apply.funds.workflows import INITIAL_STATE


class MigrationStorage(S3Boto3Storage):
Expand Down
2 changes: 1 addition & 1 deletion hypha/apply/funds/models/applications.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

from ..admin_forms import RoundBasePageAdminForm, WorkflowFormAdminForm
from ..edit_handlers import ReadOnlyPanel
from ..workflow import OPEN_CALL_PHASES
from ..workflows.constants import OPEN_CALL_PHASES
from .submissions import ApplicationSubmission
from .utils import (
LIMIT_TO_REVIEWERS,
Expand Down
18 changes: 10 additions & 8 deletions hypha/apply/funds/models/submissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,9 @@
from hypha.apply.users.roles import APPLICANT_GROUP_NAME

from ..blocks import NAMED_BLOCKS, ApplicationCustomFormFieldsBlock
from ..workflow import (
COMMUNITY_REVIEW_PHASES,
DETERMINATION_RESPONSE_PHASES,
DRAFT_STATE,
INITIAL_STATE,
from ..workflows import (
PHASES,
PHASES_MAPPING,
STAGE_CHANGE_ACTIONS,
WORKFLOWS,
UserPermissions,
accepted_statuses,
active_statuses,
dismissed_statuses,
Expand All @@ -69,6 +62,15 @@
get_review_active_statuses,
review_statuses,
)
from ..workflows.constants import (
COMMUNITY_REVIEW_PHASES,
DETERMINATION_RESPONSE_PHASES,
DRAFT_STATE,
INITIAL_STATE,
PHASES_MAPPING,
STAGE_CHANGE_ACTIONS,
UserPermissions,
)
from .mixins import AccessFormData
from .reviewer_role import ReviewerRole
from .utils import (
Expand Down
2 changes: 1 addition & 1 deletion hypha/apply/funds/models/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
STAFF_GROUP_NAME,
)

from ..workflow import DRAFT_STATE, WORKFLOWS
from ..workflows import DRAFT_STATE, WORKFLOWS

REVIEW_GROUPS = [
STAFF_GROUP_NAME,
Expand Down
2 changes: 1 addition & 1 deletion hypha/apply/funds/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from hypha.apply.activity.messaging import MESSAGES, messenger
from hypha.apply.activity.models import Activity, Event
from hypha.apply.funds.models.assigned_reviewers import AssignedReviewers
from hypha.apply.funds.workflow import INITIAL_STATE
from hypha.apply.funds.workflows import INITIAL_STATE
from hypha.apply.review.options import DISAGREE, MAYBE


Expand Down
2 changes: 1 addition & 1 deletion hypha/apply/funds/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

from .models import ApplicationSubmission, Round, ScreeningStatus
from .widgets import Select2MultiCheckboxesWidget
from .workflow import STATUSES, get_review_active_statuses
from .workflows import STATUSES, get_review_active_statuses

User = get_user_model()

Expand Down
6 changes: 5 additions & 1 deletion hypha/apply/funds/tests/factories/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@
RoundBaseForm,
RoundBaseReviewForm,
)
from hypha.apply.funds.workflow import ConceptProposal, Request, RequestExternal
from hypha.apply.funds.workflows.registry import (
ConceptProposal,
Request,
RequestExternal,
)
from hypha.apply.stream_forms.testing.factories import FormDataFactory
from hypha.apply.users.roles import REVIEWER_GROUP_NAME, STAFF_GROUP_NAME
from hypha.apply.users.tests.factories import (
Expand Down
3 changes: 2 additions & 1 deletion hypha/apply/funds/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

from hypha.apply.funds.blocks import EmailBlock, FullNameBlock
from hypha.apply.funds.models import ApplicationSubmission, AssignedReviewers, Reminder
from hypha.apply.funds.workflow import DRAFT_STATE, Request
from hypha.apply.funds.workflows.constants import DRAFT_STATE
from hypha.apply.funds.workflows.registry import Request
from hypha.apply.review.options import AGREE, MAYBE, NO
from hypha.apply.review.tests.factories import ReviewFactory, ReviewOpinionFactory
from hypha.apply.users.tests.factories import StaffFactory
Expand Down
2 changes: 1 addition & 1 deletion hypha/apply/funds/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
SealedSubmissionFactory,
)
from hypha.apply.funds.views.submission_detail import SubmissionDetailView
from hypha.apply.funds.workflow import INITIAL_STATE
from hypha.apply.funds.workflows import INITIAL_STATE
from hypha.apply.projects.models import Project
from hypha.apply.projects.tests.factories import ProjectFactory
from hypha.apply.review.tests.factories import ReviewFactory
Expand Down
2 changes: 1 addition & 1 deletion hypha/apply/funds/tests/views/test_submission_delete.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.urls import reverse

from hypha.apply.funds.tests.factories.models import ApplicationSubmissionFactory
from hypha.apply.funds.workflow import DRAFT_STATE
from hypha.apply.funds.workflows import DRAFT_STATE
from hypha.apply.users.tests.factories import AdminFactory, ApplicantFactory


Expand Down
2 changes: 1 addition & 1 deletion hypha/apply/funds/views/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from hypha.apply.determinations.views import BatchDeterminationCreateView
from hypha.apply.funds.models.screening import ScreeningStatus
from hypha.apply.funds.utils import export_submissions_to_csv
from hypha.apply.funds.workflow import PHASES, get_action_mapping, review_statuses
from hypha.apply.funds.workflows import PHASES, get_action_mapping, review_statuses
from hypha.apply.search.filters import apply_date_filter
from hypha.apply.search.query_parser import parse_search_query
from hypha.apply.users.decorators import (
Expand Down
2 changes: 1 addition & 1 deletion hypha/apply/funds/views/partials.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
get_statuses_as_params,
status_and_phases_mapping,
)
from ..workflow import PHASES_MAPPING
from ..workflows.constants import PHASES_MAPPING

User = get_user_model()

Expand Down
2 changes: 1 addition & 1 deletion hypha/apply/funds/views/staff_assignments.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
ReviewerRole,
)
from ..tables import StaffAssignmentsTable
from ..workflow import active_statuses
from ..workflows import active_statuses

User = get_user_model()

Expand Down
2 changes: 1 addition & 1 deletion hypha/apply/funds/views/submission_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from hypha.apply.activity.models import Event

from ..models import ApplicationSubmission
from ..workflow import DRAFT_STATE
from ..workflows.constants import DRAFT_STATE


class SubmissionDeleteView(LoginRequiredMixin, UserPassesTestMixin, DeleteView):
Expand Down
2 changes: 1 addition & 1 deletion hypha/apply/funds/views/submission_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
get_archive_view_groups,
has_permission,
)
from ..workflow import DRAFT_STATE
from ..workflows import DRAFT_STATE

if settings.APPLICATION_TRANSLATIONS_ENABLED:
from hypha.apply.translate.utils import (
Expand Down
2 changes: 1 addition & 1 deletion hypha/apply/funds/views/submission_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
from ..permissions import (
has_permission,
)
from ..workflow import (
from ..workflows.constants import (
DRAFT_STATE,
STAGE_CHANGE_ACTIONS,
)
Expand Down
Loading

0 comments on commit 2f9e94e

Please sign in to comment.