diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e0e9ba2b9c..ce5749ff56 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -35,6 +35,16 @@ repos: "requirements/translate.txt", ] + - repo: https://github.com/asottile/pyupgrade + rev: v3.21.2 + hooks: + - id: pyupgrade + + - repo: https://github.com/adamchainz/django-upgrade + rev: "1.32.0" + hooks: + - id: django-upgrade + - repo: https://github.com/astral-sh/ruff-pre-commit rev: "v0.15.11" hooks: @@ -76,6 +86,7 @@ repos: additional_dependencies: - stylelint@16.26.1 - stylelint-config-standard-scss@13.1.0 + - repo: https://github.com/gitleaks/gitleaks rev: v8.30.0 hooks: diff --git a/docs/scripts/doc_macros.py b/docs/scripts/doc_macros.py index 70ef3719a1..0ddc99b097 100644 --- a/docs/scripts/doc_macros.py +++ b/docs/scripts/doc_macros.py @@ -52,7 +52,7 @@ def get_python_version() -> str: version: str try: - with open(PYTHON_VERSION_FILE, "r") as py_ver: + with open(PYTHON_VERSION_FILE) as py_ver: version = py_ver.read() if not valid_semver(version): @@ -74,7 +74,7 @@ def get_node_version() -> str: version: str try: - with open(NVM_VERSION_FILE, "r") as nvm_ver: + with open(NVM_VERSION_FILE) as nvm_ver: version = nvm_ver.read() # Node version is usually in the format of "vX.X.X" diff --git a/hypha/apply/activity/admin.py b/hypha/apply/activity/admin.py index eba7b0ff8a..d3f10619c4 100644 --- a/hypha/apply/activity/admin.py +++ b/hypha/apply/activity/admin.py @@ -12,6 +12,7 @@ def has_add_permission(self, request, obj): return False +@admin.register(Event) class EventAdmin(admin.ModelAdmin): list_display = ("type", "by", "when", "source") list_filter = ("type", "when") @@ -23,6 +24,3 @@ def has_add_permission(self, request): def has_delete_permission(self, *args): return False - - -admin.site.register(Event, EventAdmin) diff --git a/hypha/apply/activity/migrations/0001_initial.py b/hypha/apply/activity/migrations/0001_initial.py index 43dd338bb2..e137bd0666 100644 --- a/hypha/apply/activity/migrations/0001_initial.py +++ b/hypha/apply/activity/migrations/0001_initial.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.8 on 2018-02-28 11:03 -from __future__ import unicode_literals from django.conf import settings from django.db import migrations, models diff --git a/hypha/apply/activity/migrations/0002_activity_type.py b/hypha/apply/activity/migrations/0002_activity_type.py index 482a3550cd..ca2d63bc61 100644 --- a/hypha/apply/activity/migrations/0002_activity_type.py +++ b/hypha/apply/activity/migrations/0002_activity_type.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.8 on 2018-03-01 15:49 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/hypha/apply/activity/migrations/0003_activity_visibility.py b/hypha/apply/activity/migrations/0003_activity_visibility.py index 8f948615e4..9f7bd0c82f 100644 --- a/hypha/apply/activity/migrations/0003_activity_visibility.py +++ b/hypha/apply/activity/migrations/0003_activity_visibility.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.8 on 2018-03-06 11:52 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/hypha/apply/activity/tests/test_messaging.py b/hypha/apply/activity/tests/test_messaging.py index 5bec4db92f..a28acd9ede 100644 --- a/hypha/apply/activity/tests/test_messaging.py +++ b/hypha/apply/activity/tests/test_messaging.py @@ -749,7 +749,7 @@ def test_activity_lead_change_from_none(self): ) self.assertEqual(Activity.objects.count(), 1) activity = Activity.objects.first() - self.assertIn(str("Unassigned"), activity.message) + self.assertIn("Unassigned", activity.message) self.assertIn(str(project.lead), activity.message) def test_activity_created(self): diff --git a/hypha/apply/categories/migrations/0001_initial.py b/hypha/apply/categories/migrations/0001_initial.py index da244f34fc..f23df40b1b 100644 --- a/hypha/apply/categories/migrations/0001_initial.py +++ b/hypha/apply/categories/migrations/0001_initial.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.8 on 2018-01-09 17:52 -from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion diff --git a/hypha/apply/funds/admin_views.py b/hypha/apply/funds/admin_views.py index c110f7aae8..85f692c5f4 100644 --- a/hypha/apply/funds/admin_views.py +++ b/hypha/apply/funds/admin_views.py @@ -65,10 +65,8 @@ def custom_admin_round_copy_view(request, page): messages.info( request, _( - ( - "Please select the date in the copied page. " - "Newly copied pages have NONE value for the start and end date" - ) + "Please select the date in the copied page. " + "Newly copied pages have NONE value for the start and end date" ), ) diff --git a/hypha/apply/funds/migrations/0001_initial.py b/hypha/apply/funds/migrations/0001_initial.py index 392a586312..fa1d1c7e57 100644 --- a/hypha/apply/funds/migrations/0001_initial.py +++ b/hypha/apply/funds/migrations/0001_initial.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.7 on 2017-12-22 09:28 -from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion diff --git a/hypha/apply/funds/migrations/0002_fundpage_workflow.py b/hypha/apply/funds/migrations/0002_fundpage_workflow.py index fa8c2b309f..0a35a592bb 100644 --- a/hypha/apply/funds/migrations/0002_fundpage_workflow.py +++ b/hypha/apply/funds/migrations/0002_fundpage_workflow.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.7 on 2017-12-22 10:12 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/hypha/apply/funds/migrations/0003_applicationform_category_fundpageform_option.py b/hypha/apply/funds/migrations/0003_applicationform_category_fundpageform_option.py index 3fddd57096..776b5fe6de 100644 --- a/hypha/apply/funds/migrations/0003_applicationform_category_fundpageform_option.py +++ b/hypha/apply/funds/migrations/0003_applicationform_category_fundpageform_option.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.7 on 2018-01-04 11:42 -from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion diff --git a/hypha/apply/funds/migrations/0004_categoryblock_add_required_option.py b/hypha/apply/funds/migrations/0004_categoryblock_add_required_option.py index ae330c77d5..31620efdae 100644 --- a/hypha/apply/funds/migrations/0004_categoryblock_add_required_option.py +++ b/hypha/apply/funds/migrations/0004_categoryblock_add_required_option.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.8 on 2018-01-17 11:54 -from __future__ import unicode_literals from django.db import migrations import hypha.apply.categories.blocks diff --git a/hypha/apply/funds/migrations/0005_applicationsubmission.py b/hypha/apply/funds/migrations/0005_applicationsubmission.py index 41e5de12ac..d646b8ae8d 100644 --- a/hypha/apply/funds/migrations/0005_applicationsubmission.py +++ b/hypha/apply/funds/migrations/0005_applicationsubmission.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.8 on 2018-01-22 09:40 -from __future__ import unicode_literals import django.contrib.postgres.fields.jsonb from django.db import migrations, models diff --git a/hypha/apply/funds/migrations/0006_update_block_definitions.py b/hypha/apply/funds/migrations/0006_update_block_definitions.py index 1facaa93ba..1fb6ae2175 100644 --- a/hypha/apply/funds/migrations/0006_update_block_definitions.py +++ b/hypha/apply/funds/migrations/0006_update_block_definitions.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.8 on 2018-01-23 15:18 -from __future__ import unicode_literals from django.db import migrations import hypha.apply.categories.blocks diff --git a/hypha/apply/funds/migrations/0007_round.py b/hypha/apply/funds/migrations/0007_round.py index 9d3347bc80..9b9d5511d8 100644 --- a/hypha/apply/funds/migrations/0007_round.py +++ b/hypha/apply/funds/migrations/0007_round.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.8 on 2018-01-18 15:59 -from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion diff --git a/hypha/apply/funds/migrations/0008_add_date_to_round.py b/hypha/apply/funds/migrations/0008_add_date_to_round.py index 03cd677aa0..3f9fc7ccf8 100644 --- a/hypha/apply/funds/migrations/0008_add_date_to_round.py +++ b/hypha/apply/funds/migrations/0008_add_date_to_round.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.8 on 2018-01-18 16:24 -from __future__ import unicode_literals import datetime from django.db import migrations, models diff --git a/hypha/apply/funds/migrations/0009_update_date_fields.py b/hypha/apply/funds/migrations/0009_update_date_fields.py index 38177f0c9e..e4aa6e5194 100644 --- a/hypha/apply/funds/migrations/0009_update_date_fields.py +++ b/hypha/apply/funds/migrations/0009_update_date_fields.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.8 on 2018-01-19 11:30 -from __future__ import unicode_literals import datetime from django.db import migrations, models diff --git a/hypha/apply/funds/migrations/0010_update_for_rich_text_block.py b/hypha/apply/funds/migrations/0010_update_for_rich_text_block.py index 8a685aad8e..ee6e418257 100644 --- a/hypha/apply/funds/migrations/0010_update_for_rich_text_block.py +++ b/hypha/apply/funds/migrations/0010_update_for_rich_text_block.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.8 on 2018-01-24 15:00 -from __future__ import unicode_literals from django.db import migrations import hypha.apply.categories.blocks diff --git a/hypha/apply/funds/migrations/0011_update_encoder_add_round_to_submission.py b/hypha/apply/funds/migrations/0011_update_encoder_add_round_to_submission.py index cc6657f2f4..ef2652bb44 100644 --- a/hypha/apply/funds/migrations/0011_update_encoder_add_round_to_submission.py +++ b/hypha/apply/funds/migrations/0011_update_encoder_add_round_to_submission.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.8 on 2018-01-24 22:09 -from __future__ import unicode_literals import django.contrib.postgres.fields.jsonb import django.core.serializers.json diff --git a/hypha/apply/funds/migrations/0012_create_lab_models.py b/hypha/apply/funds/migrations/0012_create_lab_models.py index 0c26c8a496..788952f735 100644 --- a/hypha/apply/funds/migrations/0012_create_lab_models.py +++ b/hypha/apply/funds/migrations/0012_create_lab_models.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.8 on 2018-01-25 12:09 -from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion diff --git a/hypha/apply/funds/migrations/0013_allow_nullable_round_on_submission.py b/hypha/apply/funds/migrations/0013_allow_nullable_round_on_submission.py index 17e838928b..cb996518c5 100644 --- a/hypha/apply/funds/migrations/0013_allow_nullable_round_on_submission.py +++ b/hypha/apply/funds/migrations/0013_allow_nullable_round_on_submission.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.8 on 2018-01-25 12:28 -from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion diff --git a/hypha/apply/funds/migrations/0014_add_meta_names.py b/hypha/apply/funds/migrations/0014_add_meta_names.py index cd42551eea..e91fcd84e7 100644 --- a/hypha/apply/funds/migrations/0014_add_meta_names.py +++ b/hypha/apply/funds/migrations/0014_add_meta_names.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.8 on 2018-01-25 13:08 -from __future__ import unicode_literals from django.db import migrations diff --git a/hypha/apply/funds/migrations/0015_link_user_to_application.py b/hypha/apply/funds/migrations/0015_link_user_to_application.py index e0d879ef3c..e934da601e 100644 --- a/hypha/apply/funds/migrations/0015_link_user_to_application.py +++ b/hypha/apply/funds/migrations/0015_link_user_to_application.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.8 on 2018-02-01 16:45 -from __future__ import unicode_literals from django.conf import settings from django.db import migrations, models diff --git a/hypha/apply/funds/migrations/0016_roundform.py b/hypha/apply/funds/migrations/0016_roundform.py index 51e7502667..0dbee8f90c 100644 --- a/hypha/apply/funds/migrations/0016_roundform.py +++ b/hypha/apply/funds/migrations/0016_roundform.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.8 on 2018-02-07 11:48 -from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion diff --git a/hypha/apply/funds/migrations/0017_round_workflow.py b/hypha/apply/funds/migrations/0017_round_workflow.py index 5b7e7e24d6..a550ebbaea 100644 --- a/hypha/apply/funds/migrations/0017_round_workflow.py +++ b/hypha/apply/funds/migrations/0017_round_workflow.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.8 on 2018-02-08 07:58 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/hypha/apply/funds/migrations/0018_add_addressfield.py b/hypha/apply/funds/migrations/0018_add_addressfield.py index e1c2c00b52..6cf52b8a4d 100644 --- a/hypha/apply/funds/migrations/0018_add_addressfield.py +++ b/hypha/apply/funds/migrations/0018_add_addressfield.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.8 on 2018-02-05 11:53 -from __future__ import unicode_literals from django.db import migrations import hypha.apply.categories.blocks diff --git a/hypha/apply/funds/migrations/0019_protect_submission.py b/hypha/apply/funds/migrations/0019_protect_submission.py index 8d48b23c01..81214000e2 100644 --- a/hypha/apply/funds/migrations/0019_protect_submission.py +++ b/hypha/apply/funds/migrations/0019_protect_submission.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.8 on 2018-02-08 15:52 -from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion diff --git a/hypha/apply/funds/migrations/0020_add_workflow_and_status_to_submission.py b/hypha/apply/funds/migrations/0020_add_workflow_and_status_to_submission.py index e6fc14c782..4758b1a201 100644 --- a/hypha/apply/funds/migrations/0020_add_workflow_and_status_to_submission.py +++ b/hypha/apply/funds/migrations/0020_add_workflow_and_status_to_submission.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.8 on 2018-02-14 11:29 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/hypha/apply/funds/migrations/0021_rename_workflow_field.py b/hypha/apply/funds/migrations/0021_rename_workflow_field.py index b24682ab7b..9771e47bfd 100644 --- a/hypha/apply/funds/migrations/0021_rename_workflow_field.py +++ b/hypha/apply/funds/migrations/0021_rename_workflow_field.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.8 on 2018-02-14 11:41 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/hypha/apply/funds/migrations/0022_applicationsubmission_form_fields.py b/hypha/apply/funds/migrations/0022_applicationsubmission_form_fields.py index c7b3429881..936715db74 100644 --- a/hypha/apply/funds/migrations/0022_applicationsubmission_form_fields.py +++ b/hypha/apply/funds/migrations/0022_applicationsubmission_form_fields.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.8 on 2018-02-13 15:10 -from __future__ import unicode_literals from django.db import migrations import hypha.apply.categories.blocks diff --git a/hypha/apply/funds/migrations/0023_round_lead.py b/hypha/apply/funds/migrations/0023_round_lead.py index 4ae2cde0b3..8819c728b0 100644 --- a/hypha/apply/funds/migrations/0023_round_lead.py +++ b/hypha/apply/funds/migrations/0023_round_lead.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.8 on 2018-02-14 17:21 -from __future__ import unicode_literals from django.conf import settings from django.db import migrations, models diff --git a/hypha/apply/funds/migrations/0024_applicationsubmission_search_data.py b/hypha/apply/funds/migrations/0024_applicationsubmission_search_data.py index 1cfb3a6121..8cffa721dd 100644 --- a/hypha/apply/funds/migrations/0024_applicationsubmission_search_data.py +++ b/hypha/apply/funds/migrations/0024_applicationsubmission_search_data.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.8 on 2018-02-16 16:29 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/hypha/apply/funds/migrations/0025_update_with_file_blocks.py b/hypha/apply/funds/migrations/0025_update_with_file_blocks.py index 41dcbc945d..8d168500ad 100644 --- a/hypha/apply/funds/migrations/0025_update_with_file_blocks.py +++ b/hypha/apply/funds/migrations/0025_update_with_file_blocks.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.8 on 2018-02-21 15:14 -from __future__ import unicode_literals from django.db import migrations import hypha.apply.categories.blocks diff --git a/hypha/apply/funds/migrations/0026_add_leads_to_submission_and_lab.py b/hypha/apply/funds/migrations/0026_add_leads_to_submission_and_lab.py index fa727a7f55..ae3eca7e33 100644 --- a/hypha/apply/funds/migrations/0026_add_leads_to_submission_and_lab.py +++ b/hypha/apply/funds/migrations/0026_add_leads_to_submission_and_lab.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.8 on 2018-03-02 17:08 -from __future__ import unicode_literals from django.conf import settings from django.db import migrations, models diff --git a/hypha/apply/funds/migrations/0027_applicationsubmission_drupal_id.py b/hypha/apply/funds/migrations/0027_applicationsubmission_drupal_id.py index 80df4764ea..a56abf55d1 100644 --- a/hypha/apply/funds/migrations/0027_applicationsubmission_drupal_id.py +++ b/hypha/apply/funds/migrations/0027_applicationsubmission_drupal_id.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.8 on 2018-03-08 11:02 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/hypha/apply/funds/models/applications.py b/hypha/apply/funds/models/applications.py index 6127d409ac..1f9c4971e4 100644 --- a/hypha/apply/funds/models/applications.py +++ b/hypha/apply/funds/models/applications.py @@ -200,7 +200,7 @@ def serve(self, request): # Manually do what the login_required decorator does so that we can check settings if not request.user.is_authenticated and settings.FORCE_LOGIN_FOR_APPLICATION: return redirect( - "%s?next=%s" % (settings.WAGTAIL_FRONTEND_LOGIN_URL, request.path) + "{}?next={}".format(settings.WAGTAIL_FRONTEND_LOGIN_URL, request.path) ) if hasattr(request, "is_preview") or not self.open_round: @@ -739,7 +739,7 @@ def serve(self, request, *args, **kwargs): # Manually do what the login_required decorator does so that we can check settings if not request.user.is_authenticated and settings.FORCE_LOGIN_FOR_APPLICATION: return redirect( - "%s?next=%s" % (settings.WAGTAIL_FRONTEND_LOGIN_URL, request.path) + "{}?next={}".format(settings.WAGTAIL_FRONTEND_LOGIN_URL, request.path) ) if request.method == "POST": diff --git a/hypha/apply/funds/models/co_applicants.py b/hypha/apply/funds/models/co_applicants.py index 504e2eac81..66f5353b79 100644 --- a/hypha/apply/funds/models/co_applicants.py +++ b/hypha/apply/funds/models/co_applicants.py @@ -42,11 +42,11 @@ class CoApplicantInvite(models.Model): status = models.CharField( _("status"), max_length=20, - choices=CoApplicantInviteStatus.choices, + choices=CoApplicantInviteStatus, default=CoApplicantInviteStatus.PENDING, ) role = models.CharField( - _("role"), choices=CoApplicantRole.choices, default=CoApplicantRole.VIEW + _("role"), choices=CoApplicantRole, default=CoApplicantRole.VIEW ) project_permission = models.JSONField(blank=True, null=True, default=list) responded_on = models.DateTimeField(blank=True, null=True) @@ -80,7 +80,7 @@ class CoApplicant(models.Model): CoApplicantInvite, on_delete=models.CASCADE, related_name="co_applicant" ) role = models.CharField( - _("role"), choices=CoApplicantRole.choices, default=CoApplicantRole.VIEW + _("role"), choices=CoApplicantRole, default=CoApplicantRole.VIEW ) project_permission = models.JSONField(blank=True, null=True, default=list) created_at = models.DateTimeField(auto_now_add=True, null=True) diff --git a/hypha/apply/funds/tables.py b/hypha/apply/funds/tables.py index 4320ab2beb..1118a22e1a 100644 --- a/hypha/apply/funds/tables.py +++ b/hypha/apply/funds/tables.py @@ -115,9 +115,7 @@ def order_last_update(self, qs, desc): return qs, True def get_column_class_names(self, classes_set, bound_column): - classes_set = super(SubmissionsTable, self).get_column_class_names( - classes_set, bound_column - ) + classes_set = super().get_column_class_names(classes_set, bound_column) classes_set.add(bound_column.name) return classes_set @@ -445,9 +443,7 @@ def order_progress(self, qs, desc): return qs.order_by(self._field_order("progress", desc)), True def get_column_class_names(self, classes_set, bound_column): - classes_set = super(RoundsTable, self).get_column_class_names( - classes_set, bound_column - ) + classes_set = super().get_column_class_names(classes_set, bound_column) classes_set.add(bound_column.name) return classes_set diff --git a/hypha/apply/funds/views/co_applicants.py b/hypha/apply/funds/views/co_applicants.py index 960464f8eb..3538b15966 100644 --- a/hypha/apply/funds/views/co_applicants.py +++ b/hypha/apply/funds/views/co_applicants.py @@ -43,7 +43,7 @@ def dispatch(self, request, *args, **kwargs): if not permission: messages.warning(self.request, reason) return HttpResponseRedirect(self.submission.get_absolute_url()) - return super(CoApplicantInviteView, self).dispatch(request, *args, **kwargs) + return super().dispatch(request, *args, **kwargs) def get(self, *args, **kwargs): invite_form = InviteCoApplicantForm( @@ -211,7 +211,7 @@ def dispatch(self, request, *args, **kwargs): object=self.invite, raise_exception=True, ) - return super(EditCoApplicantView, self).dispatch(request, *args, **kwargs) + return super().dispatch(request, *args, **kwargs) def get(self, request, *args, **kwargs): if self.invite.status == CoApplicantInviteStatus.ACCEPTED: diff --git a/hypha/apply/funds/views/reminders.py b/hypha/apply/funds/views/reminders.py index 2904b9d6ec..810b6c0b71 100644 --- a/hypha/apply/funds/views/reminders.py +++ b/hypha/apply/funds/views/reminders.py @@ -57,7 +57,7 @@ def dispatch(self, request, *args, **kwargs): if not permission: messages.warning(self.request, reason) return HttpResponseRedirect(self.submission.get_absolute_url()) - return super(ReminderCreateView, self).dispatch(request, *args, **kwargs) + return super().dispatch(request, *args, **kwargs) def get(self, *args, **kwargs): reminder_form = CreateReminderForm(instance=self.submission) diff --git a/hypha/apply/funds/views/submission_edit.py b/hypha/apply/funds/views/submission_edit.py index b3aae08590..9491fbd55c 100644 --- a/hypha/apply/funds/views/submission_edit.py +++ b/hypha/apply/funds/views/submission_edit.py @@ -351,7 +351,7 @@ def dispatch(self, request, *args, **kwargs): if not permission: messages.warning(self.request, reason) return HttpResponseRedirect(self.submission.get_absolute_url()) - return super(ProgressSubmissionView, self).dispatch(request, *args, **kwargs) + return super().dispatch(request, *args, **kwargs) def get(self, *args, **kwargs): project_creation_form = ProgressSubmissionForm( @@ -409,7 +409,7 @@ def dispatch(self, request, *args, **kwargs): if not settings.PROJECTS_ALLOW_MULTIPLE and self.submission.projects.exists(): messages.warning(self.request, _("This submission already has a project.")) return HttpResponseRedirect(self.submission.get_absolute_url()) - return super(CreateProjectView, self).dispatch(request, *args, **kwargs) + return super().dispatch(request, *args, **kwargs) def get(self, *args, **kwargs): project_creation_form = ProjectCreateForm(instance=self.submission) @@ -582,7 +582,7 @@ def dispatch(self, request, *args, **kwargs): if not permission: messages.warning(self.request, reason) return HttpResponseRedirect(self.submission.get_absolute_url()) - return super(UpdateReviewersView, self).dispatch(request, *args, **kwargs) + return super().dispatch(request, *args, **kwargs) def get(self, *args, **kwargs): reviewer_form = UpdateReviewersForm( @@ -658,7 +658,7 @@ def dispatch(self, request, *args, **kwargs): if not permission: messages.warning(self.request, reason) return HttpResponseRedirect(self.submission.get_absolute_url()) - return super(UpdateAuthorView, self).dispatch(request, *args, **kwargs) + return super().dispatch(request, *args, **kwargs) def get(self, *args, **kwargs): author_form = self.form_class(user=self.request.user, instance=self.submission) @@ -712,7 +712,7 @@ def dispatch(self, request, *args, **kwargs): if not permission: messages.warning(self.request, reason) return HttpResponseRedirect(self.submission.get_absolute_url()) - return super(UpdateMetaTermsView, self).dispatch(request, *args, **kwargs) + return super().dispatch(request, *args, **kwargs) def get(self, *args, **kwargs): metaterms_form = UpdateMetaTermsForm( diff --git a/hypha/apply/funds/views/translate.py b/hypha/apply/funds/views/translate.py index e1a9cca655..52fed0c752 100644 --- a/hypha/apply/funds/views/translate.py +++ b/hypha/apply/funds/views/translate.py @@ -46,9 +46,7 @@ def dispatch(self, request, *args, **kwargs): _("User attempted to translate submission but is not org faculty"), ) return HttpResponseRedirect(self.submission.get_absolute_url()) - return super(TranslateSubmissionView, self).dispatch( - request, *args, **kwargs - ) + return super().dispatch(request, *args, **kwargs) def get(self, *args, **kwargs): translate_form = TranslateSubmissionForm() diff --git a/hypha/apply/projects/forms/project.py b/hypha/apply/projects/forms/project.py index 13588de223..0f18edfa90 100644 --- a/hypha/apply/projects/forms/project.py +++ b/hypha/apply/projects/forms/project.py @@ -427,7 +427,7 @@ def __init__(self, *args, user=None, instance=None, **kwargs): def save(self, commit=True): self.instance.title = self.instance.document - return super(UploadDocumentForm, self).save(commit=True) + return super().save(commit=True) class UploadContractDocumentForm(FileFormMixin, forms.ModelForm): @@ -443,7 +443,7 @@ def __init__(self, *args, user=None, instance=None, **kwargs): def save(self, commit=True): self.instance.title = self.instance.document - return super(UploadContractDocumentForm, self).save(commit=True) + return super().save(commit=True) class UpdateProjectLeadForm(forms.ModelForm): diff --git a/hypha/apply/review/blocks.py b/hypha/apply/review/blocks.py index f2ed49b63b..b832b3b760 100644 --- a/hypha/apply/review/blocks.py +++ b/hypha/apply/review/blocks.py @@ -154,7 +154,7 @@ class Meta: icon = "radio-empty" def get_field_kwargs(self, struct_value): - kwargs = super(VisibilityBlock, self).get_field_kwargs(struct_value) + kwargs = super().get_field_kwargs(struct_value) kwargs["choices"] = VISIBILITY.items() kwargs["initial"] = settings.REVIEW_VISIBILITY_DEFAULT kwargs["help_text"] = mark_safe( diff --git a/hypha/apply/stream_forms/forms.py b/hypha/apply/stream_forms/forms.py index 8106996261..623bd89565 100644 --- a/hypha/apply/stream_forms/forms.py +++ b/hypha/apply/stream_forms/forms.py @@ -19,7 +19,7 @@ class MixedFieldMetaclass(DeclarativeFieldsMetaclass): def __new__(mcs, name, bases, attrs): display = attrs.copy() - new_class = super(MixedFieldMetaclass, mcs).__new__(mcs, name, bases, attrs) + new_class = super().__new__(mcs, name, bases, attrs) new_class.display = display return new_class diff --git a/hypha/apply/users/admin_views.py b/hypha/apply/users/admin_views.py index b883f7e0f5..b124acd2a1 100644 --- a/hypha/apply/users/admin_views.py +++ b/hypha/apply/users/admin_views.py @@ -32,11 +32,11 @@ # Typically we would check the permission 'auth.change_user' (and 'auth.add_user' / # 'auth.delete_user') for user management actions, but this may vary according to # the AUTH_USER_MODEL setting -add_user_perm = "{0}.add_{1}".format(AUTH_USER_APP_LABEL, AUTH_USER_MODEL_NAME.lower()) -change_user_perm = "{0}.change_{1}".format( +add_user_perm = "{}.add_{}".format(AUTH_USER_APP_LABEL, AUTH_USER_MODEL_NAME.lower()) +change_user_perm = "{}.change_{}".format( AUTH_USER_APP_LABEL, AUTH_USER_MODEL_NAME.lower() ) -delete_user_perm = "{0}.delete_{1}".format( +delete_user_perm = "{}.delete_{}".format( AUTH_USER_APP_LABEL, AUTH_USER_MODEL_NAME.lower() ) diff --git a/hypha/apply/users/migrations/0001_initial.py b/hypha/apply/users/migrations/0001_initial.py index dda94d9a16..2d0b79a283 100644 --- a/hypha/apply/users/migrations/0001_initial.py +++ b/hypha/apply/users/migrations/0001_initial.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.7 on 2017-12-15 13:04 -from __future__ import unicode_literals import django.contrib.auth.models import django.contrib.auth.validators diff --git a/hypha/apply/users/migrations/0002_initial_data.py b/hypha/apply/users/migrations/0002_initial_data.py index de52563a2e..ccd7a979a4 100644 --- a/hypha/apply/users/migrations/0002_initial_data.py +++ b/hypha/apply/users/migrations/0002_initial_data.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.7 on 2017-12-15 13:15 -from __future__ import unicode_literals from django.db import migrations diff --git a/hypha/apply/users/migrations/0003_make_email_username.py b/hypha/apply/users/migrations/0003_make_email_username.py index 9179bf0b57..5174979078 100644 --- a/hypha/apply/users/migrations/0003_make_email_username.py +++ b/hypha/apply/users/migrations/0003_make_email_username.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.8 on 2018-02-05 10:52 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/hypha/apply/users/migrations/0004_drop_first_last_names.py b/hypha/apply/users/migrations/0004_drop_first_last_names.py index e1b03dab3d..6b333e2a31 100644 --- a/hypha/apply/users/migrations/0004_drop_first_last_names.py +++ b/hypha/apply/users/migrations/0004_drop_first_last_names.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.8 on 2018-02-28 11:04 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/hypha/apply/users/migrations/0005_user_drupal_id.py b/hypha/apply/users/migrations/0005_user_drupal_id.py index 3d2899a0de..cb0748e373 100644 --- a/hypha/apply/users/migrations/0005_user_drupal_id.py +++ b/hypha/apply/users/migrations/0005_user_drupal_id.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.8 on 2018-02-28 15:21 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/hypha/apply/users/migrations/0009_add_partner_group.py b/hypha/apply/users/migrations/0009_add_partner_group.py index eca6859675..96991d58f4 100644 --- a/hypha/apply/users/migrations/0009_add_partner_group.py +++ b/hypha/apply/users/migrations/0009_add_partner_group.py @@ -1,5 +1,4 @@ # Generated by Django 2.0.9 on 2018-12-19 13:21 -from __future__ import unicode_literals from django.db import migrations diff --git a/hypha/apply/users/migrations/0010_add_community_reviewer_group.py b/hypha/apply/users/migrations/0010_add_community_reviewer_group.py index be39afe9c4..cddd3cbf89 100644 --- a/hypha/apply/users/migrations/0010_add_community_reviewer_group.py +++ b/hypha/apply/users/migrations/0010_add_community_reviewer_group.py @@ -1,5 +1,4 @@ # Generated by Django 2.0.9 on 2018-12-19 13:21 -from __future__ import unicode_literals from django.db import migrations diff --git a/hypha/apply/users/migrations/0011_add_applicant_group.py b/hypha/apply/users/migrations/0011_add_applicant_group.py index 05a8304744..461d5d3378 100644 --- a/hypha/apply/users/migrations/0011_add_applicant_group.py +++ b/hypha/apply/users/migrations/0011_add_applicant_group.py @@ -1,5 +1,4 @@ # Generated by Django 2.0.9 on 2018-12-19 13:21 -from __future__ import unicode_literals from django.db import migrations diff --git a/hypha/apply/users/migrations/0012_set_applicant_group.py b/hypha/apply/users/migrations/0012_set_applicant_group.py index 38e88013db..90d54a66a9 100644 --- a/hypha/apply/users/migrations/0012_set_applicant_group.py +++ b/hypha/apply/users/migrations/0012_set_applicant_group.py @@ -1,5 +1,4 @@ # Generated by Django 2.0.9 on 2018-12-19 13:21 -from __future__ import unicode_literals from django.db import migrations diff --git a/hypha/apply/users/migrations/0017_rename_staff_admin.py b/hypha/apply/users/migrations/0017_rename_staff_admin.py index ac2c859ff7..391784f371 100644 --- a/hypha/apply/users/migrations/0017_rename_staff_admin.py +++ b/hypha/apply/users/migrations/0017_rename_staff_admin.py @@ -1,5 +1,4 @@ # Generated by Django 2.0.9 on 2018-12-19 13:21 -from __future__ import unicode_literals from django.db import migrations diff --git a/hypha/apply/users/tests/test_middleware.py b/hypha/apply/users/tests/test_middleware.py index 1b35a3d299..8d6666afc5 100644 --- a/hypha/apply/users/tests/test_middleware.py +++ b/hypha/apply/users/tests/test_middleware.py @@ -43,7 +43,7 @@ def test_unverified_user_can_access_allowed_urls(self): path = str(path) + f"{submission.id}/" response = self.client.get(path, follow=True) elif "upload" in path: - response = self.client.post(path, HTTP_TUS_RESUMABLE=True) + response = self.client.post(path, headers={"tus-resumable": "1.0.0"}) elif "logout" in path: response = self.client.post(path, follow=True) else: diff --git a/hypha/apply/users/tests/test_passkey_views.py b/hypha/apply/users/tests/test_passkey_views.py index 9cbfa2dcb2..3e4e04218f 100644 --- a/hypha/apply/users/tests/test_passkey_views.py +++ b/hypha/apply/users/tests/test_passkey_views.py @@ -744,7 +744,7 @@ def test_delete_requires_elevation_and_keeps_passkey(self): passkey = make_passkey(self.user) url = reverse("users:passkey_delete", args=[passkey.pk]) # HTMX request — expect an HX-Redirect header instead of a JSON body. - response = self.client.post(url, HTTP_HX_REQUEST="true") + response = self.client.post(url, headers={"hx-request": "true"}) self.assertEqual(response.status_code, 204) self.assertIn(reverse("users:elevate"), response["HX-Redirect"]) self.assertTrue(Passkey.objects.filter(pk=passkey.pk).exists()) @@ -753,7 +753,7 @@ def test_elevated_user_can_delete(self): force_elevated(self) passkey = make_passkey(self.user) url = reverse("users:passkey_delete", args=[passkey.pk]) - response = self.client.post(url, HTTP_HX_REQUEST="true") + response = self.client.post(url, headers={"hx-request": "true"}) self.assertEqual(response.status_code, 200) self.assertFalse(Passkey.objects.filter(pk=passkey.pk).exists()) @@ -777,7 +777,7 @@ def test_register_begin_requires_elevation(self): def test_delete_requires_elevation_and_keeps_passkey(self): passkey = make_passkey(self.user) url = reverse("users:passkey_delete", args=[passkey.pk]) - response = self.client.post(url, HTTP_HX_REQUEST="true") + response = self.client.post(url, headers={"hx-request": "true"}) self.assertEqual(response.status_code, 204) self.assertIn(reverse("users:elevate"), response["HX-Redirect"]) self.assertTrue(Passkey.objects.filter(pk=passkey.pk).exists()) @@ -786,7 +786,7 @@ def test_elevated_user_can_delete(self): force_elevated(self) passkey = make_passkey(self.user) url = reverse("users:passkey_delete", args=[passkey.pk]) - response = self.client.post(url, HTTP_HX_REQUEST="true") + response = self.client.post(url, headers={"hx-request": "true"}) self.assertEqual(response.status_code, 200) self.assertFalse(Passkey.objects.filter(pk=passkey.pk).exists()) diff --git a/hypha/apply/users/views.py b/hypha/apply/users/views.py index 12a1c0051f..81e471b32a 100644 --- a/hypha/apply/users/views.py +++ b/hypha/apply/users/views.py @@ -100,7 +100,7 @@ class LoginView(TwoFactorLoginView): template_name = "users/login.html" def get_context_data(self, form, **kwargs): - context_data = super(LoginView, self).get_context_data(form, **kwargs) + context_data = super().get_context_data(form, **kwargs) context_data["redirect_url"] = get_redirect_url( self.request, self.redirect_field_name ) diff --git a/hypha/core/mail.py b/hypha/core/mail.py index 013dbb29af..d0b96b6fb4 100644 --- a/hypha/core/mail.py +++ b/hypha/core/mail.py @@ -31,7 +31,7 @@ def language(lang): translation.activate(old_language) -class MarkdownMail(object): +class MarkdownMail: """Render and send an html + plain-text email using a markdown template. Usages: @@ -57,7 +57,7 @@ def _render_template(self, context: Dict) -> str | None: context.update(global_vars(None)) return loader.render_to_string(self.template_name, context) except TemplateDoesNotExist as e: - logger.warning("Template '{0}' does not exists.".format(e)) + logger.warning("Template '{}' does not exists.".format(e)) return None def make_email_object(self, to: str | List[str], context, **kwargs): diff --git a/hypha/core/middleware/tests/__init__.py b/hypha/core/middleware/tests/__init__.py index 8b13789179..e69de29bb2 100644 --- a/hypha/core/middleware/tests/__init__.py +++ b/hypha/core/middleware/tests/__init__.py @@ -1 +0,0 @@ - diff --git a/hypha/elevate/__init__.py b/hypha/elevate/__init__.py index 31cb49de8e..88ead39f2d 100644 --- a/hypha/elevate/__init__.py +++ b/hypha/elevate/__init__.py @@ -16,5 +16,3 @@ VERSION = version("elevate") except Exception: # pragma: no cover VERSION = "unknown" - -default_app_config = "hypha.elevate.apps.ElevateConfig" diff --git a/hypha/home/migrations/0001_initial.py b/hypha/home/migrations/0001_initial.py index 932d09eddf..68aaf824c2 100644 --- a/hypha/home/migrations/0001_initial.py +++ b/hypha/home/migrations/0001_initial.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.8 on 2018-01-09 18:58 -from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion diff --git a/hypha/home/migrations/0002_add_apply_homepage.py b/hypha/home/migrations/0002_add_apply_homepage.py index 59ecd28f98..85075522d9 100644 --- a/hypha/home/migrations/0002_add_apply_homepage.py +++ b/hypha/home/migrations/0002_add_apply_homepage.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - from django.db import migrations diff --git a/hypha/images/migrations/0001_initial.py b/hypha/images/migrations/0001_initial.py index 35a32abb9b..f516adcc36 100644 --- a/hypha/images/migrations/0001_initial.py +++ b/hypha/images/migrations/0001_initial.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.7 on 2017-04-14 09:20 -from __future__ import unicode_literals from django.conf import settings from django.db import migrations, models