From aa19e8b67c80ec067918d1297b1744c42b275219 Mon Sep 17 00:00:00 2001 From: Lorenz Zahn <lorenz.zahn@student.uni-halle.de> Date: Tue, 11 Jul 2023 12:12:11 +0200 Subject: [PATCH] More docutmentation --- .../workhours/accounting/new_users/__init__.py | 5 +++++ app/vkk/workhours/accounting/new_users/forms.py | 14 ++++++++++++++ app/vkk/workhours/accounting/new_users/urls.py | 4 ++++ .../accounting/salary-levels/__init__.py | 5 +++++ .../workhours/accounting/salary-levels/urls.py | 4 ++++ app/vkk/workhours/accounting/users/__init__.py | 5 +++++ app/vkk/workhours/accounting/users/urls.py | 6 +++++- app/vkk/workhours/accounting/users/views.py | 16 ++++++++++++++++ 8 files changed, 58 insertions(+), 1 deletion(-) diff --git a/app/vkk/workhours/accounting/new_users/__init__.py b/app/vkk/workhours/accounting/new_users/__init__.py index e69de29b..e2dc6f77 100644 --- a/app/vkk/workhours/accounting/new_users/__init__.py +++ b/app/vkk/workhours/accounting/new_users/__init__.py @@ -0,0 +1,5 @@ +""" +This module contains the utilities associated with the management of new users. + +This module's substructure closely resembles the path substructure of the website. +""" \ No newline at end of file diff --git a/app/vkk/workhours/accounting/new_users/forms.py b/app/vkk/workhours/accounting/new_users/forms.py index 115fdaa1..4045e72e 100644 --- a/app/vkk/workhours/accounting/new_users/forms.py +++ b/app/vkk/workhours/accounting/new_users/forms.py @@ -1,15 +1,26 @@ +""" +A collection of forms used in this module. +""" + from django.forms import ModelForm from datetime import date, timedelta from vkk.generic.forms import CustomDateInput from vkk.users.models import NewUser, send_renew_mail class NewUserRenewForm(ModelForm): + """ + A class based `View` providing functionality for extending the expiration date for a + user to register. + """ class Meta: model = NewUser fields = ['expiration_date'] widgets = {'expiration_date' : CustomDateInput} def __init__(self, *args, **kwargs): + """ + Creates and returns a new object of this class. + """ if ( kwargs.get('initial') is None or kwargs['initial'].get('expiration_date') is None ): kwargs['initial'] = { @@ -18,5 +29,8 @@ class NewUserRenewForm(ModelForm): super().__init__(*args, **kwargs) def save(self, commit=True): + """ + Saves and returns a `NewUser` associated with this `Form` class object. + """ send_renew_mail(self.instance) return super().save(commit) diff --git a/app/vkk/workhours/accounting/new_users/urls.py b/app/vkk/workhours/accounting/new_users/urls.py index acf15934..39f79435 100644 --- a/app/vkk/workhours/accounting/new_users/urls.py +++ b/app/vkk/workhours/accounting/new_users/urls.py @@ -1,3 +1,7 @@ +""" +This submodule contains the routing configuration. +""" + from django.urls import path from django.utils.translation import gettext_lazy as _ from vkk.workhours.accounting.views import AccountingFilterView, AccountingSuccessView, AccountingUpdateView diff --git a/app/vkk/workhours/accounting/salary-levels/__init__.py b/app/vkk/workhours/accounting/salary-levels/__init__.py index e69de29b..6fe78363 100644 --- a/app/vkk/workhours/accounting/salary-levels/__init__.py +++ b/app/vkk/workhours/accounting/salary-levels/__init__.py @@ -0,0 +1,5 @@ +""" +This module contains the utilities associated with the management of salary levels. + +This module's substructure closely resembles the path substructure of the website. +""" \ No newline at end of file diff --git a/app/vkk/workhours/accounting/salary-levels/urls.py b/app/vkk/workhours/accounting/salary-levels/urls.py index d19a1a56..b7181848 100644 --- a/app/vkk/workhours/accounting/salary-levels/urls.py +++ b/app/vkk/workhours/accounting/salary-levels/urls.py @@ -1,3 +1,7 @@ +""" +This submodule contains the routing configuration. +""" + from django.urls import path from django.utils.translation import gettext_lazy as _ from ..views import * diff --git a/app/vkk/workhours/accounting/users/__init__.py b/app/vkk/workhours/accounting/users/__init__.py index e69de29b..0c8ad2e8 100644 --- a/app/vkk/workhours/accounting/users/__init__.py +++ b/app/vkk/workhours/accounting/users/__init__.py @@ -0,0 +1,5 @@ +""" +This module contains the utilities associated with the management of users. + +This module's substructure closely resembles the path substructure of the website. +""" \ No newline at end of file diff --git a/app/vkk/workhours/accounting/users/urls.py b/app/vkk/workhours/accounting/users/urls.py index b908e722..95bdf8cb 100644 --- a/app/vkk/workhours/accounting/users/urls.py +++ b/app/vkk/workhours/accounting/users/urls.py @@ -1,3 +1,7 @@ +""" +This submodule contains the routing configuration. +""" + from django.urls import path from django.utils.translation import gettext_lazy as _ from ..views import * @@ -64,4 +68,4 @@ urlpatterns = [ ), name='default' ), -] +] \ No newline at end of file diff --git a/app/vkk/workhours/accounting/users/views.py b/app/vkk/workhours/accounting/users/views.py index fe852deb..45874dec 100644 --- a/app/vkk/workhours/accounting/users/views.py +++ b/app/vkk/workhours/accounting/users/views.py @@ -1,13 +1,23 @@ +""" +This submodule contains all fo the class based views of this module. +""" + from smtplib import SMTPException from vkk.workhours.accounting.views import AccountingCreateView, AccountingDetailView from vkk.users.models import User, NewUser, send_registration_mail from vkk.workhours.models import ProjectAssignment, ProjectManager class UserCreateView(AccountingCreateView): + """ + A class based view providing functionality for creating new `User`s. + """ model = User fields = ['first_name', 'last_name', 'email'] def form_valid(self, form): + """ + Saves the asscoated `Form` data and returns said instance. + """ user = form.instance user.set_unusable_password() response = super().form_valid(form) @@ -19,11 +29,17 @@ class UserCreateView(AccountingCreateView): return response class AccountingUserDetailView(AccountingDetailView): + """ + A class based `View` providing functionality for displaying a `User`s details. + """ template_name = 'vkk/workhours/accounting/users/details.html' model = User fields = ['first_name', 'last_name', 'email', 'last_login', 'is_accountant', 'is_active'] def get_context_data(self, **kwargs): + """ + Returns a context for rendering a page containg user details. + """ context = super().get_context_data(**kwargs) manages = ProjectManager.objects.filter( manager__pk=self.kwargs['pk'] -- GitLab