Skip to content

Commit

Permalink
refactor: Rename DdmAuthMixin to DDMAuthMixin.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico-AP committed Nov 14, 2024
1 parent 66430fd commit 540afec
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 33 deletions.
4 changes: 2 additions & 2 deletions ddm/auth/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.contrib.auth import get_user_model
from django.views.generic import TemplateView

from ddm.auth.views import DdmAuthMixin
from ddm.auth.views import DDMAuthMixin
from ddm.projects.models import ResearchProfile, DonationProject

User = get_user_model()
Expand Down Expand Up @@ -86,7 +86,7 @@ def test_redirect_if_anonymous(self):
self.assertRedirects(response, reverse('ddm_login'))


class TestView(DdmAuthMixin, TemplateView):
class TestView(DDMAuthMixin, TemplateView):
template_name = 'auth/no_permission.html'


Expand Down
4 changes: 2 additions & 2 deletions ddm/auth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
User = get_user_model()


class DdmAuthMixin:
class DDMAuthMixin:
"""
Mixin for Class Based Views that handles redirects as follows:
- unauthenticated users => login page.
Expand Down Expand Up @@ -71,7 +71,7 @@ def dispatch(self, request, *args, **kwargs):
return super().dispatch(request, *args, **kwargs)


class ProjectTokenView(SuccessMessageMixin, DdmAuthMixin, FormView):
class ProjectTokenView(SuccessMessageMixin, DDMAuthMixin, FormView):
""" View to see existing access token or generate a new one. """
template_name = 'auth/token.html'
form_class = TokenCreationForm
Expand Down
24 changes: 12 additions & 12 deletions ddm/datadonation/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from ddm.datadonation.forms import BlueprintEditForm, ProcessingRuleInlineFormset
from ddm.datadonation.models import DonationBlueprint, DonationInstruction, FileUploader
from ddm.projects.models import DonationProject
from ddm.projects.views import DdmAuthMixin
from ddm.projects.views import DDMAuthMixin


class BlueprintMixin:
Expand All @@ -28,7 +28,7 @@ def get_success_url(self):
kwargs={'project_pk': self.kwargs['project_pk']})


class DataDonationOverview(DdmAuthMixin, BlueprintMixin, ListView):
class DataDonationOverview(DDMAuthMixin, BlueprintMixin, ListView):
""" View to list all file uploaders associated with a project. """
model = FileUploader
context_object_name = 'file_uploaders'
Expand All @@ -44,7 +44,7 @@ def get_queryset(self):
return queryset


class FileUploaderCreate(SuccessMessageMixin, DdmAuthMixin, BlueprintMixin, CreateView):
class FileUploaderCreate(SuccessMessageMixin, DDMAuthMixin, BlueprintMixin, CreateView):
""" View to create a new file uploader. """
model = FileUploader
template_name = 'datadonation/uploader/create.html'
Expand All @@ -63,7 +63,7 @@ def get_success_url(self):
return reverse('datadonation:uploaders:edit', kwargs=kwargs)


class FileUploaderEdit(SuccessMessageMixin, DdmAuthMixin, BlueprintMixin, UpdateView):
class FileUploaderEdit(SuccessMessageMixin, DDMAuthMixin, BlueprintMixin, UpdateView):
""" View to edit the details of an existing file uploader. """
model = FileUploader
template_name = 'datadonation/uploader/edit.html'
Expand Down Expand Up @@ -113,7 +113,7 @@ def form_valid(self, form, selected_blueprints):
return HttpResponseRedirect(self.get_success_url())


class FileUploaderDelete(SuccessMessageMixin, DdmAuthMixin, BlueprintMixin, DeleteView):
class FileUploaderDelete(SuccessMessageMixin, DDMAuthMixin, BlueprintMixin, DeleteView):
""" View to delete an existing blueprint uploader. """
model = FileUploader
template_name = 'datadonation/uploader/delete.html'
Expand All @@ -123,7 +123,7 @@ def get_success_message(self, cleaned_data):
return self.success_message % self.object.name


class BlueprintCreate(SuccessMessageMixin, DdmAuthMixin, BlueprintMixin, CreateView):
class BlueprintCreate(SuccessMessageMixin, DDMAuthMixin, BlueprintMixin, CreateView):
""" View to create a new donation blueprint. """
model = DonationBlueprint
template_name = 'datadonation/blueprint/create.html'
Expand All @@ -145,7 +145,7 @@ def get_success_url(self):
kwargs={'project_pk': self.object.project.pk, 'pk': self.object.pk})


class BlueprintEdit(SuccessMessageMixin, DdmAuthMixin, BlueprintMixin, UpdateView):
class BlueprintEdit(SuccessMessageMixin, DDMAuthMixin, BlueprintMixin, UpdateView):
""" View to edit the details of an existing donation blueprint. """
model = DonationBlueprint
template_name = 'datadonation/blueprint/edit.html'
Expand Down Expand Up @@ -187,7 +187,7 @@ def form_invalid(self, form, formset):
return self.render_to_response(self.get_context_data(form=form, formset=formset))


class BlueprintDelete(SuccessMessageMixin, DdmAuthMixin, BlueprintMixin, DeleteView):
class BlueprintDelete(SuccessMessageMixin, DDMAuthMixin, BlueprintMixin, DeleteView):
""" View to delete an existing donation blueprint. """
model = DonationBlueprint
template_name = 'datadonation/blueprint/delete.html'
Expand All @@ -210,7 +210,7 @@ def get_success_url(self):
return reverse('datadonation:instructions:overview', kwargs=kwargs)


class InstructionOverview(DdmAuthMixin, InstructionMixin, ListView):
class InstructionOverview(DDMAuthMixin, InstructionMixin, ListView):
""" View to create a new instruction page. """
model = DonationInstruction
context_object_name = 'instructions'
Expand All @@ -222,7 +222,7 @@ def get_queryset(self):
return queryset


class InstructionCreate(SuccessMessageMixin, DdmAuthMixin, InstructionMixin, CreateView):
class InstructionCreate(SuccessMessageMixin, DDMAuthMixin, InstructionMixin, CreateView):
""" View to create an instruction page. """
model = DonationInstruction
template_name = 'datadonation/instructions/create.html'
Expand All @@ -245,15 +245,15 @@ def get_initial(self):
return initial


class InstructionEdit(SuccessMessageMixin, DdmAuthMixin, InstructionMixin, UpdateView):
class InstructionEdit(SuccessMessageMixin, DDMAuthMixin, InstructionMixin, UpdateView):
""" View to edit an instruction page. """
model = DonationInstruction
template_name = 'datadonation/instructions/edit.html'
fields = ['text', 'index']
success_message = 'Instruction page was successfully updated.'


class InstructionDelete(SuccessMessageMixin, DdmAuthMixin, InstructionMixin, DeleteView):
class InstructionDelete(SuccessMessageMixin, DDMAuthMixin, InstructionMixin, DeleteView):
""" View to delete an instruction page. """
model = DonationInstruction
template_name = 'datadonation/instructions/delete.html'
Expand Down
4 changes: 2 additions & 2 deletions ddm/logging/views.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from django.contrib.messages.views import SuccessMessageMixin
from django.views.generic import TemplateView

from ddm.auth.views import DdmAuthMixin
from ddm.auth.views import DDMAuthMixin
from ddm.projects.models import DonationProject


class ProjectLogsView(SuccessMessageMixin, DdmAuthMixin, TemplateView):
class ProjectLogsView(SuccessMessageMixin, DDMAuthMixin, TemplateView):
""" View that lists all exceptions related to a project. """
template_name = 'logging/overview.html'

Expand Down
16 changes: 8 additions & 8 deletions ddm/projects/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

from ddm.projects.forms import ProjectCreateForm, ProjectEditForm, BriefingEditForm, DebriefingEditForm
from ddm.projects.models import DonationProject, ResearchProfile
from ddm.auth.views import DdmAuthMixin
from ddm.auth.views import DDMAuthMixin


class ProjectList(DdmAuthMixin, ListView):
class ProjectList(DDMAuthMixin, ListView):
""" View to display a list of existing donation projects. """
model = DonationProject
template_name = 'projects/list.html'
Expand All @@ -18,7 +18,7 @@ def get_queryset(self):
return DonationProject.objects.filter(owner__user=self.request.user)


class ProjectCreate(SuccessMessageMixin, DdmAuthMixin, CreateView):
class ProjectCreate(SuccessMessageMixin, DDMAuthMixin, CreateView):
""" View to create a new donation project. """
model = DonationProject
template_name = 'projects/create.html'
Expand All @@ -35,21 +35,21 @@ def form_valid(self, form):
return super().form_valid(form)


class ProjectDetail(DdmAuthMixin, DetailView):
class ProjectDetail(DDMAuthMixin, DetailView):
""" View to display landing page for project. """
model = DonationProject
template_name = 'projects/detail.html'


class ProjectEdit(SuccessMessageMixin, DdmAuthMixin, UpdateView):
class ProjectEdit(SuccessMessageMixin, DDMAuthMixin, UpdateView):
""" View to edit the details of an existing donation project. """
model = DonationProject
template_name = 'projects/edit.html'
form_class = ProjectEditForm
success_message = 'Project details successfully updated.'


class ProjectDelete(SuccessMessageMixin, DdmAuthMixin, DeleteView):
class ProjectDelete(SuccessMessageMixin, DDMAuthMixin, DeleteView):
""" View to display a list of existing donation projects. """
model = DonationProject
template_name = 'projects/delete.html'
Expand All @@ -60,15 +60,15 @@ def get_success_message(self, cleaned_data):
return self.success_message % self.object.name


class BriefingEdit(SuccessMessageMixin, DdmAuthMixin, UpdateView):
class BriefingEdit(SuccessMessageMixin, DDMAuthMixin, UpdateView):
""" View to edit the briefing page. """
model = DonationProject
template_name = 'projects/edit-briefing.html'
form_class = BriefingEditForm
success_message = 'Briefing page successfully updated.'


class DebriefingEdit(SuccessMessageMixin, DdmAuthMixin, UpdateView):
class DebriefingEdit(SuccessMessageMixin, DDMAuthMixin, UpdateView):
""" View to edit the debriefing page. """
model = DonationProject
template_name = 'projects/edit-debriefing.html'
Expand Down
14 changes: 7 additions & 7 deletions ddm/questionnaire/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from django_ckeditor_5.widgets import CKEditor5Widget

from ddm.auth.views import DdmAuthMixin
from ddm.auth.views import DDMAuthMixin
from ddm.datadonation.models import DonationBlueprint
from ddm.projects.models import DonationProject
from ddm.questionnaire.models import (
Expand All @@ -28,7 +28,7 @@ def get_project(self):
return DonationProject.objects.get(pk=self.kwargs['project_pk'])


class QuestionnaireOverview(ProjectMixin, DdmAuthMixin, ListView):
class QuestionnaireOverview(ProjectMixin, DDMAuthMixin, ListView):
""" View to list all donation blueprints associated with a project. """
model = DonationBlueprint
context_object_name = 'donation_blueprints'
Expand Down Expand Up @@ -90,7 +90,7 @@ def get_context_data(self, **kwargs):
return context


class QuestionCreate(SuccessMessageMixin, DdmAuthMixin, QuestionFormMixin, CreateView):
class QuestionCreate(SuccessMessageMixin, DDMAuthMixin, QuestionFormMixin, CreateView):
""" View to create question. """
template_name = 'questionnaire/create.html'
success_message = 'New %(question_type)s was created.'
Expand Down Expand Up @@ -122,7 +122,7 @@ def get_success_message(self, cleaned_data):
)


class QuestionEdit(SuccessMessageMixin, DdmAuthMixin, QuestionFormMixin, UpdateView):
class QuestionEdit(SuccessMessageMixin, DDMAuthMixin, QuestionFormMixin, UpdateView):
""" View to edit question. """
model = QuestionBase
template_name = 'questionnaire/edit.html'
Expand All @@ -137,7 +137,7 @@ def get_success_url(self):
return reverse('questionnaire:edit', kwargs=success_kwargs)


class QuestionDelete(SuccessMessageMixin, DdmAuthMixin, ProjectMixin, DeleteView):
class QuestionDelete(SuccessMessageMixin, DDMAuthMixin, ProjectMixin, DeleteView):
""" View to delete question. """
model = QuestionBase
template_name = 'questionnaire/delete.html'
Expand Down Expand Up @@ -189,7 +189,7 @@ def get_excluded_fields(self):
return excluded_fields


class ItemEdit(SuccessMessageMixin, DdmAuthMixin, InlineFormsetMixin, UpdateView):
class ItemEdit(SuccessMessageMixin, DDMAuthMixin, InlineFormsetMixin, UpdateView):
""" View to edit the items associated with a question. """
model = QuestionBase
formset_model = QuestionItem
Expand All @@ -207,7 +207,7 @@ def get_success_url(self):
return reverse('questionnaire:items', kwargs=success_kwargs)


class ScaleEdit(SuccessMessageMixin, DdmAuthMixin, InlineFormsetMixin, UpdateView):
class ScaleEdit(SuccessMessageMixin, DDMAuthMixin, InlineFormsetMixin, UpdateView):
""" View to edit the scale associated with a question. """
model = QuestionBase
formset_model = ScalePoint
Expand Down

0 comments on commit 540afec

Please sign in to comment.