Created
January 14, 2021 10:35
-
-
Save fredkingham/a587719033a13ce05a6bce14633eba72 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import time | |
from django.utils import timezone | |
from opal.models import Episode | |
from odonto import episode_categories | |
from odonto.odonto_submissions.models import Submission | |
def delete_and_resend(): | |
episodes = Episode.objects.filter( | |
stage=episode_categories.AbstractOdontoCategory.SUBMITTED | |
).filter( | |
submission__state=Submission.SENT | |
) | |
submissions = [i.category.submission() for i in episodes] | |
five_days_ago = timezone.now() - datetime.timedelta(5) | |
for i in submissions: | |
if i.created < five_days_ago: | |
sign_off_date = i.episode.category.get_sign_off_date() | |
if sign_off_date > datetime.date(2020, 4, 1): | |
episode = i.episode | |
i.delete() | |
Submission.send(episode) | |
time.sleep(5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment