diff --git a/webapp/migrations/0072_jobad.py b/webapp/migrations/0072_jobad.py index 98b7890..958dd3b 100644 --- a/webapp/migrations/0072_jobad.py +++ b/webapp/migrations/0072_jobad.py @@ -36,7 +36,7 @@ class Migration(migrations.Migration): ("visible", models.BooleanField(default=True)), ("created_at", models.DateTimeField(default=django.utils.timezone.now)), ( - "autohide", + "autohide_at", models.DateTimeField(default=webapp.utils.month_from_now), ), ("autohide_enabled", models.BooleanField(default=False)), diff --git a/webapp/models.py b/webapp/models.py index fec3679..baeceed 100644 --- a/webapp/models.py +++ b/webapp/models.py @@ -41,17 +41,20 @@ class BaseFeed(models.Model): """Model containing something showing on some info feed.""" id = models.AutoField(primary_key=True) - title = models.CharField(max_length=255) - tags = models.ManyToManyField(Tag, related_name="feeds", blank=True) - visible = models.BooleanField(default=True) deleted = models.BooleanField(default=False) - publish_time = models.DateTimeField(default=timezone.now) - autohide = models.DateTimeField(default=month_from_now) - autohide_enabled = models.BooleanField(default=False) - + title = models.CharField(max_length=255) description = models.CharField(max_length=255) content = models.TextField() image = models.ImageField(blank=True, null=True) + tags = models.ManyToManyField(Tag, related_name="feeds", blank=True) + + # isNotDraft + visible = models.BooleanField(default=True) + # Automatically publish after this time, unless isDraft + publish_time = models.DateTimeField(default=timezone.now) + # Automatically unpublish after this if autohide_enabled + autohide = models.DateTimeField(default=month_from_now) + autohide_enabled = models.BooleanField(default=False) webhookUrl = "" hookType = "" @@ -108,6 +111,19 @@ class Event(BaseFeed): verbose_name_plural = _("Events") +class JobAd(BaseFeed): + """Job advertisements shown on Corporate relations page""" + + created_at = models.DateTimeField(default=timezone.now) + + webhookUrl = f"https://{FRONTEND_URL}/jobads" + hookType = "jobad" + + class Meta: + verbose_name = _("JobAd") + verbose_name_plural = _("JobAds") + + class TemplateQuestion(models.Model): """ Stores template questions for signup forms as JSON format. Used in signup form creation. @@ -205,19 +221,6 @@ def email_on_signup(sender, instance, created, **kwargs): ) -class JobAd(BaseFeed): - """Job advertisements shown on Corporate relations page""" - - created_at = models.DateTimeField(default=timezone.now) - - webhookUrl = f"https://{FRONTEND_URL}/jobads" - hookType = "jobad" - - class Meta: - verbose_name = _("JobAd") - verbose_name_plural = _("JobAds") - - def generateMessage(heading: str, title: str, description: str, url: str): return render_to_string( "webapp/tg_message.tpl", @@ -300,8 +303,8 @@ class TelegramHook(BaseWebhook): auditlog.register(Tag) auditlog.register(Feed) auditlog.register(Event) +auditlog.register(JobAd) auditlog.register(SignupForm) auditlog.register(Signup) -auditlog.register(JobAd) auditlog.register(GenericWebhook) auditlog.register(TelegramHook) diff --git a/webapp/translation.py b/webapp/translation.py index a1e01b9..a8ca677 100644 --- a/webapp/translation.py +++ b/webapp/translation.py @@ -24,6 +24,11 @@ class EventTranslationOptions(TranslationOptions): fields = ("location",) +@register(JobAd) +class JobAdTranslationOptions(TranslationOptions): + fields = () + + @register(TemplateQuestion) class TemplateQuestionTranslationOptions(TranslationOptions): fields = () @@ -39,11 +44,6 @@ class SignupTranslationOptions(TranslationOptions): fields = () -@register(JobAd) -class JobAdTranslationOptions(TranslationOptions): - fields = () - - @register(BaseWebhook) class BaseWebhookOptions(TranslationOptions): fields = ()