vkk.workhours.models

This module contains the data models associated with the management of work hours, projects, project managers, departments, etc.

  1"""
  2This module contains the data models associated with the management of work hours,
  3projects, project managers, departments, etc.
  4"""
  5
  6from datetime import datetime, timedelta, date
  7from django.db import models
  8from django.conf import settings
  9from django.utils.timezone import template_localtime, now, make_aware
 10from django.utils.formats import date_format
 11from django.utils.text import format_lazy
 12from django.core.exceptions import ValidationError
 13from django.core.validators import MinValueValidator, MaxValueValidator
 14from django.utils.translation import gettext_lazy as _
 15
 16
 17class Department(models.Model):
 18    """
 19    `Model` for Departments
 20    """
 21    name = models.CharField(
 22        verbose_name=_('name'),
 23        max_length=255,
 24    )
 25    accounting_entry = models.CharField(
 26        verbose_name=_('accounting entry'),
 27        max_length=7,
 28        unique=True
 29    )
 30    invoice_number = models.IntegerField(
 31        null=True,
 32        verbose_name=_('invoice number'),
 33    )
 34
 35    def __str__(self):
 36        """
 37        Returns a string representation of this `Department` instance.
 38        """
 39        return str(self.name)
 40
 41    class Meta:
 42        """
 43        Meta information associated with the `Department` class.
 44        """
 45        verbose_name = _('department')
 46        verbose_name_plural = _('departments')
 47        default_permissions = ()
 48
 49
 50class Project(models.Model):
 51    """
 52    A `Model` subclass to track projects.
 53    """
 54    invoice_number = models.IntegerField(
 55        verbose_name=_('invoice number'),
 56        unique=True,
 57        validators=[
 58            MinValueValidator(20000000),
 59            MaxValueValidator(39999999),
 60        ],
 61        help_text=_(
 62            'Identifier for invoice as number between 20000000 and 39999999.')
 63    )
 64    name = models.CharField(
 65        verbose_name=_('name'),
 66        max_length=255
 67    )
 68    contractor = models.CharField(
 69        verbose_name=_('contractor'),
 70        max_length=255
 71    )
 72    start = models.DateField(
 73        verbose_name=_('start date'),
 74    )
 75    end = models.DateField(
 76        verbose_name=_('end date'),
 77    )
 78    department = models.ForeignKey(
 79        Department,
 80        on_delete=models.SET_NULL,
 81        null=True,
 82        verbose_name=_('department')
 83    )
 84
 85    def clean_fields(self, exclude=None):
 86        """
 87        Cleans and validates the fields associated with this instance.
 88        This will raise a `ValidationError` on failure.
 89        """
 90        super().clean_fields(exclude)
 91        if (not exclude or 'end' not in exclude) and self.start > self.end:
 92            raise ValidationError({
 93                'end': ValidationError(
 94                    _('The end date must be after the start date.'),
 95                    code='invalid_dates'
 96                )
 97            })
 98
 99    def __str__(self):
