0

I am building a management application for a company. One of the things the application can do is start new projects. The model for this is:

class Project(models.Model):
    employees = models.ManyToManyField(settings.AUTH_USER_MODEL)
    division = models.ForeignKey(Division)
    client = models.ForeignKey(Company)
    description = models.CharField(max_length=120)
    timestamp = models.DateTimeField(auto_now_add=True)
    deadline = models.DateField(blank=True)
    active = models.BooleanField(default=True)

As you can see in the model, an employee can set a deadline for their project. I need to be able to send the user notifications if they are close to their deadline.

For example, if the deadline is in two days, the user will get a notification like "Your deadline for projectname is over two days". So basically, what I need is a deadline timer.

What is the logic for this? I don't really know where to start with this.

Sep Roland
  • 33,889
  • 7
  • 43
  • 76
Manu Febie
  • 31
  • 5
  • 1
    You can use celery – Sandeep Balagopal Oct 24 '17 at 06:26
  • Your question is too broad, What kind of notification? when they next view a page? an email reminder? other? What have you tried/researched? – Sayse Oct 24 '17 at 07:10
  • 1
    That's pretty broad. Could be something as simple as a cronjob that runs once a day and checks projects that have a closing deadline, and sends emails to those users. Just be careful to set a flag to prevent sending repeating emails after the condition is met. (Speaking from experience. I once deployed a notification system that checked for due times every 30 minutes and send out friendly reminders to those who were overdue. I went to bed after seeing the first round of emails being successfully sent. But I didn't notice that the same batch went out 30 minutes later, and throughout the night.) – Björn Kristinsson Oct 24 '17 at 07:34
  • @BjörnKristinsson Hmmm okay .. Well what I want is a simple notification inside the application itself. So not email. Something like fb or other social media accounst use to notify u when. But in my case a notification when a project is close to its deadline. – Manu Febie Oct 24 '17 at 09:49
  • @SandeepBalagopal I have heard of Celery before but never used it before. COuld you maybe explain when and what for celery is used for? – Manu Febie Oct 25 '17 at 02:00
  • Celery is a powerful tool for executing background tasks. You can find many docs if you google. – Sandeep Balagopal Oct 25 '17 at 05:11

0 Answers0