Improve help text for email field on news submission
authorMagnus Hagander <magnus@hagander.net>
Tue, 16 Mar 2021 17:25:08 +0000 (18:25 +0100)
committerMagnus Hagander <magnus@hagander.net>
Tue, 16 Mar 2021 17:27:01 +0000 (18:27 +0100)
While at it also move it from the model and into the form, so we don't
have to go back-edit the migrations every time (and it's the more
correct place now that it contains more direct instructions and a link)

pgweb/news/forms.py
pgweb/news/migrations/0006_sending_email.py
pgweb/news/models.py

index a2e4247ff3242f0948daafff8a705096d94e7231..1daa863905e399089e32a308594ff08c4f1d36d0 100644 (file)
@@ -12,6 +12,7 @@ class NewsArticleForm(forms.ModelForm):
     def __init__(self, *args, **kwargs):
         super().__init__(*args, **kwargs)
         self.fields['email'].required = True
+        self.fields['email'].help_text = "Pick a confirmed email associated with the organisation. This will be used as the reply address of posted news. If no correct address is available, you need to register one on the <a href=\"/account/edit/organisations/\">organisation</a> before submitting."
 
     def filter_by_user(self, user):
         self.fields['org'].queryset = Organisation.objects.filter(managers=user, approved=True)
index 57e00a487189ce185aa7934f3e90f6f5123f0646..b57af8f7d9f60c56dfe6382d239b8c93f496004b 100644 (file)
@@ -15,6 +15,6 @@ class Migration(migrations.Migration):
         migrations.AddField(
             model_name='newsarticle',
             name='email',
-            field=models.ForeignKey(blank=True, help_text='Pick a confirmed email associated with the organisation. This will be used as the reply address of posted news.', null=True, on_delete=django.db.models.deletion.PROTECT, to='core.OrganisationEmail', verbose_name='Reply email'),
+            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='core.OrganisationEmail', verbose_name='Reply email'),
         ),
     ]
index bbfa4d9c74ce4b4803951a31f978d1c154511b04..2be3962c31ba46d168bab8aa06018a554a59e3e9 100644 (file)
@@ -28,7 +28,7 @@ class NewsTag(models.Model):
 
 class NewsArticle(TwoModeratorsMixin, TristateModerateModel):
     org = models.ForeignKey(Organisation, null=False, blank=False, verbose_name="Organisation", help_text=ORGANISATION_HINT_TEXT, on_delete=models.CASCADE)
-    email = models.ForeignKey(OrganisationEmail, null=True, blank=True, verbose_name="Reply email", help_text="Pick a confirmed email associated with the organisation. This will be used as the reply address of posted news.", on_delete=models.PROTECT)
+    email = models.ForeignKey(OrganisationEmail, null=True, blank=True, verbose_name="Reply email", on_delete=models.PROTECT)
     date = models.DateField(null=False, blank=False, default=date.today, db_index=True)
     title = models.CharField(max_length=200, null=False, blank=False)
     content = models.TextField(null=False, blank=False)