Repository: dotkom/onlineweb4

Issue:
(Event) Minimum length on event description and ingress
Possibly we should also limit the text to exclude words like TBA.

Events in ow4 demand some text in order to look good, so let's put a minimum requirement on length for the event texts. Making up a description of 200 characters should be no big deal.

I've really had it with "INFO: TBA"



Discussion:

Resolving patch:
diff --git a/apps/events/admin.py b/apps/events/admin.py
--- a/apps/events/admin.py
+++ b/apps/events/admin.py
@@ -1,5 +1,10 @@
 # -*- coding: utf-8 -*-
 
+from django import forms
+from django.contrib import admin
+from django.core import validators
+from django.utils.translation import ugettext as _
+
 from apps.events.models import Event
 from apps.events.models import AttendanceEvent
 from apps.events.models import Attendee
@@ -8,10 +13,8 @@
 from apps.events.models import FieldOfStudyRule
 from apps.events.models import GradeRule
 from apps.events.models import UserGroupRule
-
 from apps.feedback.admin import FeedbackRelationInline
 
-from django.contrib import admin
 
 
 class AttendeeInline(admin.TabularInline):
@@ -24,6 +27,7 @@ class CompanyInline(admin.TabularInline):
     max_num = 20
     extra = 0
 
+
 class RuleBundleInline(admin.TabularInline):
     model = RuleBundle
     extra = 1
@@ -34,32 +38,39 @@ class AttendanceEventAdmin(admin.ModelAdmin):
     model = AttendanceEvent
     inlines = (AttendeeInline, RuleBundleInline)
 
+
 class AttendeeAdmin(admin.ModelAdmin):
     model = Attendee
     list_display = ('user', 'event')
 
+
 class CompanyEventAdmin(admin.ModelAdmin):
     model = CompanyEvent
     inlines = (CompanyInline,)
 
+
 class RuleBundleAdmin(admin.ModelAdmin):
     model = RuleBundle
-   
+
+
 class FieldOfStudyRuleAdmin(admin.ModelAdmin):
     model = FieldOfStudyRule
 
+
 class GradeRuleAdmin(admin.ModelAdmin):
     model = GradeRule
 
+
 class UserGroupRuleAdmin(admin.ModelAdmin):
     model = UserGroupRule
 
+
 class AttendanceEventInline(admin.StackedInline):
     model = AttendanceEvent
     max_num = 1
     extra = 0
     filter_horizontal = ('rule_bundles',)
-    
+
 
 class EventAdmin(admin.ModelAdmin):
     inlines = (AttendanceEventInline, FeedbackRelationInline, CompanyInline)
@@ -76,6 +87,16 @@ def save_formset(self, request, form, formset, change):
             instance.save()
         formset.save_m2m()
 
+    def get_form(self, request, obj=None, **kwargs):
+        form = super(EventAdmin, self).get_form(request, obj, **kwargs)
+        form.base_fields['ingress_short'].validators=[validators.MinLengthValidator(75)]
+        form.base_fields['ingress'].validators=[validators.MinLengthValidator(100)]
+        form.base_fields['description'].validators=[
+                                                    validators.MinLengthValidator(200),
+                                                    validators.RegexValidator("^(?:(?!TBA).)*$", _("Beskrivelsen kan ikke inneholde 'TBA'."), "ulovlig"),
+                                                    ]
+        return form
+
 admin.site.register(Event, EventAdmin)
 admin.site.register(Attendee, AttendeeAdmin)
 admin.site.register(AttendanceEvent, AttendanceEventAdmin)


Test patch: