Skip to content

Commit

Permalink
move almost all views to separate packages
Browse files Browse the repository at this point in the history
  • Loading branch information
ReYaNOW committed Jun 4, 2024
1 parent 3a2297e commit 89d2ee2
Show file tree
Hide file tree
Showing 30 changed files with 50 additions and 43 deletions.
6 changes: 3 additions & 3 deletions contributors/admin/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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',
),
]
Expand Down
2 changes: 1 addition & 1 deletion contributors/tests/test_paginator.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
6 changes: 3 additions & 3 deletions contributors/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
26 changes: 13 additions & 13 deletions contributors/views/__init__.py
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion contributors/views/contributor_compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions contributors/views/organizations_views/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from contributors.views.organizations_views import organization, organizations
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
2 changes: 1 addition & 1 deletion contributors/views/user_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 89d2ee2

Please sign in to comment.