100        """
101        Returns a string representation of this `Project` instance.
102        """
103        return str(self.name)
104
105    class Meta:
106        """
107        Meta information associated with the `Project` class.
108        """
109        verbose_name = _('project')
110        verbose_name_plural = _('projects')
111        default_permissions = ()
112        constraints = [
113            models.CheckConstraint(
114                check=models.Q(start__lte=models.F('end')),
115                name='runtime_check_projekt'
116            ),
117            models.CheckConstraint(
118                check=models.Q(invoice_number__gte=20000000) & models.Q(
119                    invoice_number__lte=39999999),
120                name='invoice_number_intervall_check'
121            )
122        ]
123
124
125class ProjectManager(models.Model):
126    """
127    A model for tracking user in role of project managers.
128    """
129    manager = models.ForeignKey(
130        to=settings.AUTH_USER_MODEL,
131        verbose_name=_('manager'),
132        on_delete=models.CASCADE,
133    )
134    project = models.ForeignKey(
135        to=Project,
136        on_delete=models.CASCADE,
137        verbose_name=_('project')
138    )
139    start = models.DateField(
140        verbose_name=_('start date'),
141    )
142    end = models.DateField(
143        verbose_name=_('end date')
144    )
145    is_proxy = models.BooleanField(
146        verbose_name=_('proxy'),
147        default=False,
148        help_text=_(
149            'Designates whether management rights are given to the user'
150            'for administrative uses only.'
151        ),
152    )
153
154    def clean_fields(self, exclude=None):
155        """
156        Cleans and validates the fields associated with this instance.
157        This will raise a `ValidationError` on failure.
158        """
159        super().clean_fields(exclude)
160        if (not exclude or 'end' not in exclude) and self.start > self.end:
161            raise ValidationError({
162                'end': ValidationError(
163                    _('The end date must be after the start date.'),
164                    code='invalid_dates'
165                )
166            })
167
168    class Meta:
169        """
170        Meta information associated with the `ProjectManager` class.
171        """
172        verbose_name = _('project manager')
173        verbose_name_plural = _('project managers')
174        default_permissions = ()
175        constraints = [
176            models.CheckConstraint(
177                check=models.Q(start__lte=models.F('end')),
178                name='runtime_check_manager'
179            ),
180            models.UniqueConstraint(
181                fields=['manager', 'project'],
182                name='unique_constraint_project_manager',
183            )
184        ]
185
186
187class SalaryLevel(models.Model):
188    """
189    A `Model` subclass to track salary levels.
190    """
191    salary_code = models.CharField(
192        verbose_name=_('salary code'),
193        max_length=15,
194        unique=True
195    )
196
197    class Meta:
198        """
199        Meta information associated with the `ProjectManager` class.
200        """
201        verbose_name = _('salary level')
202        verbose_name_plural = _('salary levels')
203        default_permissions = ()
204
205    def __str__(self):
206        """
207        Returns a string representation of this `SalaryLevel` instance.
208        """
209        return str(self.salary_code)
210
211
212class ProjectAssignment(models.Model):
213    """
214    A `Model` subclass to track users assigned to projects.
215    """
216    contributor = models.ForeignKey(
217        to=settings.AUTH_USER_MODEL,
218        on_delete=models.CASCADE,
219        verbose_name=_('contributor'),
220    )
221    salary_level = models.ForeignKey(
222        to=SalaryLevel,
223        on_delete=models.RESTRICT,
224        verbose_name=_('salary level'),
225    )
226    project = models.ForeignKey(
227        to=Project,
228        on_delete=models.CASCADE,
229        verbose_name=_('project')
230    )
231
232    class Meta:
233        """
234        Meta information associated with the `ProjectAssignment` class.
235        """
236        verbose_name = _('project assignment')
237        verbose_name_plural = _('project assignments')
238        default_permissions = ()
239        constraints = [
240            models.UniqueConstraint(
241                fields=['contributor', 'salary_level', 'project'],
242                name='unique_constraint_project_assignment',
243            )
244        ]
245
246
247class PeriodManager(models.Manager):
248    """
249    Manager class for `Period`s.
250    """
251
252    def latest(self, *fields, create=False):
253        """
254        Returns the latest `Period` from the database.
255        Extends `latest()` to allow automatic creation of a valid periods.
256        """
257        if create:
258            latest = None
259            today = now().date()
260            try:
261                latest = super().latest(*fields)
262            except Period.DoesNotExist:
263                start = today.replace(day=1)
264            if latest and latest.end < today:
265                start = latest.end + timedelta(days=1)
266            if not latest or latest.end < today:
267                end = (
268                    (start.replace(day=1) + timedelta(days=32)).replace(day=1)
269                ) - timedelta(days=1)
270                dead_line = make_aware(
271                    datetime.combine(
272                        (end + timedelta(days=32)).replace(day=1),
273                        datetime.min.time()
274                    ) - timedelta(microseconds=1)
275                )
276                latest = self.create(
277                    start=start,
278                    end=end,
279                    dead_line=dead_line,
280                    dead_line_final=dead_line
281                )
282            if latest.end < today:
283                return self.latest(*fields, create=create)
284            else:
285                return latest
286        else:
287            return super().latest(*fields)
288
289
290class Period(models.Model):
291    """
292    A `Model` subclass to track time periods.
293    """
294    start = models.DateField(
295        verbose_name=_('start date')
296    )
297    end = models.DateField(
298        verbose_name=_('end date')
299    )
300    dead_line = models.DateTimeField(
301        verbose_name=_('dead line')
302    )
303    dead_line_final = models.DateTimeField(
304        verbose_name=_('final dead line')
305    )
306
307    def clean_fields(self, exclude=None):
308        """
309        Cleans and validates the fields associated with this instance.
310        This will raise a `ValidationError` on failure.
311        """
312        super().clean_fields(exclude)
313        if (not exclude or 'end' not in exclude) and self.start > self.end:
314            raise ValidationError({
315                'end': ValidationError(
316                    _('The end date must be after the start date.'),
317                    code='invalid_dates'
318                )
319            })
320        if (not exclude or 'dead_line' not in exclude) and self.end > self.dead_line.date():
321            raise ValidationError({
322                'dead_line': ValidationError(
323                    _('The dead line must be after the end date.'),
324                    code='invalid_dead_line'
325                )
326            })
327        if (not exclude or 'dead_line_final' not in exclude) and self.dead_line.date() > self.dead_line_final.date():
328            raise ValidationError({
329                'dead_line_final': ValidationError(
330                    _('The final dead line cannot be before the dead line.'),
331                    code='invalid_dead_line_final'
332                )
333            })
334
335    def __str__(self):
336        """
337        Returns a string representation of this `Period` instance.
338        """
339        start = date_format(
340            self.start, format='SHORT_DATE_FORMAT', use_l10n=True)
341        end = date_format(self.end, format='SHORT_DATE_FORMAT', use_l10n=True)
342        dead_line = date_format(
343            template_localtime(self.dead_line),
344            format='SHORT_DATETIME_FORMAT', use_l10n=True
345        )
346        return '%s - %s ( %s )' % (start, end, dead_line)
347
348    objects = PeriodManager()
349
350    class Meta:
351        """
352        Meta information associated with the `Period` class.
353        """
354        verbose_name = _('period')
355        verbose_name_plural = _('periods')
356        default_permissions = ()
357        constraints = [
358            models.CheckConstraint(
359                check=models.Q(start__lte=models.F('end')),
360                name='runtime_check_period'
361            ),
362            models.CheckConstraint(
363                check=models.Q(end__lte=models.F('dead_line')),
364                name='dead_line_check_period'
365            ),
366            models.CheckConstraint(
367                check=models.Q(dead_line__lte=models.F('dead_line_final')),
368                name='dead_line_final_check_period'
369            )
370        ]
371        get_latest_by = 'start'
372
373
374class PeriodClosure(models.Model):
375    """
376    A `Model` subclass to track whether a user or manager, assigned to a project, has permission to
377    add, change or delete work hour records for a given period.
378    """
379    period = models.ForeignKey(
380        to=Period,
381        on_delete=models.CASCADE,
382        verbose_name=('period')
383    )
384    project_assignment = models.ForeignKey(
385        to=ProjectAssignment,
386        on_delete=models.CASCADE,
387        verbose_name=('project assignment')
388    )
389    is_closed_contributor = models.BooleanField(
390        default=False,
391        verbose_name=('closed for contributor')
392    )
393    is_closed_manager = models.BooleanField(
394        default=False,
395        verbose_name=('closed for manager')
396    )
397
398    class Meta:
399        """
400        Meta information associated with the `PeriodClosure` class.
401        """
402        verbose_name = _('period')
403        verbose_name_plural = _('periods')
404        default_permissions = ()
405        constraints = [
406            models.UniqueConstraint(
407                fields=['period', 'project_assignment'],
408                name='unique_constraint_period_closure',
409            )
410        ]
411
412
413class WorkHours(models.Model):
414    """
415    A `Model` subclass to keep track of work hours.
416    """
417    project_assignment = models.ForeignKey(
418        to=ProjectAssignment,
419        on_delete=models.RESTRICT,
420        verbose_name=_('project assignment'),
421    )
422    period = models.ForeignKey(
423        to=Period,
424        on_delete=models.RESTRICT,
425        verbose_name=_('period')
426    )
427    day = models.DateField(
428        verbose_name=_('work day'),
429        help_text=_('Date of work day.')
430    )
431    hours = models.DecimalField(
432        max_digits=4,
433        decimal_places=2,
434        validators=[
435            MinValueValidator(0.01),
436            MaxValueValidator(24),
437        ],
438        verbose_name=_('work hours'),
439        help_text=_('Number of hours worked with '
440                    'precision up to two decimal places.'),
441    )
442
443    def clean_fields(self, exclude=None):
444        """
445        Cleans and validates the fields associated with this instance.
446        This will raise a `ValidationError` on failure.
447        """
448        super().clean_fields(exclude)
449        # Constraints over foreign keys do not work at this point in time
450        if not exclude or 'day' not in exclude:
451            if self.period.start < self.day or self.day > self.period.end:
452                raise ValidationError({
453                    'day': ValidationError(
454                        _('Work day is not between the start and end'
455                          'date of the given period.'),
456                        code='invalid_day'
457                    )
458                })
459        if not exclude or 'project_assignment' not in exclude:
460            if self.day < self.project_assignment.project.start or self.day > self.project_assignment.project.end:
461                raise ValidationError({
462                    'project_assignment': ValidationError(
463                        _('Work day is not within the start and end'
464                          'date of the given project.'),
465                        code='invalid_day'
466                    )
467                })
468
469    class Meta:
470        """
471        Meta information associated with the `WorkHours` class.
472        """
473        verbose_name = _('work hours')
474        verbose_name_plural = _('work hours')
475        default_permissions = ()
476        constraints = [
477            models.UniqueConstraint(
478                fields=['project_assignment', 'day'],
479                name='unique_constraint_work_hours',
480            ),
481            models.CheckConstraint(
482                check=models.Q(hours__gt=0.0),
483                name='min_work_hours'
484            ),
485            models.CheckConstraint(
486                check=models.Q(hours__lte=24.0),
487                name='max_work_hours'
488            ),
489        ]
490
491
492class WorkHoursCorrection(models.Model):
493    """
494    A `Model` subclass to keep track of correction to work hour aggregations.
495    """
496    project_assignment = models.ForeignKey(
497        to=ProjectAssignment,
498        on_delete=models.RESTRICT,
499        verbose_name=_('project assignment'),
500    )
501    period = models.ForeignKey(
502        to=Period,
503        on_delete=models.RESTRICT,
504        verbose_name=_('period')
505    )
506    ammount = models.DecimalField(
507        max_digits=5,
508        decimal_places=2,
509        help_text=_('Ammount by which the total number of workhours'
510                    'for a given project assignment and period should be corrected.'),
511    )
512
513    class Meta:
514        """
515        Meta information associated with the `WorkHoursCorrection` class.
516        """
517        verbose_name = _('work hours correction')
518        verbose_name_plural = _('work hours correction')
519        default_permissions = ()
520        constraints = [
521            models.UniqueConstraint(
522                fields=['project_assignment', 'period'],
523                name='unique_constraint_work_hours_correction',
524            ),
525        ]
526
527
528class ProjectFundedStaffDate(models.Model):
529    """
530    A `Model` subclassfor tracking date related information for `ProjectFundedStaff`.
531    """
532    date = models.DateField(
533        verbose_name=_('start date'),
534    )
535    project = models.ForeignKey(
536        'Project',
537        verbose_name=_('project'),
538        on_delete=models.CASCADE,
539    )
540
541    def __str__(self):
542        """
543        Returns a string representation of this `ProjectFundedStaffDate` instance.
544        """
545        date = date_format(
546            self.date, format='SHORT_DATE_FORMAT', use_l10n=True)
547        verbose = self._meta.verbose_name
548        return f"{verbose}: {date}"
549
550    class Meta:
551        """
552        Meta information associated with the `ProjectFundedStaffDate` class.
553        """
554        verbose_name = _('project funded staff interval')
555        verbose_name_plural = _('project funded staff intervals')
556        default_permissions = ()
557        constraints = [
558            models.UniqueConstraint(
559                fields=['date', 'project'],
560                name='unique_constraint_project_funded_staff_date',
561            ),
562        ]
563
564
565class ProjectFundedStaff(models.Model):
566    """
567    A `Model` subclassfor tracking staff associated with a project. (Instead of individual contributors.)
568    """
569    salary_level = models.ForeignKey(
570        'SalaryLevel',
571        verbose_name=_('salary level'),
572        on_delete=models.CASCADE,
573    )
574    start = models.ForeignKey(
575        'ProjectFundedStaffDate',
576        verbose_name=_('start date'),
577        on_delete=models.CASCADE
578    )
579    hours = models.DecimalField(
580        max_digits=8,
581        decimal_places=2,
582    )
583
584    class Meta:
585        """
586        Meta information associated with the `ProjectFundedStaff` class.
587        """
588        verbose_name = _('project funded staff')
589        verbose_name_plural = _('project funded staff')
590        default_permissions = ()
591        constraints = [
592            models.UniqueConstraint(
593                fields=['salary_level', 'start'],
594                name='unique_constraint_project_funded_staff',
595            ),
596        ]
597
598
599class GeneralCosts(models.Model):
600    """
601    A `Model` subclassfor tracking general costs associated with projects.
602    """
603    start = models.DateField(
604        verbose_name=_('start date'),
605    )
606    costs = models.DecimalField(
607        verbose_name=_('general costs'),
608        max_digits=8,
609        decimal_places=2,
610    )
611
612    def __str__(self):
613        """
614        Returns a string representation of this `GeneralCosts` instance.
615        """
616        start = date_format(
617            self.start, format='SHORT_DATE_FORMAT', use_l10n=True)
618        verbose = self._meta.verbose_name
619        return f"{verbose}: {start}"
620
621    class Meta:
622        """
623        Meta information associated with the `GeneralCosts` class.
624        """
625        verbose_name = _('general costs')
626        verbose_name_plural = _('general costs')
627        default_permissions = ()
628        constraints = [
629            models.UniqueConstraint(
630                fields=['start'],
631                name='unique_constraint_general_costs',
632            ),
633        ]
634
635
636class DepartmentDate(models.Model):
637    """
638    A `Model` subclassfor tracking date related information for `DepartmentCosts`.
639    """
640    date = models.DateField(
641        verbose_name=_('start date'),
642    )
643
644    def __str__(self):
645        """
646        Returns a string representation of this `DepartmentDate` instance.
647        """
648        date = date_format(
649            self.date, format='SHORT_DATE_FORMAT', use_l10n=True)
650        verbose = self._meta.verbose_name
651        return f"{verbose}: {date}"
652
653    class Meta:
654        """
655        Meta information associated with the `DepartmentDate` class.
656        """
657        verbose_name = _('department interval')
658        verbose_name_plural = _('department intervals')
659        default_permissions = ()
660        constraints = [
661            models.UniqueConstraint(
662                fields=['date'],
663                name='unique_constraint_department_date',
664            ),
665        ]
666
667
668class DepartmentCosts(models.Model):
669    """
670    A model for tracking costs associated with departments.
671    """
672    department = models.ForeignKey(
673        'Department',
674        verbose_name=_('department'),
675        on_delete=models.CASCADE
676    )
677    start = models.ForeignKey(
678        'DepartmentDate',
679        verbose_name=_('start date'),
680        on_delete=models.CASCADE
681    )
682    equivalents_per_hour = models.DecimalField(
683        verbose_name=_('full time equivalents per hour'),
684        max_digits=8,
685        decimal_places=2,
686    )
687
688    def __str__(self):
689        """
690        Returns a string representation of this `DepartmentCosts` instance.
691        """
692        return f"{self._meta.verbose_name}: {self.pk}"
693
694    class Meta:
695        """
696        Meta information associated with the `DepartmentCosts` class.
697        """
698        verbose_name = _('department costs')
699        verbose_name_plural = _('department costs')
700        default_permissions = ()
701        constraints = [
702            models.UniqueConstraint(
703                fields=['department', 'start'],
704                name='unique_constraint_department_costs',
705            ),
706        ]
707
708
709class SalaryLevelDate(models.Model):
710    """
711    A `Model` subclassfor tracking date related information for `SalaryLevelCosts`.
712    """
713    date = models.DateField(
714        verbose_name=_('start date'),
715    )
716
717    def __str__(self):
718        """
719        Returns a string representation of this `SalaryLevelDate` instance.
720        """
721        date = date_format(
722            self.date, format='SHORT_DATE_FORMAT', use_l10n=True)
723        verbose = self._meta.verbose_name
724        return f"{verbose}: {date}"
725
726    class Meta:
727        """
728        Meta information associated with the `SalaryLevelDate` class.
729        """
730        verbose_name = _('salary interval')
731        verbose_name_plural = _('salary intervals')
732        default_permissions = ()
733        constraints = [
734            models.UniqueConstraint(
735                fields=['date'],
736                name='unique_constraint_salary_level_date',
737            ),
738        ]
739
740
741class SalaryLevelCosts(models.Model):
742    """
743    A `Model` subclassfor tracking costs associated with salary levels.
744    """
745    salary_level = models.ForeignKey(
746        'SalaryLevel',
747        verbose_name=_('salary level'),
748        on_delete=models.CASCADE,
749    )
750    start = models.ForeignKey(
751        'SalaryLevelDate',
752        verbose_name=_('start date'),
753        on_delete=models.CASCADE
754    )
755    brutto_per_hour = models.DecimalField(
756        verbose_name=_('brutto staff costs per hour'),
757        max_digits=8,
758        decimal_places=2,
759    )
760
761    def __str__(self):
762        """
763        Returns a string representation of this `SalaryLevelCosts` instance.
764        """
765        return f"{self._meta.verbose_name}: {self.pk}"
766
767    class Meta:
768        """
769        Meta information associated with the `SalaryLevelCosts` class.
770        """
771        verbose_name = _('salary level costs')
772        verbose_name_plural = _('salary level costs')
773        default_permissions = ()
774        constraints = [
775            models.UniqueConstraint(
776                fields=['salary_level', 'start'],
777                name='unique_constraint_salary_level_costs',
778            ),
779        ]
780
781
782class ReceiptTemplate(models.Model):
783    """
784    A model for keeping track of templates for generating receipts. 
785    """
786    start = models.DateField(
787        verbose_name=_('start date'),
788    )
789    data = models.JSONField()
790
791    def __str__(self):
792        """
793        Returns a string representation of this `ReceiptTemplate` instance.
794        """
795        return f"{self._meta.verbose_name}: {self.start}"
796
797    class Meta:
798        """
799        Meta information associated with the `ReceiptTemplate` class.
800        """
801        default_permissions = ()
802        verbose_name = _('receipt template')
803        verbose_name_plural = ('receipt templates')
804        constraints = [
805            models.UniqueConstraint(
806                fields=['start'],
807                name='unique_constraint_receipt_template_start',
808            ),
809        ]
810
811
812class Receipt(models.Model):
813    """
814    A model for keeping track of receipts. 
815    """
816    start = models.DateField(
817        verbose_name=_('start date'),
818    )
819    end = models.DateField(
820        verbose_name=_('end date'),
821    )
822    create_time = models.DateTimeField(
823        verbose_name=_('time booked'),
824        auto_now=False,
825        auto_now_add=True,
826    )
827    project = models.ForeignKey(
828        'Project',
829        verbose_name=_('project'),
830        on_delete=models.CASCADE,
831    )
832    receipt_number = models.IntegerField(
833        verbose_name=_('receipt number'),
834    )
835    buper = models.IntegerField(
836        verbose_name=_('buper'),
837    )
838
839    data = models.JSONField()
840
841    class Meta:
842        """
843        Meta information associated with the `Receipt` class.
844        """
845        default_permissions = ()
846        verbose_name = _('receipt')
847        verbose_name_plural = ('receipts')
848        constraints = [
849            models.CheckConstraint(
850                check=models.Q(start__lte=models.F('end')),
851                name='interval_check_receipt'
852            ),
853        ]
class Department(django.db.models.base.Model):
18class Department(models.Model):
19    """
20    `Model` for Departments
21    """
22    name = models.CharField(
23        verbose_name=_('name'),
24        max_length=255,
25    )
26    accounting_entry = models.CharField(
27        verbose_name=_('accounting entry'),
28        max_length=7,
29        unique=True
30    )
31    invoice_number = models.IntegerField(
32        null=True,
33        verbose_name=_('invoice number'),
34    )
35
36    def __str__(self):
37        """
38        Returns a string representation of this `Department` instance.
39        """
40        return str(self.name)
41
42    class Meta:
43        """
44        Meta information associated with the `Department` class.
45        """
46        verbose_name = _('department')
47        verbose_name_plural = _('departments')
48        default_permissions = ()

Model for Departments

def name(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def accounting_entry(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def invoice_number(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def id(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def objects(unknown):
project_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

departmentcosts_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

Inherited Members
django.db.models.base.Model
Model
from_db
pk
get_deferred_fields
refresh_from_db
arefresh_from_db
serializable_value
save
asave
save_base
delete
adelete
prepare_database_save
clean
validate_unique
date_error_message
unique_error_message
get_constraints
validate_constraints
full_clean
clean_fields
check
class Department.DoesNotExist(django.core.exceptions.ObjectDoesNotExist):

The requested object does not exist

Inherited Members
builtins.Exception
Exception
django.core.exceptions.ObjectDoesNotExist
silent_variable_failure
builtins.BaseException
with_traceback
add_note
args
class Department.MultipleObjectsReturned(django.core.exceptions.MultipleObjectsReturned):

The query returned multiple objects when only one was expected.

Inherited Members
builtins.Exception
Exception
builtins.BaseException
with_traceback
add_note
args
class Project(django.db.models.base.Model):
 51class Project(models.Model):
 52    """
 53    A `Model` subclass to track projects.
 54    """
 55    invoice_number = models.IntegerField(
 56        verbose_name=_('invoice number'),
 57        unique=True,
 58        validators=[
 59            MinValueValidator(20000000),
 60            MaxValueValidator(39999999),
 61        ],
 62        help_text=_(
 63            'Identifier for invoice as number between 20000000 and 39999999.')
 64    )
 65    name = models.CharField(
 66        verbose_name=_('name'),
 67        max_length=255
 68    )
 69    contractor = models.CharField(
 70        verbose_name=_('contractor'),
 71        max_length=255
 72    )
 73    start = models.DateField(
 74        verbose_name=_('start date'),
 75    )
 76    end = models.DateField(
 77        verbose_name=_('end date'),
 78    )
 79    department = models.ForeignKey(
 80        Department,
 81        on_delete=models.SET_NULL,
 82        null=True,
 83        verbose_name=_('department')
 84    )
 85
 86    def clean_fields(self, exclude=None):
 87        """
 88        Cleans and validates the fields associated with this instance.
 89        This will raise a `ValidationError` on failure.
 90        """
 91        super().clean_fields(exclude)
 92        if (not exclude or 'end' not in exclude) and self.start > self.end:
 93            raise ValidationError({
 94                'end': ValidationError(
 95                    _('The end date must be after the start date.'),
 96                    code='invalid_dates'
 97                )
 98            })
 99
100    def __str__(self):
101        """
102        Returns a string representation of this `Project` instance.
103        """
104        return str(self.name)
105
106    class Meta:
107        """
108        Meta information associated with the `Project` class.
109        """
110        verbose_name = _('project')
111        verbose_name_plural = _('projects')
112        default_permissions = ()
113        constraints = [
114            models.CheckConstraint(
115                check=models.Q(start__lte=models.F('end')),
116                name='runtime_check_projekt'
117            ),
118            models.CheckConstraint(
119                check=models.Q(invoice_number__gte=20000000) & models.Q(
120                    invoice_number__lte=39999999),
121                name='invoice_number_intervall_check'
122            )
123        ]

A Model subclass to track projects.

def invoice_number(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def name(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def contractor(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def start(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def end(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

department

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

def clean_fields(self, exclude=None):
86    def clean_fields(self, exclude=None):
87        """
88        Cleans and validates the fields associated with this instance.
89        This will raise a `ValidationError` on failure.
90        """
91        super().clean_fields(exclude)
92        if (not exclude or 'end' not in exclude) and self.start > self.end:
93            raise ValidationError({
94                'end': ValidationError(
95                    _('The end date must be after the start date.'),
96                    code='invalid_dates'
97                )
98            })

Cleans and validates the fields associated with this instance. This will raise a ValidationError on failure.

def get_next_by_start(unknown):

Method descriptor with partial application of the given arguments and keywords.

Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.

def get_previous_by_start(unknown):

Method descriptor with partial application of the given arguments and keywords.

Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.

def get_next_by_end(unknown):

Method descriptor with partial application of the given arguments and keywords.

Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.

def get_previous_by_end(unknown):

Method descriptor with partial application of the given arguments and keywords.

Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.

department_id
def id(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def objects(unknown):
projectmanager_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

projectassignment_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

projectfundedstaffdate_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

receipt_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

Inherited Members
django.db.models.base.Model
Model
from_db
pk
get_deferred_fields
refresh_from_db
arefresh_from_db
serializable_value
save
asave
save_base
delete
adelete
prepare_database_save
clean
validate_unique
date_error_message
unique_error_message
get_constraints
validate_constraints
full_clean
check
class Project.DoesNotExist(django.core.exceptions.ObjectDoesNotExist):

The requested object does not exist

Inherited Members
builtins.Exception
Exception
django.core.exceptions.ObjectDoesNotExist
silent_variable_failure
builtins.BaseException
with_traceback
add_note
args
class Project.MultipleObjectsReturned(django.core.exceptions.MultipleObjectsReturned):

The query returned multiple objects when only one was expected.

Inherited Members
builtins.Exception
Exception
builtins.BaseException
with_traceback
add_note
args
class ProjectManager(django.db.models.base.Model):
126class ProjectManager(models.Model):
127    """
128    A model for tracking user in role of project managers.
129    """
130    manager = models.ForeignKey(
131        to=settings.AUTH_USER_MODEL,
132        verbose_name=_('manager'),
133        on_delete=models.CASCADE,
134    )
135    project = models.ForeignKey(
136        to=Project,
137        on_delete=models.CASCADE,
138        verbose_name=_('project')
139    )
140    start = models.DateField(
141        verbose_name=_('start date'),
142    )
143    end = models.DateField(
144        verbose_name=_('end date')
145    )
146    is_proxy = models.BooleanField(
147        verbose_name=_('proxy'),
148        default=False,
149        help_text=_(
150            'Designates whether management rights are given to the user'
151            'for administrative uses only.'
152        ),
153    )
154
155    def clean_fields(self, exclude=None):
156        """
157        Cleans and validates the fields associated with this instance.
158        This will raise a `ValidationError` on failure.
159        """
160        super().clean_fields(exclude)
161        if (not exclude or 'end' not in exclude) and self.start > self.end:
162            raise ValidationError({
163                'end': ValidationError(
164                    _('The end date must be after the start date.'),
165                    code='invalid_dates'
166                )
167            })
168
169    class Meta:
170        """
171        Meta information associated with the `ProjectManager` class.
172        """
173        verbose_name = _('project manager')
174        verbose_name_plural = _('project managers')
175        default_permissions = ()
176        constraints = [
177            models.CheckConstraint(
178                check=models.Q(start__lte=models.F('end')),
179                name='runtime_check_manager'
180            ),
181            models.UniqueConstraint(
182                fields=['manager', 'project'],
183                name='unique_constraint_project_manager',
184            )
185        ]

A model for tracking user in role of project managers.

manager

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

project

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

def start(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def end(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def is_proxy(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def clean_fields(self, exclude=None):
155    def clean_fields(self, exclude=None):
156        """
157        Cleans and validates the fields associated with this instance.
158        This will raise a `ValidationError` on failure.
159        """
160        super().clean_fields(exclude)
161        if (not exclude or 'end' not in exclude) and self.start > self.end:
162            raise ValidationError({
163                'end': ValidationError(
164                    _('The end date must be after the start date.'),
165                    code='invalid_dates'
166                )
167            })

Cleans and validates the fields associated with this instance. This will raise a ValidationError on failure.

manager_id
project_id
def get_next_by_start(unknown):

Method descriptor with partial application of the given arguments and keywords.

Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.

def get_previous_by_start(unknown):

Method descriptor with partial application of the given arguments and keywords.

Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.

def get_next_by_end(unknown):

Method descriptor with partial application of the given arguments and keywords.

Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.

def get_previous_by_end(unknown):

Method descriptor with partial application of the given arguments and keywords.

Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.

def id(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def objects(unknown):
Inherited Members
django.db.models.base.Model
Model
from_db
pk
get_deferred_fields
refresh_from_db
arefresh_from_db
serializable_value
save
asave
save_base
delete
adelete
prepare_database_save
clean
validate_unique
date_error_message
unique_error_message
get_constraints
validate_constraints
full_clean
check
class ProjectManager.DoesNotExist(django.core.exceptions.ObjectDoesNotExist):

The requested object does not exist

Inherited Members
builtins.Exception
Exception
django.core.exceptions.ObjectDoesNotExist
silent_variable_failure
builtins.BaseException
with_traceback
add_note
args
class ProjectManager.MultipleObjectsReturned(django.core.exceptions.MultipleObjectsReturned):

The query returned multiple objects when only one was expected.

Inherited Members
builtins.Exception
Exception
builtins.BaseException
with_traceback
add_note
args
class SalaryLevel(django.db.models.base.Model):
188class SalaryLevel(models.Model):
189    """
190    A `Model` subclass to track salary levels.
191    """
192    salary_code = models.CharField(
193        verbose_name=_('salary code'),
194        max_length=15,
195        unique=True
196    )
197
198    class Meta:
199        """
200        Meta information associated with the `ProjectManager` class.
201        """
202        verbose_name = _('salary level')
203        verbose_name_plural = _('salary levels')
204        default_permissions = ()
205
206    def __str__(self):
207        """
208        Returns a string representation of this `SalaryLevel` instance.
209        """
210        return str(self.salary_code)

A Model subclass to track salary levels.

def salary_code(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def id(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def objects(unknown):
projectassignment_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

projectfundedstaff_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

salarylevelcosts_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

Inherited Members
django.db.models.base.Model
Model
from_db
pk
get_deferred_fields
refresh_from_db
arefresh_from_db
serializable_value
save
asave
save_base
delete
adelete
prepare_database_save
clean
validate_unique
date_error_message
unique_error_message
get_constraints
validate_constraints
full_clean
clean_fields
check
class SalaryLevel.DoesNotExist(django.core.exceptions.ObjectDoesNotExist):

The requested object does not exist

Inherited Members
builtins.Exception
Exception
django.core.exceptions.ObjectDoesNotExist
silent_variable_failure
builtins.BaseException
with_traceback
add_note
args
class SalaryLevel.MultipleObjectsReturned(django.core.exceptions.MultipleObjectsReturned):

The query returned multiple objects when only one was expected.

Inherited Members
builtins.Exception
Exception
builtins.BaseException
with_traceback
add_note
args
class ProjectAssignment(django.db.models.base.Model):
213class ProjectAssignment(models.Model):
214    """
215    A `Model` subclass to track users assigned to projects.
216    """
217    contributor = models.ForeignKey(
218        to=settings.AUTH_USER_MODEL,
219        on_delete=models.CASCADE,
220        verbose_name=_('contributor'),
221    )
222    salary_level = models.ForeignKey(
223        to=SalaryLevel,
224        on_delete=models.RESTRICT,
225        verbose_name=_('salary level'),
226    )
227    project = models.ForeignKey(
228        to=Project,
229        on_delete=models.CASCADE,
230        verbose_name=_('project')
231    )
232
233    class Meta:
234        """
235        Meta information associated with the `ProjectAssignment` class.
236        """
237        verbose_name = _('project assignment')
238        verbose_name_plural = _('project assignments')
239        default_permissions = ()
240        constraints = [
241            models.UniqueConstraint(
242                fields=['contributor', 'salary_level', 'project'],
243                name='unique_constraint_project_assignment',
244            )
245        ]

A Model subclass to track users assigned to projects.

contributor

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

salary_level

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

project

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

contributor_id
salary_level_id
project_id
def id(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def objects(unknown):
periodclosure_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

workhours_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

workhourscorrection_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

Inherited Members
django.db.models.base.Model
Model
from_db
pk
get_deferred_fields
refresh_from_db
arefresh_from_db
serializable_value
save
asave
save_base
delete
adelete
prepare_database_save
clean
validate_unique
date_error_message
unique_error_message
get_constraints
validate_constraints
full_clean
clean_fields
check
class ProjectAssignment.DoesNotExist(django.core.exceptions.ObjectDoesNotExist):

The requested object does not exist

Inherited Members
builtins.Exception
Exception
django.core.exceptions.ObjectDoesNotExist
silent_variable_failure
builtins.BaseException
with_traceback
add_note
args
class ProjectAssignment.MultipleObjectsReturned(django.core.exceptions.MultipleObjectsReturned):

The query returned multiple objects when only one was expected.

Inherited Members
builtins.Exception
Exception
builtins.BaseException
with_traceback
add_note
args
class PeriodManager(django.db.models.manager.Manager):
248class PeriodManager(models.Manager):
249    """
250    Manager class for `Period`s.
251    """
252
253    def latest(self, *fields, create=False):
254        """
255        Returns the latest `Period` from the database.
256        Extends `latest()` to allow automatic creation of a valid periods.
257        """
258        if create:
259            latest = None
260            today = now().date()
261            try:
262                latest = super().latest(*fields)
263            except Period.DoesNotExist:
264                start = today.replace(day=1)
265            if latest and latest.end < today:
266                start = latest.end + timedelta(days=1)
267            if not latest or latest.end < today:
268                end = (
269                    (start.replace(day=1) + timedelta(days=32)).replace(day=1)
270                ) - timedelta(days=1)
271                dead_line = make_aware(
272                    datetime.combine(
273                        (end + timedelta(days=32)).replace(day=1),
274                        datetime.min.time()
275                    ) - timedelta(microseconds=1)
276                )
277                latest = self.create(
278                    start=start,
279                    end=end,
280                    dead_line=dead_line,
281                    dead_line_final=dead_line
282                )
283            if latest.end < today:
284                return self.latest(*fields, create=create)
285            else:
286                return latest
287        else:
288            return super().latest(*fields)

Manager class for Periods.

def latest(self, *fields, create=False):
253    def latest(self, *fields, create=False):
254        """
255        Returns the latest `Period` from the database.
256        Extends `latest()` to allow automatic creation of a valid periods.
257        """
258        if create:
259            latest = None
260            today = now().date()
261            try:
262                latest = super().latest(*fields)
263            except Period.DoesNotExist:
264                start = today.replace(day=1)
265            if latest and latest.end < today:
266                start = latest.end + timedelta(days=1)
267            if not latest or latest.end < today:
268                end = (
269                    (start.replace(day=1) + timedelta(days=32)).replace(day=1)
270                ) - timedelta(days=1)
271                dead_line = make_aware(
272                    datetime.combine(
273                        (end + timedelta(days=32)).replace(day=1),
274                        datetime.min.time()
275                    ) - timedelta(microseconds=1)
276                )
277                latest = self.create(
278                    start=start,
279                    end=end,
280                    dead_line=dead_line,
281                    dead_line_final=dead_line
282                )
283            if latest.end < today:
284                return self.latest(*fields, create=create)
285            else:
286                return latest
287        else:
288            return super().latest(*fields)

Returns the latest Period from the database. Extends latest() to allow automatic creation of a valid periods.

Inherited Members
django.db.models.manager.BaseManager
creation_counter
auto_created
use_in_migrations
model
name
deconstruct
check
from_queryset
contribute_to_class
db_manager
db
get_queryset
all
django.db.models.manager.BaseManagerFromQuerySet
aaggregate
abulk_create
abulk_update
acontains
acount
acreate
aearliest
aexists
aexplain
afirst
aget
aget_or_create
aggregate
ain_bulk
aiterator
alast
alatest
alias
annotate
aupdate
aupdate_or_create
bulk_create
bulk_update
complex_filter
contains
count
create
dates
datetimes
defer
difference
distinct
earliest
exclude
exists
explain
extra
filter
first
get
get_or_create
in_bulk
intersection
iterator
last
none
only
order_by
raw
reverse
select_for_update
union
update
update_or_create
using
values
values_list
class Period(django.db.models.base.Model):
291class Period(models.Model):
292    """
293    A `Model` subclass to track time periods.
294    """
295    start = models.DateField(
296        verbose_name=_('start date')
297    )
298    end = models.DateField(
299        verbose_name=_('end date')
300    )
301    dead_line = models.DateTimeField(
302        verbose_name=_('dead line')
303    )
304    dead_line_final = models.DateTimeField(
305        verbose_name=_('final dead line')
306    )
307
308    def clean_fields(self, exclude=None):
309        """
310        Cleans and validates the fields associated with this instance.
311        This will raise a `ValidationError` on failure.
312        """
313        super().clean_fields(exclude)
314        if (not exclude or 'end' not in exclude) and self.start > self.end:
315            raise ValidationError({
316                'end': ValidationError(
317                    _('The end date must be after the start date.'),
318                    code='invalid_dates'
319                )
320            })
321        if (not exclude or 'dead_line' not in exclude) and self.end > self.dead_line.date():
322            raise ValidationError({
323                'dead_line': ValidationError(
324                    _('The dead line must be after the end date.'),
325                    code='invalid_dead_line'
326                )
327            })
328        if (not exclude or 'dead_line_final' not in exclude) and self.dead_line.date() > self.dead_line_final.date():
329            raise ValidationError({
330                'dead_line_final': ValidationError(
331                    _('The final dead line cannot be before the dead line.'),
332                    code='invalid_dead_line_final'
333                )
334            })
335
336    def __str__(self):
337        """
338        Returns a string representation of this `Period` instance.
339        """
340        start = date_format(
341            self.start, format='SHORT_DATE_FORMAT', use_l10n=True)
342        end = date_format(self.end, format='SHORT_DATE_FORMAT', use_l10n=True)
343        dead_line = date_format(
344            template_localtime(self.dead_line),
345            format='SHORT_DATETIME_FORMAT', use_l10n=True
346        )
347        return '%s - %s ( %s )' % (start, end, dead_line)
348
349    objects = PeriodManager()
350
351    class Meta:
352        """
353        Meta information associated with the `Period` class.
354        """
355        verbose_name = _('period')
356        verbose_name_plural = _('periods')
357        default_permissions = ()
358        constraints = [
359            models.CheckConstraint(
360                check=models.Q(start__lte=models.F('end')),
361                name='runtime_check_period'
362            ),
363            models.CheckConstraint(
364                check=models.Q(end__lte=models.F('dead_line')),
365                name='dead_line_check_period'
366            ),
367            models.CheckConstraint(
368                check=models.Q(dead_line__lte=models.F('dead_line_final')),
369                name='dead_line_final_check_period'
370            )
371        ]
372        get_latest_by = 'start'

A Model subclass to track time periods.

def start(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def end(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def dead_line(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def dead_line_final(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def clean_fields(self, exclude=None):
308    def clean_fields(self, exclude=None):
309        """
310        Cleans and validates the fields associated with this instance.
311        This will raise a `ValidationError` on failure.
312        """
313        super().clean_fields(exclude)
314        if (not exclude or 'end' not in exclude) and self.start > self.end:
315            raise ValidationError({
316                'end': ValidationError(
317                    _('The end date must be after the start date.'),
318                    code='invalid_dates'
319                )
320            })
321        if (not exclude or 'dead_line' not in exclude) and self.end > self.dead_line.date():
322            raise ValidationError({
323                'dead_line': ValidationError(
324                    _('The dead line must be after the end date.'),
325                    code='invalid_dead_line'
326                )
327            })
328        if (not exclude or 'dead_line_final' not in exclude) and self.dead_line.date() > self.dead_line_final.date():
329            raise ValidationError({
330                'dead_line_final': ValidationError(
331                    _('The final dead line cannot be before the dead line.'),
332                    code='invalid_dead_line_final'
333                )
334            })

Cleans and validates the fields associated with this instance. This will raise a ValidationError on failure.

def objects(unknown):
def get_next_by_start(unknown):

Method descriptor with partial application of the given arguments and keywords.

Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.

def get_previous_by_start(unknown):

Method descriptor with partial application of the given arguments and keywords.

Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.

def get_next_by_end(unknown):

Method descriptor with partial application of the given arguments and keywords.

Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.

def get_previous_by_end(unknown):

Method descriptor with partial application of the given arguments and keywords.

Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.

def get_next_by_dead_line(unknown):

Method descriptor with partial application of the given arguments and keywords.

Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.

def get_previous_by_dead_line(unknown):

Method descriptor with partial application of the given arguments and keywords.

Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.

def get_next_by_dead_line_final(unknown):

Method descriptor with partial application of the given arguments and keywords.

Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.

def get_previous_by_dead_line_final(unknown):

Method descriptor with partial application of the given arguments and keywords.

Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.

def id(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

periodclosure_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

workhours_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

workhourscorrection_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

Inherited Members
django.db.models.base.Model
Model
from_db
pk
get_deferred_fields
refresh_from_db
arefresh_from_db
serializable_value
save
asave
save_base
delete
adelete
prepare_database_save
clean
validate_unique
date_error_message
unique_error_message
get_constraints
validate_constraints
full_clean
check
class Period.DoesNotExist(django.core.exceptions.ObjectDoesNotExist):

The requested object does not exist

Inherited Members
builtins.Exception
Exception
django.core.exceptions.ObjectDoesNotExist
silent_variable_failure
builtins.BaseException
with_traceback
add_note
args
class Period.MultipleObjectsReturned(django.core.exceptions.MultipleObjectsReturned):

The query returned multiple objects when only one was expected.

Inherited Members
builtins.Exception
Exception
builtins.BaseException
with_traceback
add_note
args
class PeriodClosure(django.db.models.base.Model):
375class PeriodClosure(models.Model):
376    """
377    A `Model` subclass to track whether a user or manager, assigned to a project, has permission to
378    add, change or delete work hour records for a given period.
379    """
380    period = models.ForeignKey(
381        to=Period,
382        on_delete=models.CASCADE,
383        verbose_name=('period')
384    )
385    project_assignment = models.ForeignKey(
386        to=ProjectAssignment,
387        on_delete=models.CASCADE,
388        verbose_name=('project assignment')
389    )
390    is_closed_contributor = models.BooleanField(
391        default=False,
392        verbose_name=('closed for contributor')
393    )
394    is_closed_manager = models.BooleanField(
395        default=False,
396        verbose_name=('closed for manager')
397    )
398
399    class Meta:
400        """
401        Meta information associated with the `PeriodClosure` class.
402        """
403        verbose_name = _('period')
404        verbose_name_plural = _('periods')
405        default_permissions = ()
406        constraints = [
407            models.UniqueConstraint(
408                fields=['period', 'project_assignment'],
409                name='unique_constraint_period_closure',
410            )
411        ]

A Model subclass to track whether a user or manager, assigned to a project, has permission to add, change or delete work hour records for a given period.

period

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

project_assignment

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

def is_closed_contributor(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def is_closed_manager(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

period_id
project_assignment_id
def id(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def objects(unknown):
Inherited Members
django.db.models.base.Model
Model
from_db
pk
get_deferred_fields
refresh_from_db
arefresh_from_db
serializable_value
save
asave
save_base
delete
adelete
prepare_database_save
clean
validate_unique
date_error_message
unique_error_message
get_constraints
validate_constraints
full_clean
clean_fields
check
class PeriodClosure.DoesNotExist(django.core.exceptions.ObjectDoesNotExist):

The requested object does not exist

Inherited Members
builtins.Exception
Exception
django.core.exceptions.ObjectDoesNotExist
silent_variable_failure
builtins.BaseException
with_traceback
add_note
args
class PeriodClosure.MultipleObjectsReturned(django.core.exceptions.MultipleObjectsReturned):

The query returned multiple objects when only one was expected.

Inherited Members
builtins.Exception
Exception
builtins.BaseException
with_traceback
add_note
args
class WorkHours(django.db.models.base.Model):
414class WorkHours(models.Model):
415    """
416    A `Model` subclass to keep track of work hours.
417    """
418    project_assignment = models.ForeignKey(
419        to=ProjectAssignment,
420        on_delete=models.RESTRICT,
421        verbose_name=_('project assignment'),
422    )
423    period = models.ForeignKey(
424        to=Period,
425        on_delete=models.RESTRICT,
426        verbose_name=_('period')
427    )
428    day = models.DateField(
429        verbose_name=_('work day'),
430        help_text=_('Date of work day.')
431    )
432    hours = models.DecimalField(
433        max_digits=4,
434        decimal_places=2,
435        validators=[
436            MinValueValidator(0.01),
437            MaxValueValidator(24),
438        ],
439        verbose_name=_('work hours'),
440        help_text=_('Number of hours worked with '
441                    'precision up to two decimal places.'),
442    )
443
444    def clean_fields(self, exclude=None):
445        """
446        Cleans and validates the fields associated with this instance.
447        This will raise a `ValidationError` on failure.
448        """
449        super().clean_fields(exclude)
450        # Constraints over foreign keys do not work at this point in time
451        if not exclude or 'day' not in exclude:
452            if self.period.start < self.day or self.day > self.period.end:
453                raise ValidationError({
454                    'day': ValidationError(
455                        _('Work day is not between the start and end'
456                          'date of the given period.'),
457                        code='invalid_day'
458                    )
459                })
460        if not exclude or 'project_assignment' not in exclude:
461            if self.day < self.project_assignment.project.start or self.day > self.project_assignment.project.end:
462                raise ValidationError({
463                    'project_assignment': ValidationError(
464                        _('Work day is not within the start and end'
465                          'date of the given project.'),
466                        code='invalid_day'
467                    )
468                })
469
470    class Meta:
471        """
472        Meta information associated with the `WorkHours` class.
473        """
474        verbose_name = _('work hours')
475        verbose_name_plural = _('work hours')
476        default_permissions = ()
477        constraints = [
478            models.UniqueConstraint(
479                fields=['project_assignment', 'day'],
480                name='unique_constraint_work_hours',
481            ),
482            models.CheckConstraint(
483                check=models.Q(hours__gt=0.0),
484                name='min_work_hours'
485            ),
486            models.CheckConstraint(
487                check=models.Q(hours__lte=24.0),
488                name='max_work_hours'
489            ),
490        ]

A Model subclass to keep track of work hours.

project_assignment

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

period

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

def day(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def hours(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def clean_fields(self, exclude=None):
444    def clean_fields(self, exclude=None):
445        """
446        Cleans and validates the fields associated with this instance.
447        This will raise a `ValidationError` on failure.
448        """
449        super().clean_fields(exclude)
450        # Constraints over foreign keys do not work at this point in time
451        if not exclude or 'day' not in exclude:
452            if self.period.start < self.day or self.day > self.period.end:
453                raise ValidationError({
454                    'day': ValidationError(
455                        _('Work day is not between the start and end'
456                          'date of the given period.'),
457                        code='invalid_day'
458                    )
459                })
460        if not exclude or 'project_assignment' not in exclude:
461            if self.day < self.project_assignment.project.start or self.day > self.project_assignment.project.end:
462                raise ValidationError({
463                    'project_assignment': ValidationError(
464                        _('Work day is not within the start and end'
465                          'date of the given project.'),
466                        code='invalid_day'
467                    )
468                })

Cleans and validates the fields associated with this instance. This will raise a ValidationError on failure.

project_assignment_id
period_id
def get_next_by_day(unknown):

Method descriptor with partial application of the given arguments and keywords.

Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.

def get_previous_by_day(unknown):

Method descriptor with partial application of the given arguments and keywords.

Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.

def id(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def objects(unknown):
Inherited Members
django.db.models.base.Model
Model
from_db
pk
get_deferred_fields
refresh_from_db
arefresh_from_db
serializable_value
save
asave
save_base
delete
adelete
prepare_database_save
clean
validate_unique
date_error_message
unique_error_message
get_constraints
validate_constraints
full_clean
check
class WorkHours.DoesNotExist(django.core.exceptions.ObjectDoesNotExist):

The requested object does not exist

Inherited Members
builtins.Exception
Exception
django.core.exceptions.ObjectDoesNotExist
silent_variable_failure
builtins.BaseException
with_traceback
add_note
args
class WorkHours.MultipleObjectsReturned(django.core.exceptions.MultipleObjectsReturned):

The query returned multiple objects when only one was expected.

Inherited Members
builtins.Exception
Exception
builtins.BaseException
with_traceback
add_note
args
class WorkHoursCorrection(django.db.models.base.Model):
493class WorkHoursCorrection(models.Model):
494    """
495    A `Model` subclass to keep track of correction to work hour aggregations.
496    """
497    project_assignment = models.ForeignKey(
498        to=ProjectAssignment,
499        on_delete=models.RESTRICT,
500        verbose_name=_('project assignment'),
501    )
502    period = models.ForeignKey(
503        to=Period,
504        on_delete=models.RESTRICT,
505        verbose_name=_('period')
506    )
507    ammount = models.DecimalField(
508        max_digits=5,
509        decimal_places=2,
510        help_text=_('Ammount by which the total number of workhours'
511                    'for a given project assignment and period should be corrected.'),
512    )
513
514    class Meta:
515        """
516        Meta information associated with the `WorkHoursCorrection` class.
517        """
518        verbose_name = _('work hours correction')
519        verbose_name_plural = _('work hours correction')
520        default_permissions = ()
521        constraints = [
522            models.UniqueConstraint(
523                fields=['project_assignment', 'period'],
524                name='unique_constraint_work_hours_correction',
525            ),
526        ]

A Model subclass to keep track of correction to work hour aggregations.

project_assignment

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

period

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

def ammount(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

project_assignment_id
period_id
def id(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def objects(unknown):
Inherited Members
django.db.models.base.Model
Model
from_db
pk
get_deferred_fields
refresh_from_db
arefresh_from_db
serializable_value
save
asave
save_base
delete
adelete
prepare_database_save
clean
validate_unique
date_error_message
unique_error_message
get_constraints
validate_constraints
full_clean
clean_fields
check
class WorkHoursCorrection.DoesNotExist(django.core.exceptions.ObjectDoesNotExist):

The requested object does not exist

Inherited Members
builtins.Exception
Exception
django.core.exceptions.ObjectDoesNotExist
silent_variable_failure
builtins.BaseException
with_traceback
add_note
args
class WorkHoursCorrection.MultipleObjectsReturned(django.core.exceptions.MultipleObjectsReturned):

The query returned multiple objects when only one was expected.

Inherited Members
builtins.Exception
Exception
builtins.BaseException
with_traceback
add_note
args
class ProjectFundedStaffDate(django.db.models.base.Model):
529class ProjectFundedStaffDate(models.Model):
530    """
531    A `Model` subclassfor tracking date related information for `ProjectFundedStaff`.
532    """
533    date = models.DateField(
534        verbose_name=_('start date'),
535    )
536    project = models.ForeignKey(
537        'Project',
538        verbose_name=_('project'),
539        on_delete=models.CASCADE,
540    )
541
542    def __str__(self):
543        """
544        Returns a string representation of this `ProjectFundedStaffDate` instance.
545        """
546        date = date_format(
547            self.date, format='SHORT_DATE_FORMAT', use_l10n=True)
548        verbose = self._meta.verbose_name
549        return f"{verbose}: {date}"
550
551    class Meta:
552        """
553        Meta information associated with the `ProjectFundedStaffDate` class.
554        """
555        verbose_name = _('project funded staff interval')
556        verbose_name_plural = _('project funded staff intervals')
557        default_permissions = ()
558        constraints = [
559            models.UniqueConstraint(
560                fields=['date', 'project'],
561                name='unique_constraint_project_funded_staff_date',
562            ),
563        ]

A Model subclassfor tracking date related information for ProjectFundedStaff.

def date(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

project

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

def get_next_by_date(unknown):

Method descriptor with partial application of the given arguments and keywords.

Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.

def get_previous_by_date(unknown):

Method descriptor with partial application of the given arguments and keywords.

Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.

project_id
def id(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def objects(unknown):
projectfundedstaff_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

Inherited Members
django.db.models.base.Model
Model
from_db
pk
get_deferred_fields
refresh_from_db
arefresh_from_db
serializable_value
save
asave
save_base
delete
adelete
prepare_database_save
clean
validate_unique
date_error_message
unique_error_message
get_constraints
validate_constraints
full_clean
clean_fields
check
class ProjectFundedStaffDate.DoesNotExist(django.core.exceptions.ObjectDoesNotExist):

The requested object does not exist

Inherited Members
builtins.Exception
Exception
django.core.exceptions.ObjectDoesNotExist
silent_variable_failure
builtins.BaseException
with_traceback
add_note
args
class ProjectFundedStaffDate.MultipleObjectsReturned(django.core.exceptions.MultipleObjectsReturned):

The query returned multiple objects when only one was expected.

Inherited Members
builtins.Exception
Exception
builtins.BaseException
with_traceback
add_note
args
class ProjectFundedStaff(django.db.models.base.Model):
566class ProjectFundedStaff(models.Model):
567    """
568    A `Model` subclassfor tracking staff associated with a project. (Instead of individual contributors.)
569    """
570    salary_level = models.ForeignKey(
571        'SalaryLevel',
572        verbose_name=_('salary level'),
573        on_delete=models.CASCADE,
574    )
575    start = models.ForeignKey(
576        'ProjectFundedStaffDate',
577        verbose_name=_('start date'),
578        on_delete=models.CASCADE
579    )
580    hours = models.DecimalField(
581        max_digits=8,
582        decimal_places=2,
583    )
584
585    class Meta:
586        """
587        Meta information associated with the `ProjectFundedStaff` class.
588        """
589        verbose_name = _('project funded staff')
590        verbose_name_plural = _('project funded staff')
591        default_permissions = ()
592        constraints = [
593            models.UniqueConstraint(
594                fields=['salary_level', 'start'],
595                name='unique_constraint_project_funded_staff',
596            ),
597        ]

A Model subclassfor tracking staff associated with a project. (Instead of individual contributors.)

salary_level

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

start

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

def hours(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

salary_level_id
start_id
def id(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def objects(unknown):
Inherited Members
django.db.models.base.Model
Model
from_db
pk
get_deferred_fields
refresh_from_db
arefresh_from_db
serializable_value
save
asave
save_base
delete
adelete
prepare_database_save
clean
validate_unique
date_error_message
unique_error_message
get_constraints
validate_constraints
full_clean
clean_fields
check
class ProjectFundedStaff.DoesNotExist(django.core.exceptions.ObjectDoesNotExist):

The requested object does not exist

Inherited Members
builtins.Exception
Exception
django.core.exceptions.ObjectDoesNotExist
silent_variable_failure
builtins.BaseException
with_traceback
add_note
args
class ProjectFundedStaff.MultipleObjectsReturned(django.core.exceptions.MultipleObjectsReturned):

The query returned multiple objects when only one was expected.

Inherited Members
builtins.Exception
Exception
builtins.BaseException
with_traceback
add_note
args
class GeneralCosts(django.db.models.base.Model):
600class GeneralCosts(models.Model):
601    """
602    A `Model` subclassfor tracking general costs associated with projects.
603    """
604    start = models.DateField(
605        verbose_name=_('start date'),
606    )
607    costs = models.DecimalField(
608        verbose_name=_('general costs'),
609        max_digits=8,
610        decimal_places=2,
611    )
612
613    def __str__(self):
614        """
615        Returns a string representation of this `GeneralCosts` instance.
616        """
617        start = date_format(
618            self.start, format='SHORT_DATE_FORMAT', use_l10n=True)
619        verbose = self._meta.verbose_name
620        return f"{verbose}: {start}"
621
622    class Meta:
623        """
624        Meta information associated with the `GeneralCosts` class.
625        """
626        verbose_name = _('general costs')
627        verbose_name_plural = _('general costs')
628        default_permissions = ()
629        constraints = [
630            models.UniqueConstraint(
631                fields=['start'],
632                name='unique_constraint_general_costs',
633            ),
634        ]

A Model subclassfor tracking general costs associated with projects.

def start(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def costs(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def get_next_by_start(unknown):

Method descriptor with partial application of the given arguments and keywords.

Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.

def get_previous_by_start(unknown):

Method descriptor with partial application of the given arguments and keywords.

Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.

def id(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def objects(unknown):
Inherited Members
django.db.models.base.Model
Model
from_db
pk
get_deferred_fields
refresh_from_db
arefresh_from_db
serializable_value
save
asave
save_base
delete
adelete
prepare_database_save
clean
validate_unique
date_error_message
unique_error_message
get_constraints
validate_constraints
full_clean
clean_fields
check
class GeneralCosts.DoesNotExist(django.core.exceptions.ObjectDoesNotExist):

The requested object does not exist

Inherited Members
builtins.Exception
Exception
django.core.exceptions.ObjectDoesNotExist
silent_variable_failure
builtins.BaseException
with_traceback
add_note
args
class GeneralCosts.MultipleObjectsReturned(django.core.exceptions.MultipleObjectsReturned):

The query returned multiple objects when only one was expected.

Inherited Members
builtins.Exception
Exception
builtins.BaseException
with_traceback
add_note
args
class DepartmentDate(django.db.models.base.Model):
637class DepartmentDate(models.Model):
638    """
639    A `Model` subclassfor tracking date related information for `DepartmentCosts`.
640    """
641    date = models.DateField(
642        verbose_name=_('start date'),
643    )
644
645    def __str__(self):
646        """
647        Returns a string representation of this `DepartmentDate` instance.
648        """
649        date = date_format(
650            self.date, format='SHORT_DATE_FORMAT', use_l10n=True)
651        verbose = self._meta.verbose_name
652        return f"{verbose}: {date}"
653
654    class Meta:
655        """
656        Meta information associated with the `DepartmentDate` class.
657        """
658        verbose_name = _('department interval')
659        verbose_name_plural = _('department intervals')
660        default_permissions = ()
661        constraints = [
662            models.UniqueConstraint(
663                fields=['date'],
664                name='unique_constraint_department_date',
665            ),
666        ]

A Model subclassfor tracking date related information for DepartmentCosts.

def date(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def get_next_by_date(unknown):

Method descriptor with partial application of the given arguments and keywords.

Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.

def get_previous_by_date(unknown):

Method descriptor with partial application of the given arguments and keywords.

Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.

def id(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def objects(unknown):
departmentcosts_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

Inherited Members
django.db.models.base.Model
Model
from_db
pk
get_deferred_fields
refresh_from_db
arefresh_from_db
serializable_value
save
asave
save_base
delete
adelete
prepare_database_save
clean
validate_unique
date_error_message
unique_error_message
get_constraints
validate_constraints
full_clean
clean_fields
check
class DepartmentDate.DoesNotExist(django.core.exceptions.ObjectDoesNotExist):

The requested object does not exist

Inherited Members
builtins.Exception
Exception
django.core.exceptions.ObjectDoesNotExist
silent_variable_failure
builtins.BaseException
with_traceback
add_note
args
class DepartmentDate.MultipleObjectsReturned(django.core.exceptions.MultipleObjectsReturned):

The query returned multiple objects when only one was expected.

Inherited Members
builtins.Exception
Exception
builtins.BaseException
with_traceback
add_note
args
class DepartmentCosts(django.db.models.base.Model):
669class DepartmentCosts(models.Model):
670    """
671    A model for tracking costs associated with departments.
672    """
673    department = models.ForeignKey(
674        'Department',
675        verbose_name=_('department'),
676        on_delete=models.CASCADE
677    )
678    start = models.ForeignKey(
679        'DepartmentDate',
680        verbose_name=_('start date'),
681        on_delete=models.CASCADE
682    )
683    equivalents_per_hour = models.DecimalField(
684        verbose_name=_('full time equivalents per hour'),
685        max_digits=8,
686        decimal_places=2,
687    )
688
689    def __str__(self):
690        """
691        Returns a string representation of this `DepartmentCosts` instance.
692        """
693        return f"{self._meta.verbose_name}: {self.pk}"
694
695    class Meta:
696        """
697        Meta information associated with the `DepartmentCosts` class.
698        """
699        verbose_name = _('department costs')
700        verbose_name_plural = _('department costs')
701        default_permissions = ()
702        constraints = [
703            models.UniqueConstraint(
704                fields=['department', 'start'],
705                name='unique_constraint_department_costs',
706            ),
707        ]

A model for tracking costs associated with departments.

department

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

start

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

def equivalents_per_hour(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

department_id
start_id
def id(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def objects(unknown):
Inherited Members
django.db.models.base.Model
Model
from_db
pk
get_deferred_fields
refresh_from_db
arefresh_from_db
serializable_value
save
asave
save_base
delete
adelete
prepare_database_save
clean
validate_unique
date_error_message
unique_error_message
get_constraints
validate_constraints
full_clean
clean_fields
check
class DepartmentCosts.DoesNotExist(django.core.exceptions.ObjectDoesNotExist):

The requested object does not exist

Inherited Members
builtins.Exception
Exception
django.core.exceptions.ObjectDoesNotExist
silent_variable_failure
builtins.BaseException
with_traceback
add_note
args
class DepartmentCosts.MultipleObjectsReturned(django.core.exceptions.MultipleObjectsReturned):

The query returned multiple objects when only one was expected.

Inherited Members
builtins.Exception
Exception
builtins.BaseException
with_traceback
add_note
args
class SalaryLevelDate(django.db.models.base.Model):
710class SalaryLevelDate(models.Model):
711    """
712    A `Model` subclassfor tracking date related information for `SalaryLevelCosts`.
713    """
714    date = models.DateField(
715        verbose_name=_('start date'),
716    )
717
718    def __str__(self):
719        """
720        Returns a string representation of this `SalaryLevelDate` instance.
721        """
722        date = date_format(
723            self.date, format='SHORT_DATE_FORMAT', use_l10n=True)
724        verbose = self._meta.verbose_name
725        return f"{verbose}: {date}"
726
727    class Meta:
728        """
729        Meta information associated with the `SalaryLevelDate` class.
730        """
731        verbose_name = _('salary interval')
732        verbose_name_plural = _('salary intervals')
733        default_permissions = ()
734        constraints = [
735            models.UniqueConstraint(
736                fields=['date'],
737                name='unique_constraint_salary_level_date',
738            ),
739        ]

A Model subclassfor tracking date related information for SalaryLevelCosts.

def date(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def get_next_by_date(unknown):

Method descriptor with partial application of the given arguments and keywords.

Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.

def get_previous_by_date(unknown):

Method descriptor with partial application of the given arguments and keywords.

Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.

def id(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def objects(unknown):
salarylevelcosts_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

Inherited Members
django.db.models.base.Model
Model
from_db
pk
get_deferred_fields
refresh_from_db
arefresh_from_db
serializable_value
save
asave
save_base
delete
adelete
prepare_database_save
clean
validate_unique
date_error_message
unique_error_message
get_constraints
validate_constraints
full_clean
clean_fields
check
class SalaryLevelDate.DoesNotExist(django.core.exceptions.ObjectDoesNotExist):

The requested object does not exist

Inherited Members
builtins.Exception
Exception
django.core.exceptions.ObjectDoesNotExist
silent_variable_failure
builtins.BaseException
with_traceback
add_note
args
class SalaryLevelDate.MultipleObjectsReturned(django.core.exceptions.MultipleObjectsReturned):

The query returned multiple objects when only one was expected.

Inherited Members
builtins.Exception
Exception
builtins.BaseException
with_traceback
add_note
args
class SalaryLevelCosts(django.db.models.base.Model):
742class SalaryLevelCosts(models.Model):
743    """
744    A `Model` subclassfor tracking costs associated with salary levels.
745    """
746    salary_level = models.ForeignKey(
747        'SalaryLevel',
748        verbose_name=_('salary level'),
749        on_delete=models.CASCADE,
750    )
751    start = models.ForeignKey(
752        'SalaryLevelDate',
753        verbose_name=_('start date'),
754        on_delete=models.CASCADE
755    )
756    brutto_per_hour = models.DecimalField(
757        verbose_name=_('brutto staff costs per hour'),
758        max_digits=8,
759        decimal_places=2,
760    )
761
762    def __str__(self):
763        """
764        Returns a string representation of this `SalaryLevelCosts` instance.
765        """
766        return f"{self._meta.verbose_name}: {self.pk}"
767
768    class Meta:
769        """
770        Meta information associated with the `SalaryLevelCosts` class.
771        """
772        verbose_name = _('salary level costs')
773        verbose_name_plural = _('salary level costs')
774        default_permissions = ()
775        constraints = [
776            models.UniqueConstraint(
777                fields=['salary_level', 'start'],
778                name='unique_constraint_salary_level_costs',
779            ),
780        ]

A Model subclassfor tracking costs associated with salary levels.

salary_level

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

start

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

def brutto_per_hour(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

salary_level_id
start_id
def id(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def objects(unknown):
Inherited Members
django.db.models.base.Model
Model
from_db
pk
get_deferred_fields
refresh_from_db
arefresh_from_db
serializable_value
save
asave
save_base
delete
adelete
prepare_database_save
clean
validate_unique
date_error_message
unique_error_message
get_constraints
validate_constraints
full_clean
clean_fields
check
class SalaryLevelCosts.DoesNotExist(django.core.exceptions.ObjectDoesNotExist):

The requested object does not exist

Inherited Members
builtins.Exception
Exception
django.core.exceptions.ObjectDoesNotExist
silent_variable_failure
builtins.BaseException
with_traceback
add_note
args
class SalaryLevelCosts.MultipleObjectsReturned(django.core.exceptions.MultipleObjectsReturned):

The query returned multiple objects when only one was expected.

Inherited Members
builtins.Exception
Exception
builtins.BaseException
with_traceback
add_note
args
class ReceiptTemplate(django.db.models.base.Model):
783class ReceiptTemplate(models.Model):
784    """
785    A model for keeping track of templates for generating receipts. 
786    """
787    start = models.DateField(
788        verbose_name=_('start date'),
789    )
790    data = models.JSONField()
791
792    def __str__(self):
793        """
794        Returns a string representation of this `ReceiptTemplate` instance.
795        """
796        return f"{self._meta.verbose_name}: {self.start}"
797
798    class Meta:
799        """
800        Meta information associated with the `ReceiptTemplate` class.
801        """
802        default_permissions = ()
803        verbose_name = _('receipt template')
804        verbose_name_plural = ('receipt templates')
805        constraints = [
806            models.UniqueConstraint(
807                fields=['start'],
808                name='unique_constraint_receipt_template_start',
809            ),
810        ]

A model for keeping track of templates for generating receipts.

def start(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def data(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def get_next_by_start(unknown):

Method descriptor with partial application of the given arguments and keywords.

Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.

def get_previous_by_start(unknown):

Method descriptor with partial application of the given arguments and keywords.

Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.

def id(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def objects(unknown):
Inherited Members
django.db.models.base.Model
Model
from_db
pk
get_deferred_fields
refresh_from_db
arefresh_from_db
serializable_value
save
asave
save_base
delete
adelete
prepare_database_save
clean
validate_unique
date_error_message
unique_error_message
get_constraints
validate_constraints
full_clean
clean_fields
check
class ReceiptTemplate.DoesNotExist(django.core.exceptions.ObjectDoesNotExist):

The requested object does not exist

Inherited Members
builtins.Exception
Exception
django.core.exceptions.ObjectDoesNotExist
silent_variable_failure
builtins.BaseException
with_traceback
add_note
args
class ReceiptTemplate.MultipleObjectsReturned(django.core.exceptions.MultipleObjectsReturned):

The query returned multiple objects when only one was expected.

Inherited Members
builtins.Exception
Exception
builtins.BaseException
with_traceback
add_note
args
class Receipt(django.db.models.base.Model):
813class Receipt(models.Model):
814    """
815    A model for keeping track of receipts. 
816    """
817    start = models.DateField(
818        verbose_name=_('start date'),
819    )
820    end = models.DateField(
821        verbose_name=_('end date'),
822    )
823    create_time = models.DateTimeField(
824        verbose_name=_('time booked'),
825        auto_now=False,
826        auto_now_add=True,
827    )
828    project = models.ForeignKey(
829        'Project',
830        verbose_name=_('project'),
831        on_delete=models.CASCADE,
832    )
833    receipt_number = models.IntegerField(
834        verbose_name=_('receipt number'),
835    )
836    buper = models.IntegerField(
837        verbose_name=_('buper'),
838    )
839
840    data = models.JSONField()
841
842    class Meta:
843        """
844        Meta information associated with the `Receipt` class.
845        """
846        default_permissions = ()
847        verbose_name = _('receipt')
848        verbose_name_plural = ('receipts')
849        constraints = [
850            models.CheckConstraint(
851                check=models.Q(start__lte=models.F('end')),
852                name='interval_check_receipt'
853            ),
854        ]

A model for keeping track of receipts.

def start(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def end(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def create_time(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

project

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

def receipt_number(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def buper(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def data(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def get_next_by_start(unknown):

Method descriptor with partial application of the given arguments and keywords.

Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.

def get_previous_by_start(unknown):

Method descriptor with partial application of the given arguments and keywords.

Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.

def get_next_by_end(unknown):

Method descriptor with partial application of the given arguments and keywords.

Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.

def get_previous_by_end(unknown):

Method descriptor with partial application of the given arguments and keywords.

Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.

def get_next_by_create_time(unknown):

Method descriptor with partial application of the given arguments and keywords.

Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.

def get_previous_by_create_time(unknown):

Method descriptor with partial application of the given arguments and keywords.

Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.

project_id
def id(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def objects(unknown):
Inherited Members
django.db.models.base.Model
Model
from_db
pk
get_deferred_fields
refresh_from_db
arefresh_from_db
serializable_value
save
asave
save_base
delete
adelete
prepare_database_save
clean
validate_unique
date_error_message
unique_error_message
get_constraints
validate_constraints
full_clean
clean_fields
check
class Receipt.DoesNotExist(django.core.exceptions.ObjectDoesNotExist):

The requested object does not exist

Inherited Members
builtins.Exception
Exception
django.core.exceptions.ObjectDoesNotExist
silent_variable_failure
builtins.BaseException
with_traceback
add_note
args
class Receipt.MultipleObjectsReturned(django.core.exceptions.MultipleObjectsReturned):

The query returned multiple objects when only one was expected.

Inherited Members
builtins.Exception
Exception
builtins.BaseException
with_traceback
add_note
args