mirror of
				https://gitlab.crans.org/bde/nk20
				synced 2025-11-04 09:12:11 +01:00 
			
		
		
		
	Prepare weekly reports
This commit is contained in:
		@@ -17,6 +17,7 @@ class ProfileInline(admin.StackedInline):
 | 
			
		||||
    Inline user profile in user admin
 | 
			
		||||
    """
 | 
			
		||||
    model = Profile
 | 
			
		||||
    form = ProfileForm
 | 
			
		||||
    can_delete = False
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -25,7 +26,6 @@ class CustomUserAdmin(UserAdmin):
 | 
			
		||||
    inlines = (ProfileInline,)
 | 
			
		||||
    list_display = ('username', 'email', 'first_name', 'last_name', 'is_staff')
 | 
			
		||||
    list_select_related = ('profile',)
 | 
			
		||||
    form = ProfileForm
 | 
			
		||||
 | 
			
		||||
    def get_inline_instances(self, request, obj=None):
 | 
			
		||||
        """
 | 
			
		||||
 
 | 
			
		||||
@@ -37,6 +37,7 @@ class ProfileForm(forms.ModelForm):
 | 
			
		||||
    """
 | 
			
		||||
    A form for the extras field provided by the :model:`member.Profile` model.
 | 
			
		||||
    """
 | 
			
		||||
    last_report = forms.DateField(required=False, disabled=True, label=_("Last report date"))
 | 
			
		||||
 | 
			
		||||
    def save(self, commit=True):
 | 
			
		||||
        if not self.instance.section or (("department" in self.changed_data
 | 
			
		||||
 
 | 
			
		||||
@@ -11,6 +11,7 @@ from django.db import models
 | 
			
		||||
from django.db.models import Q
 | 
			
		||||
from django.template import loader
 | 
			
		||||
from django.urls import reverse, reverse_lazy
 | 
			
		||||
from django.utils import timezone
 | 
			
		||||
from django.utils.encoding import force_bytes
 | 
			
		||||
from django.utils.http import urlsafe_base64_encode
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
@@ -92,6 +93,16 @@ class Profile(models.Model):
 | 
			
		||||
        default=False,
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    report_frequency = models.PositiveSmallIntegerField(
 | 
			
		||||
        verbose_name=_("report frequency (in days)"),
 | 
			
		||||
        default=0,
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    last_report = models.DateField(
 | 
			
		||||
        verbose_name=_("last report date"),
 | 
			
		||||
        default=timezone.now,
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    email_confirmed = models.BooleanField(
 | 
			
		||||
        verbose_name=_("email confirmed"),
 | 
			
		||||
        default=False,
 | 
			
		||||
 
 | 
			
		||||
@@ -71,6 +71,8 @@ class UserUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, UpdateView):
 | 
			
		||||
 | 
			
		||||
        context['profile_form'] = self.profile_form(instance=context['user_object'].profile,
 | 
			
		||||
                                                    data=self.request.POST if self.request.POST else None)
 | 
			
		||||
        if not self.object.profile.report_frequency:
 | 
			
		||||
            del context['profile_form'].fields["last_report"]
 | 
			
		||||
 | 
			
		||||
        return context
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user