From 3a2297ece5405c4206f842438a2cdb46ab9d83b8 Mon Sep 17 00:00:00 2001 From: Sergei Date: Tue, 4 Jun 2024 22:48:57 +0300 Subject: [PATCH 1/4] move leaderboard views to separate module, created generic view for them --- contributors/urls.py | 14 +++--- contributors/views/__init__.py | 4 +- contributors/views/leaderboard.py | 58 +++++++++++++++++++++++ contributors/views/leaderboard_commits.py | 23 --------- contributors/views/leaderboard_issues.py | 23 --------- contributors/views/leaderboard_prs.py | 24 ---------- 6 files changed, 66 insertions(+), 80 deletions(-) create mode 100644 contributors/views/leaderboard.py delete mode 100644 contributors/views/leaderboard_commits.py delete mode 100644 contributors/views/leaderboard_issues.py delete mode 100644 contributors/views/leaderboard_prs.py diff --git a/contributors/urls.py b/contributors/urls.py index aab27185..1abd1043 100644 --- a/contributors/urls.py +++ b/contributors/urls.py @@ -32,17 +32,17 @@ ), path( 'leaderboard/commits', - views.leaderboard_commits.ListView.as_view(), + views.leaderboard.CommitsListView.as_view(), name='leaderboard_commits', ), path( 'leaderboard/pull-requests', - views.leaderboard_prs.ListView.as_view(), + views.leaderboard.PrsListView.as_view(), name='leaderboard_prs', ), path( 'leaderboard/issues', - views.leaderboard_issues.ListView.as_view(), + views.leaderboard.IssuesListView.as_view(), name='leaderboard_issues', ), path( @@ -90,14 +90,14 @@ name='project_details', ), path( - "issues/", + 'issues/', views.issues.ListView.as_view(), - name="open_issues", + name='open_issues', ), path( - "pull_requests", + 'pull_requests', views.pull_requests.ListView.as_view(), - name="pull_requests_list", + name='pull_requests_list', ), path('event-handler', views.webhook.EventHandler.as_view()), path('about', views.about.AboutView.as_view(), name="about"), diff --git a/contributors/views/__init__.py b/contributors/views/__init__.py index eb00c71e..6d08cae9 100644 --- a/contributors/views/__init__.py +++ b/contributors/views/__init__.py @@ -11,9 +11,7 @@ home, issues, landing, - leaderboard_commits, - leaderboard_issues, - leaderboard_prs, + leaderboard, organization, organizations, project, diff --git a/contributors/views/leaderboard.py b/contributors/views/leaderboard.py new file mode 100644 index 00000000..c8d2d265 --- /dev/null +++ b/contributors/views/leaderboard.py @@ -0,0 +1,58 @@ +from django.views import generic + +from contributors.models import Contributor +from contributors.views.mixins import ( + LeaderboardQueryMixin, + TableSortSearchAndPaginationMixin, +) + + +class LeaderboardGenericListView( + LeaderboardQueryMixin, + TableSortSearchAndPaginationMixin, + generic.ListView, +): + """Generic view for inheritance.""" + + queryset = Contributor.objects.visible().with_contributions() + + searchable_fields = ('login', 'name') + paginate_by = 100 + + +class CommitsListView(LeaderboardGenericListView): + """List of leaders among contributors by commits.""" + + template_name = ( + 'contributors_sections/leaderboard/leaderboard_commits.html' + ) + sortable_fields = ( + '-commits', + 'login', + 'name', + ) + ordering = sortable_fields[0] + + +class IssuesListView(LeaderboardGenericListView): + """List of leaders among contributors by issues.""" + + template_name = 'contributors_sections/leaderboard/leaderboard_issues.html' + sortable_fields = ( + '-issues', + 'login', + 'name', + ) + ordering = sortable_fields[0] + + +class PrsListView(LeaderboardGenericListView): + """List of leaders among contributors by pull requests.""" + + template_name = 'contributors_sections/leaderboard/leaderboard_prs.html' + sortable_fields = ( + '-pull_requests', + 'login', + 'name', + ) + ordering = sortable_fields[0] diff --git a/contributors/views/leaderboard_commits.py b/contributors/views/leaderboard_commits.py deleted file mode 100644 index 6aaa70a0..00000000 --- a/contributors/views/leaderboard_commits.py +++ /dev/null @@ -1,23 +0,0 @@ -from django.views import generic - -from contributors.models import Contributor -from contributors.views.mixins import ( - LeaderboardQueryMixin, - TableSortSearchAndPaginationMixin, -) - - -class ListView( - LeaderboardQueryMixin, - TableSortSearchAndPaginationMixin, - generic.ListView, -): - """List of leaders among contributors by commits.""" - - queryset = Contributor.objects.visible().with_contributions() - template_name = 'contributors_sections/leaderboard/leaderboard_commits.html' # noqa: E501 - sortable_fields = ( - '-commits', - ) - searchable_fields = ('login', 'name') - paginate_by = 100 diff --git a/contributors/views/leaderboard_issues.py b/contributors/views/leaderboard_issues.py deleted file mode 100644 index ab2b7969..00000000 --- a/contributors/views/leaderboard_issues.py +++ /dev/null @@ -1,23 +0,0 @@ -from django.views import generic - -from contributors.models import Contributor -from contributors.views.mixins import ( - LeaderboardQueryMixin, - TableSortSearchAndPaginationMixin, -) - - -class ListView( - LeaderboardQueryMixin, - TableSortSearchAndPaginationMixin, - generic.ListView, -): - """List of leaders among contributors by issues.""" - - queryset = Contributor.objects.visible().with_contributions() - template_name = 'contributors_sections/leaderboard/leaderboard_issues.html' - sortable_fields = ( - '-issues', - ) - searchable_fields = ('login', 'name') - paginate_by = 100 diff --git a/contributors/views/leaderboard_prs.py b/contributors/views/leaderboard_prs.py deleted file mode 100644 index 45dcec25..00000000 --- a/contributors/views/leaderboard_prs.py +++ /dev/null @@ -1,24 +0,0 @@ -from django.views import generic - -from contributors.models import Contributor -from contributors.views.mixins import ( - LeaderboardQueryMixin, - TableSortSearchAndPaginationMixin, -) - - -class ListView( - LeaderboardQueryMixin, - TableSortSearchAndPaginationMixin, - generic.ListView, -): - """List of leaders among contributors by pull requests.""" - - queryset = Contributor.objects.visible().with_contributions() - template_name = 'contributors_sections/leaderboard/leaderboard_prs.html' - sortable_fields = ( - '-pull_requests', - ) - - searchable_fields = ('login', 'name') - paginate_by = 100 From 89d2ee2187e4931bbd4335d1f8b4f41b1dd89608 Mon Sep 17 00:00:00 2001 From: Sergei Date: Wed, 5 Jun 2024 00:09:09 +0300 Subject: [PATCH 2/4] move almost all views to separate packages --- contributors/admin/custom.py | 6 ++--- contributors/tests/test_paginator.py | 2 +- contributors/urls.py | 6 ++--- contributors/views/__init__.py | 26 +++++++++---------- contributors/views/contributor_compare.py | 2 +- .../views/contributors_views/__init__.py | 0 .../{ => contributors_views}/contributor.py | 13 ++++++---- .../contributor_issues.py | 2 +- .../contributor_prs.py | 2 +- .../{ => contributors_views}/contributors.py | 2 +- .../contributors_for_period.py | 2 +- .../views/generic_list_views/__init__.py | 0 .../views/{ => generic_list_views}/issues.py | 4 +-- .../leaderboards.py} | 2 +- .../{ => generic_list_views}/pull_requests.py | 2 +- .../views/organizations_views/__init__.py | 1 + .../{ => organizations_views}/organization.py | 9 ++++--- .../organizations.py | 2 +- contributors/views/projects_views/__init__.py | 0 .../views/{ => projects_views}/project.py | 2 +- .../views/{ => projects_views}/projects.py | 2 +- .../views/repositories_views/__init__.py | 0 .../{ => repositories_views}/repositories.py | 2 +- .../{ => repositories_views}/repository.py | 2 +- contributors/views/user_settings.py | 2 +- contributors/views/utils/__init__.py | 0 contributors/views/{ => utils}/config.py | 0 contributors/views/{ => utils}/filters.py | 0 contributors/views/{ => utils}/mixins.py | 0 contributors/views/{ => utils}/webhook.py | 0 30 files changed, 50 insertions(+), 43 deletions(-) create mode 100644 contributors/views/contributors_views/__init__.py rename contributors/views/{ => contributors_views}/contributor.py (87%) rename contributors/views/{ => contributors_views}/contributor_issues.py (94%) rename contributors/views/{ => contributors_views}/contributor_prs.py (95%) rename contributors/views/{ => contributors_views}/contributors.py (94%) rename contributors/views/{ => contributors_views}/contributors_for_period.py (94%) create mode 100644 contributors/views/generic_list_views/__init__.py rename contributors/views/{ => generic_list_views}/issues.py (95%) rename contributors/views/{leaderboard.py => generic_list_views/leaderboards.py} (96%) rename contributors/views/{ => generic_list_views}/pull_requests.py (96%) create mode 100644 contributors/views/organizations_views/__init__.py rename contributors/views/{ => organizations_views}/organization.py (79%) rename contributors/views/{ => organizations_views}/organizations.py (89%) create mode 100644 contributors/views/projects_views/__init__.py rename contributors/views/{ => projects_views}/project.py (96%) rename contributors/views/{ => projects_views}/projects.py (96%) create mode 100644 contributors/views/repositories_views/__init__.py rename contributors/views/{ => repositories_views}/repositories.py (97%) rename contributors/views/{ => repositories_views}/repository.py (93%) create mode 100644 contributors/views/utils/__init__.py rename contributors/views/{ => utils}/config.py (100%) rename contributors/views/{ => utils}/filters.py (100%) rename contributors/views/{ => utils}/mixins.py (100%) rename contributors/views/{ => utils}/webhook.py (100%) diff --git a/contributors/admin/custom.py b/contributors/admin/custom.py index 0cb54c9d..fba8793f 100644 --- a/contributors/admin/custom.py +++ b/contributors/admin/custom.py @@ -2,7 +2,7 @@ from django.contrib import admin from django.urls import path -from contributors import views +from contributors.views.utils.config import collect_data, show_repos class CustomAdminSite(admin.AdminSite): @@ -17,12 +17,12 @@ def get_urls(self): custom_urls = [ path( 'contributors/config/', - self.admin_view(views.config.show_repos), + self.admin_view(show_repos), name='config', ), path( 'contributors/config/collect_data', - self.admin_view(views.config.collect_data), + self.admin_view(collect_data), name='collect_data', ), ] diff --git a/contributors/tests/test_paginator.py b/contributors/tests/test_paginator.py index 1b97a914..f371ffc9 100644 --- a/contributors/tests/test_paginator.py +++ b/contributors/tests/test_paginator.py @@ -1,6 +1,6 @@ from django.test import SimpleTestCase -from contributors.views.mixins import ( +from contributors.views.utils.mixins import ( INNER_VISIBLE_PAGES, MAX_PAGES_WITHOUT_SHRINKING, PAGES_VISIBLE_AT_BOUNDARY, diff --git a/contributors/urls.py b/contributors/urls.py index 1abd1043..c07f16ff 100644 --- a/contributors/urls.py +++ b/contributors/urls.py @@ -32,17 +32,17 @@ ), path( 'leaderboard/commits', - views.leaderboard.CommitsListView.as_view(), + views.leaderboards.CommitsListView.as_view(), name='leaderboard_commits', ), path( 'leaderboard/pull-requests', - views.leaderboard.PrsListView.as_view(), + views.leaderboards.PrsListView.as_view(), name='leaderboard_prs', ), path( 'leaderboard/issues', - views.leaderboard.IssuesListView.as_view(), + views.leaderboards.IssuesListView.as_view(), name='leaderboard_issues', ), path( diff --git a/contributors/views/__init__.py b/contributors/views/__init__.py index 6d08cae9..7800fc96 100644 --- a/contributors/views/__init__.py +++ b/contributors/views/__init__.py @@ -1,24 +1,24 @@ from contributors.views import ( # noqa: WPS235 about, achievements, - config, - contributor, contributor_compare, + home, + landing, + user_settings, +) +from contributors.views.contributors_views import ( + contributor, contributor_issues, contributor_prs, contributors, contributors_for_period, - home, +) +from contributors.views.generic_list_views import ( issues, - landing, - leaderboard, - organization, - organizations, - project, - projects, + leaderboards, pull_requests, - repositories, - repository, - user_settings, - webhook, ) +from contributors.views.organizations_views import organization, organizations +from contributors.views.projects_views import project, projects +from contributors.views.repositories_views import repositories, repository +from contributors.views.utils import config, filters, webhook diff --git a/contributors/views/contributor_compare.py b/contributors/views/contributor_compare.py index d5a4778a..c0868dac 100644 --- a/contributors/views/contributor_compare.py +++ b/contributors/views/contributor_compare.py @@ -2,7 +2,7 @@ from django.views.generic import ListView from contributors.models import Contribution, Contributor, Repository -from contributors.views.filters import DetailTablePeriodFilter +from contributors.views.utils.filters import DetailTablePeriodFilter class CompareWithYourselfView(ListView): diff --git a/contributors/views/contributors_views/__init__.py b/contributors/views/contributors_views/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/contributors/views/contributor.py b/contributors/views/contributors_views/contributor.py similarity index 87% rename from contributors/views/contributor.py rename to contributors/views/contributors_views/contributor.py index 1b20e44c..f63ce634 100644 --- a/contributors/views/contributor.py +++ b/contributors/views/contributors_views/contributor.py @@ -3,11 +3,14 @@ from django.views import generic from contributors.models import Contribution, Contributor, Repository -from contributors.views.mixins import ( +from contributors.views.utils.mixins import ( ContributorsJsonMixin, ContributorTotalStatMixin, ) +# This was done to fix: WPS 226 Found string literal over-use: id > 4 +ID = 'id' + class DetailView( ContributorTotalStatMixin, ContributorsJsonMixin, generic.DetailView, @@ -49,10 +52,10 @@ def get_context_data(self, **kwargs): context['summary'] = Contribution.objects.filter( contributor=self.object, ).aggregate( - commits=Count('id', filter=Q(type='cit')), - pull_requests=Count('id', filter=Q(type='pr')), - issues=Count('id', filter=Q(type='iss')), - comments=Count('id', filter=Q(type='cnt')), + commits=Count(ID, filter=Q(type='cit')), + pull_requests=Count(ID, filter=Q(type='pr')), + issues=Count(ID, filter=Q(type='iss')), + comments=Count(ID, filter=Q(type='cnt')), ) contributors = Contributor.objects.visible() diff --git a/contributors/views/contributor_issues.py b/contributors/views/contributors_views/contributor_issues.py similarity index 94% rename from contributors/views/contributor_issues.py rename to contributors/views/contributors_views/contributor_issues.py index a8c2fdea..6c94baba 100644 --- a/contributors/views/contributor_issues.py +++ b/contributors/views/contributors_views/contributor_issues.py @@ -2,7 +2,7 @@ from contributors.forms.forms import NameStatusFilterForm from contributors.models import Contribution -from contributors.views.mixins import TableSortSearchAndPaginationMixin +from contributors.views.utils.mixins import TableSortSearchAndPaginationMixin class ListView(TableSortSearchAndPaginationMixin, generic.ListView): diff --git a/contributors/views/contributor_prs.py b/contributors/views/contributors_views/contributor_prs.py similarity index 95% rename from contributors/views/contributor_prs.py rename to contributors/views/contributors_views/contributor_prs.py index 220b848d..a6010502 100644 --- a/contributors/views/contributor_prs.py +++ b/contributors/views/contributors_views/contributor_prs.py @@ -2,7 +2,7 @@ from contributors.forms.forms import PullRequestNameStatusFilterForm from contributors.models import Contribution -from contributors.views.mixins import TableSortSearchAndPaginationMixin +from contributors.views.utils.mixins import TableSortSearchAndPaginationMixin class ListView(TableSortSearchAndPaginationMixin, generic.ListView): diff --git a/contributors/views/contributors.py b/contributors/views/contributors_views/contributors.py similarity index 94% rename from contributors/views/contributors.py rename to contributors/views/contributors_views/contributors.py index 635a496a..300efbd1 100644 --- a/contributors/views/contributors.py +++ b/contributors/views/contributors_views/contributors.py @@ -2,7 +2,7 @@ from contributors.forms.forms import CombinedSearchForm from contributors.models import Contributor -from contributors.views.mixins import TableSortSearchAndPaginationMixin +from contributors.views.utils.mixins import TableSortSearchAndPaginationMixin class ListView(TableSortSearchAndPaginationMixin, generic.ListView): diff --git a/contributors/views/contributors_for_period.py b/contributors/views/contributors_views/contributors_for_period.py similarity index 94% rename from contributors/views/contributors_for_period.py rename to contributors/views/contributors_views/contributors_for_period.py index 662a1763..f2e4f0fc 100644 --- a/contributors/views/contributors_for_period.py +++ b/contributors/views/contributors_views/contributors_for_period.py @@ -1,6 +1,6 @@ from contributors.models import Contributor from contributors.utils import misc -from contributors.views import contributors +from contributors.views.contributors_views import contributors class ListView(contributors.ListView): diff --git a/contributors/views/generic_list_views/__init__.py b/contributors/views/generic_list_views/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/contributors/views/issues.py b/contributors/views/generic_list_views/issues.py similarity index 95% rename from contributors/views/issues.py rename to contributors/views/generic_list_views/issues.py index aa79863f..9bfbaf86 100644 --- a/contributors/views/issues.py +++ b/contributors/views/generic_list_views/issues.py @@ -2,8 +2,8 @@ from django_filters.views import FilterView from contributors.models import Contribution, ContributionLabel -from contributors.views.filters import IssuesFilter -from contributors.views.mixins import ( +from contributors.views.utils.filters import IssuesFilter +from contributors.views.utils.mixins import ( ContributionLabelsMixin, TableSortSearchAndPaginationMixin, ) diff --git a/contributors/views/leaderboard.py b/contributors/views/generic_list_views/leaderboards.py similarity index 96% rename from contributors/views/leaderboard.py rename to contributors/views/generic_list_views/leaderboards.py index c8d2d265..383de684 100644 --- a/contributors/views/leaderboard.py +++ b/contributors/views/generic_list_views/leaderboards.py @@ -1,7 +1,7 @@ from django.views import generic from contributors.models import Contributor -from contributors.views.mixins import ( +from contributors.views.utils.mixins import ( LeaderboardQueryMixin, TableSortSearchAndPaginationMixin, ) diff --git a/contributors/views/pull_requests.py b/contributors/views/generic_list_views/pull_requests.py similarity index 96% rename from contributors/views/pull_requests.py rename to contributors/views/generic_list_views/pull_requests.py index 91fc2e40..4165594c 100644 --- a/contributors/views/pull_requests.py +++ b/contributors/views/generic_list_views/pull_requests.py @@ -2,7 +2,7 @@ from contributors.forms.forms import PullRequestNameStatusFilterForm from contributors.models.contribution import Contribution -from contributors.views.mixins import TableSortSearchAndPaginationMixin +from contributors.views.utils.mixins import TableSortSearchAndPaginationMixin class ListView(TableSortSearchAndPaginationMixin, generic.ListView): diff --git a/contributors/views/organizations_views/__init__.py b/contributors/views/organizations_views/__init__.py new file mode 100644 index 00000000..5662ebc6 --- /dev/null +++ b/contributors/views/organizations_views/__init__.py @@ -0,0 +1 @@ +from contributors.views.organizations_views import organization, organizations diff --git a/contributors/views/organization.py b/contributors/views/organizations_views/organization.py similarity index 79% rename from contributors/views/organization.py rename to contributors/views/organizations_views/organization.py index 7871dba3..a281cccb 100644 --- a/contributors/views/organization.py +++ b/contributors/views/organizations_views/organization.py @@ -2,13 +2,15 @@ from django.utils.translation import gettext_lazy as _ from contributors.models import Organization -from contributors.views import repositories +from contributors.views.repositories_views import repositories class OrgRepositoryList(repositories.ListView): """An organization's details.""" - template_name = 'contributors_sections/organizations/organization_details.html' # noqa: E501 + template_name = ( + 'contributors_sections/organizations/organization_details.html' + ) sortable_fields = ( # noqa: WPS317 'name', 'project', @@ -20,7 +22,8 @@ class OrgRepositoryList(repositories.ListView): def get_queryset(self): # noqa: WPS615 """Get a dataset.""" self.organization = get_object_or_404( - Organization, name=self.kwargs['slug'], + Organization, + name=self.kwargs['slug'], ) self.queryset = self.queryset.filter(organization=self.organization) return super().get_queryset() diff --git a/contributors/views/organizations.py b/contributors/views/organizations_views/organizations.py similarity index 89% rename from contributors/views/organizations.py rename to contributors/views/organizations_views/organizations.py index a33f5003..ba848000 100644 --- a/contributors/views/organizations.py +++ b/contributors/views/organizations_views/organizations.py @@ -3,7 +3,7 @@ from django.views import generic from contributors.models import Organization -from contributors.views.mixins import TableSortSearchAndPaginationMixin +from contributors.views.utils.mixins import TableSortSearchAndPaginationMixin class ListView(TableSortSearchAndPaginationMixin, generic.ListView): diff --git a/contributors/views/projects_views/__init__.py b/contributors/views/projects_views/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/contributors/views/project.py b/contributors/views/projects_views/project.py similarity index 96% rename from contributors/views/project.py rename to contributors/views/projects_views/project.py index 6f8052f6..1da8b536 100644 --- a/contributors/views/project.py +++ b/contributors/views/projects_views/project.py @@ -5,7 +5,7 @@ from contributors.models import Contribution, Project from contributors.utils import misc -from contributors.views import repositories +from contributors.views.repositories_views import repositories class ProjectRepositoryList(repositories.ListView): diff --git a/contributors/views/projects.py b/contributors/views/projects_views/projects.py similarity index 96% rename from contributors/views/projects.py rename to contributors/views/projects_views/projects.py index e062a70c..de1a4879 100644 --- a/contributors/views/projects.py +++ b/contributors/views/projects_views/projects.py @@ -3,7 +3,7 @@ from django.views import generic from contributors.models import Project -from contributors.views.mixins import TableSortSearchAndPaginationMixin +from contributors.views.utils.mixins import TableSortSearchAndPaginationMixin class ListView(TableSortSearchAndPaginationMixin, generic.ListView): diff --git a/contributors/views/repositories_views/__init__.py b/contributors/views/repositories_views/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/contributors/views/repositories.py b/contributors/views/repositories_views/repositories.py similarity index 97% rename from contributors/views/repositories.py rename to contributors/views/repositories_views/repositories.py index 01425384..855061b0 100644 --- a/contributors/views/repositories.py +++ b/contributors/views/repositories_views/repositories.py @@ -3,7 +3,7 @@ from django.views import generic from contributors.models import Label, Repository -from contributors.views.mixins import ( +from contributors.views.utils.mixins import ( LabelsMixin, TableSortSearchAndPaginationMixin, ) diff --git a/contributors/views/repository.py b/contributors/views/repositories_views/repository.py similarity index 93% rename from contributors/views/repository.py rename to contributors/views/repositories_views/repository.py index 18bc4a82..512673eb 100644 --- a/contributors/views/repository.py +++ b/contributors/views/repositories_views/repository.py @@ -1,7 +1,7 @@ from django.shortcuts import get_object_or_404 from contributors.models import Repository -from contributors.views import contributors +from contributors.views.contributors_views import contributors class RepoContributorList(contributors.ListView): diff --git a/contributors/views/user_settings.py b/contributors/views/user_settings.py index 64214f8d..704d0805 100644 --- a/contributors/views/user_settings.py +++ b/contributors/views/user_settings.py @@ -5,7 +5,7 @@ from django.views.generic import TemplateView from auth.forms import UserTokenForm -from contributors.views.mixins import ( +from contributors.views.utils.mixins import ( AuthRequiredMixin, PermissionRequiredMixin, ) diff --git a/contributors/views/utils/__init__.py b/contributors/views/utils/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/contributors/views/config.py b/contributors/views/utils/config.py similarity index 100% rename from contributors/views/config.py rename to contributors/views/utils/config.py diff --git a/contributors/views/filters.py b/contributors/views/utils/filters.py similarity index 100% rename from contributors/views/filters.py rename to contributors/views/utils/filters.py diff --git a/contributors/views/mixins.py b/contributors/views/utils/mixins.py similarity index 100% rename from contributors/views/mixins.py rename to contributors/views/utils/mixins.py diff --git a/contributors/views/webhook.py b/contributors/views/utils/webhook.py similarity index 100% rename from contributors/views/webhook.py rename to contributors/views/utils/webhook.py From d1dfd5e1c08cd6eedcaac500eabf4ca8e3d06940 Mon Sep 17 00:00:00 2001 From: Sergei Date: Wed, 5 Jun 2024 19:05:19 +0300 Subject: [PATCH 3/4] remove imports in organizations_views/__init__.py due to uselessness --- contributors/views/organizations_views/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/contributors/views/organizations_views/__init__.py b/contributors/views/organizations_views/__init__.py index 5662ebc6..e69de29b 100644 --- a/contributors/views/organizations_views/__init__.py +++ b/contributors/views/organizations_views/__init__.py @@ -1 +0,0 @@ -from contributors.views.organizations_views import organization, organizations From 9cc162813d65b9c4876e0a39d7efab85240736c8 Mon Sep 17 00:00:00 2001 From: Sergei Date: Fri, 7 Jun 2024 16:05:26 +0300 Subject: [PATCH 4/4] move all modules from utils to views, remove utils folder --- contributors/admin/custom.py | 2 +- contributors/tests/test_paginator.py | 2 +- contributors/views/__init__.py | 4 +++- contributors/views/{utils => }/config.py | 0 contributors/views/contributor_compare.py | 2 +- contributors/views/contributors_views/contributor.py | 2 +- contributors/views/contributors_views/contributor_issues.py | 2 +- contributors/views/contributors_views/contributor_prs.py | 2 +- contributors/views/contributors_views/contributors.py | 2 +- contributors/views/{utils => }/filters.py | 0 contributors/views/generic_list_views/issues.py | 4 ++-- contributors/views/generic_list_views/leaderboards.py | 2 +- contributors/views/generic_list_views/pull_requests.py | 2 +- contributors/views/{utils => }/mixins.py | 0 contributors/views/organizations_views/organizations.py | 2 +- contributors/views/projects_views/projects.py | 2 +- contributors/views/repositories_views/repositories.py | 2 +- contributors/views/user_settings.py | 2 +- contributors/views/utils/__init__.py | 0 contributors/views/{utils => }/webhook.py | 0 20 files changed, 18 insertions(+), 16 deletions(-) rename contributors/views/{utils => }/config.py (100%) rename contributors/views/{utils => }/filters.py (100%) rename contributors/views/{utils => }/mixins.py (100%) delete mode 100644 contributors/views/utils/__init__.py rename contributors/views/{utils => }/webhook.py (100%) diff --git a/contributors/admin/custom.py b/contributors/admin/custom.py index fba8793f..1e1d90a2 100644 --- a/contributors/admin/custom.py +++ b/contributors/admin/custom.py @@ -2,7 +2,7 @@ from django.contrib import admin from django.urls import path -from contributors.views.utils.config import collect_data, show_repos +from contributors.views.config import collect_data, show_repos class CustomAdminSite(admin.AdminSite): diff --git a/contributors/tests/test_paginator.py b/contributors/tests/test_paginator.py index f371ffc9..1b97a914 100644 --- a/contributors/tests/test_paginator.py +++ b/contributors/tests/test_paginator.py @@ -1,6 +1,6 @@ from django.test import SimpleTestCase -from contributors.views.utils.mixins import ( +from contributors.views.mixins import ( INNER_VISIBLE_PAGES, MAX_PAGES_WITHOUT_SHRINKING, PAGES_VISIBLE_AT_BOUNDARY, diff --git a/contributors/views/__init__.py b/contributors/views/__init__.py index 7800fc96..e8282b57 100644 --- a/contributors/views/__init__.py +++ b/contributors/views/__init__.py @@ -1,10 +1,13 @@ from contributors.views import ( # noqa: WPS235 about, achievements, + config, contributor_compare, + filters, home, landing, user_settings, + webhook, ) from contributors.views.contributors_views import ( contributor, @@ -21,4 +24,3 @@ from contributors.views.organizations_views import organization, organizations from contributors.views.projects_views import project, projects from contributors.views.repositories_views import repositories, repository -from contributors.views.utils import config, filters, webhook diff --git a/contributors/views/utils/config.py b/contributors/views/config.py similarity index 100% rename from contributors/views/utils/config.py rename to contributors/views/config.py diff --git a/contributors/views/contributor_compare.py b/contributors/views/contributor_compare.py index c0868dac..d5a4778a 100644 --- a/contributors/views/contributor_compare.py +++ b/contributors/views/contributor_compare.py @@ -2,7 +2,7 @@ from django.views.generic import ListView from contributors.models import Contribution, Contributor, Repository -from contributors.views.utils.filters import DetailTablePeriodFilter +from contributors.views.filters import DetailTablePeriodFilter class CompareWithYourselfView(ListView): diff --git a/contributors/views/contributors_views/contributor.py b/contributors/views/contributors_views/contributor.py index f63ce634..62b9ed4b 100644 --- a/contributors/views/contributors_views/contributor.py +++ b/contributors/views/contributors_views/contributor.py @@ -3,7 +3,7 @@ from django.views import generic from contributors.models import Contribution, Contributor, Repository -from contributors.views.utils.mixins import ( +from contributors.views.mixins import ( ContributorsJsonMixin, ContributorTotalStatMixin, ) diff --git a/contributors/views/contributors_views/contributor_issues.py b/contributors/views/contributors_views/contributor_issues.py index 6c94baba..a8c2fdea 100644 --- a/contributors/views/contributors_views/contributor_issues.py +++ b/contributors/views/contributors_views/contributor_issues.py @@ -2,7 +2,7 @@ from contributors.forms.forms import NameStatusFilterForm from contributors.models import Contribution -from contributors.views.utils.mixins import TableSortSearchAndPaginationMixin +from contributors.views.mixins import TableSortSearchAndPaginationMixin class ListView(TableSortSearchAndPaginationMixin, generic.ListView): diff --git a/contributors/views/contributors_views/contributor_prs.py b/contributors/views/contributors_views/contributor_prs.py index a6010502..220b848d 100644 --- a/contributors/views/contributors_views/contributor_prs.py +++ b/contributors/views/contributors_views/contributor_prs.py @@ -2,7 +2,7 @@ from contributors.forms.forms import PullRequestNameStatusFilterForm from contributors.models import Contribution -from contributors.views.utils.mixins import TableSortSearchAndPaginationMixin +from contributors.views.mixins import TableSortSearchAndPaginationMixin class ListView(TableSortSearchAndPaginationMixin, generic.ListView): diff --git a/contributors/views/contributors_views/contributors.py b/contributors/views/contributors_views/contributors.py index 300efbd1..635a496a 100644 --- a/contributors/views/contributors_views/contributors.py +++ b/contributors/views/contributors_views/contributors.py @@ -2,7 +2,7 @@ from contributors.forms.forms import CombinedSearchForm from contributors.models import Contributor -from contributors.views.utils.mixins import TableSortSearchAndPaginationMixin +from contributors.views.mixins import TableSortSearchAndPaginationMixin class ListView(TableSortSearchAndPaginationMixin, generic.ListView): diff --git a/contributors/views/utils/filters.py b/contributors/views/filters.py similarity index 100% rename from contributors/views/utils/filters.py rename to contributors/views/filters.py diff --git a/contributors/views/generic_list_views/issues.py b/contributors/views/generic_list_views/issues.py index 9bfbaf86..aa79863f 100644 --- a/contributors/views/generic_list_views/issues.py +++ b/contributors/views/generic_list_views/issues.py @@ -2,8 +2,8 @@ from django_filters.views import FilterView from contributors.models import Contribution, ContributionLabel -from contributors.views.utils.filters import IssuesFilter -from contributors.views.utils.mixins import ( +from contributors.views.filters import IssuesFilter +from contributors.views.mixins import ( ContributionLabelsMixin, TableSortSearchAndPaginationMixin, ) diff --git a/contributors/views/generic_list_views/leaderboards.py b/contributors/views/generic_list_views/leaderboards.py index 383de684..c8d2d265 100644 --- a/contributors/views/generic_list_views/leaderboards.py +++ b/contributors/views/generic_list_views/leaderboards.py @@ -1,7 +1,7 @@ from django.views import generic from contributors.models import Contributor -from contributors.views.utils.mixins import ( +from contributors.views.mixins import ( LeaderboardQueryMixin, TableSortSearchAndPaginationMixin, ) diff --git a/contributors/views/generic_list_views/pull_requests.py b/contributors/views/generic_list_views/pull_requests.py index 4165594c..91fc2e40 100644 --- a/contributors/views/generic_list_views/pull_requests.py +++ b/contributors/views/generic_list_views/pull_requests.py @@ -2,7 +2,7 @@ from contributors.forms.forms import PullRequestNameStatusFilterForm from contributors.models.contribution import Contribution -from contributors.views.utils.mixins import TableSortSearchAndPaginationMixin +from contributors.views.mixins import TableSortSearchAndPaginationMixin class ListView(TableSortSearchAndPaginationMixin, generic.ListView): diff --git a/contributors/views/utils/mixins.py b/contributors/views/mixins.py similarity index 100% rename from contributors/views/utils/mixins.py rename to contributors/views/mixins.py diff --git a/contributors/views/organizations_views/organizations.py b/contributors/views/organizations_views/organizations.py index ba848000..a33f5003 100644 --- a/contributors/views/organizations_views/organizations.py +++ b/contributors/views/organizations_views/organizations.py @@ -3,7 +3,7 @@ from django.views import generic from contributors.models import Organization -from contributors.views.utils.mixins import TableSortSearchAndPaginationMixin +from contributors.views.mixins import TableSortSearchAndPaginationMixin class ListView(TableSortSearchAndPaginationMixin, generic.ListView): diff --git a/contributors/views/projects_views/projects.py b/contributors/views/projects_views/projects.py index de1a4879..e062a70c 100644 --- a/contributors/views/projects_views/projects.py +++ b/contributors/views/projects_views/projects.py @@ -3,7 +3,7 @@ from django.views import generic from contributors.models import Project -from contributors.views.utils.mixins import TableSortSearchAndPaginationMixin +from contributors.views.mixins import TableSortSearchAndPaginationMixin class ListView(TableSortSearchAndPaginationMixin, generic.ListView): diff --git a/contributors/views/repositories_views/repositories.py b/contributors/views/repositories_views/repositories.py index 855061b0..01425384 100644 --- a/contributors/views/repositories_views/repositories.py +++ b/contributors/views/repositories_views/repositories.py @@ -3,7 +3,7 @@ from django.views import generic from contributors.models import Label, Repository -from contributors.views.utils.mixins import ( +from contributors.views.mixins import ( LabelsMixin, TableSortSearchAndPaginationMixin, ) diff --git a/contributors/views/user_settings.py b/contributors/views/user_settings.py index 704d0805..64214f8d 100644 --- a/contributors/views/user_settings.py +++ b/contributors/views/user_settings.py @@ -5,7 +5,7 @@ from django.views.generic import TemplateView from auth.forms import UserTokenForm -from contributors.views.utils.mixins import ( +from contributors.views.mixins import ( AuthRequiredMixin, PermissionRequiredMixin, ) diff --git a/contributors/views/utils/__init__.py b/contributors/views/utils/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/contributors/views/utils/webhook.py b/contributors/views/webhook.py similarity index 100% rename from contributors/views/utils/webhook.py rename to contributors/views/webhook.py