I am trying to creating cron application my model look like :
class Crontab(models.Model):
#Some filelds
...
...
#m2m fields From here prob starts
minute = models.ManyToManyField(Mst_Cron_Minute, db_table="crontab_minute_map")
hour = models.ManyToManyField(Mst_Cron_Hour, db_table = "crontab_hour_map")
day_of_month = models.ManyToManyField(Mst_Cron_Day_Of_Month, db_table="crontab_day_of_month_map")
month = models.ManyToManyField(Mst_Cron_Month, db_table="crontab_month_map")
day_of_week = models.ManyToManyField(Mst_Cron_Day_Of_Week, db_table="crontab_day_of_week_map")
description = models.CharField(max_length=250, blank=True)
is_active = models.IntegerField(choices=YES_NO_CHOICES)
reason_for_deactivate = models.CharField(max_length=250, blank=True)
I need to validate the cron before it saves it into database.
- Should not have duplicate cron data saved on this model.
- if already a data in db say 5 1 * * * then for new record in the position of * none of the value allowed. Example 5 1 * * 1 or 5 1 * 1 * or 5 1 1 1 1 not allowed.
- if i have a data data 5 1 * 1 * is in DB the new data * 1 * 1 * or 5 * * 1 * ... not allowed, it mean if there is a digit in the position the * not allowed.
How can i validate this ? where my code should go ? Please help me .