* adds new command to be used with cron for periodic checkin of resubmissions * updates translations
47 lines
1.3 KiB
Python
47 lines
1.3 KiB
Python
"""
|
|
Author: Michel Peltriaux
|
|
Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany
|
|
Contact: ksp-servicestelle@sgdnord.rlp.de
|
|
Created on: 15.08.22
|
|
|
|
"""
|
|
from dateutil.utils import today
|
|
from django.db import models
|
|
|
|
from konova.models import BaseResource
|
|
from konova.utils.mailer import Mailer
|
|
|
|
|
|
class Resubmission(BaseResource):
|
|
user = models.ForeignKey(
|
|
"user.User",
|
|
on_delete=models.CASCADE,
|
|
help_text="The user who wants to be notifed"
|
|
)
|
|
resubmit_on = models.DateField(
|
|
help_text="On which date the resubmission should be performed"
|
|
)
|
|
resubmission_sent = models.BooleanField(
|
|
default=False,
|
|
help_text="Whether a resubmission has been sent or not"
|
|
)
|
|
comment = models.TextField(
|
|
null=True,
|
|
blank=True,
|
|
help_text="Optional comment for the user itself"
|
|
)
|
|
|
|
def send_resubmission_mail(self, obj_identifier):
|
|
""" Sends a resubmission mail
|
|
|
|
"""
|
|
_today = today().date()
|
|
resubmission_handled = _today.__ge__(self.resubmit_on) and self.resubmission_sent
|
|
if resubmission_handled:
|
|
return
|
|
|
|
mailer = Mailer()
|
|
mailer.send_mail_resubmission(obj_identifier, self)
|
|
self.resubmission_sent = True
|
|
self.save()
|