Enable events to be badged.
authorJonathan S. Katz <jonathan.katz@excoventures.com>
Wed, 6 Dec 2017 03:06:37 +0000 (12:06 +0900)
committerMagnus Hagander <magnus@hagander.net>
Wed, 6 Dec 2017 03:06:37 +0000 (12:06 +0900)
Adds the "badged" flag to the Event model in order to distinguish
community badged events from other PostgreSQL oriented events.
Seven total events will be displayed on the homepage, with up to
four community events displayed. If there are no upcoming
community events then, then the header "Events" is shown.

The event submission interface allows a user to opt-in to
listing an event as a "community" event and provide an
explanation for moderators as to why the event should be
considered a community event.

Expands the list of News and Planet PostgreSQL blog entries to 10.

pgweb/core/views.py
pgweb/events/forms.py
pgweb/events/migrations/0002_event_badged.py [new file with mode: 0644]
pgweb/events/models.py
pgweb/events/views.py
templates/base/form.html
templates/index.html

index fb2dc91a690d1a29209058ea22c4e625e7fdce85..4bdb35a52c02545b58aa55e79d63e237972d34a0 100644 (file)
@@ -40,15 +40,19 @@ from django.template.context import RequestContext
 # Front page view
 @cache(minutes=10)
 def home(request):
-       news = NewsArticle.objects.filter(approved=True)[:7]
-       events = Event.objects.select_related('country').filter(approved=True, training=False, enddate__gte=date.today()).order_by('enddate', 'startdate')[:5]
+       news = NewsArticle.objects.filter(approved=True)[:10]
+       # get the first seven events and divide each up into a list of community and other events
+       event_queryset = Event.objects.select_related('country').filter(approved=True, training=False, enddate__gte=date.today()).order_by('enddate', 'startdate')
+       # display up to the first 4 community events.  Then choose the next 7 - |communty_events|
+       community_events = [event for event in event_queryset.filter(badged=True).all()[:4]]
+       other_events = [event for event in event_queryset.filter(badged=False).all()[:(7-len(community_events))]]
        try:
                quote = Quote.objects.filter(approved=True).order_by('?')[0]
        except:
                # if there is no quote available, just ignore error
                quote = None
        versions = Version.objects.filter(supported=True)
-       planet = ImportedRSSItem.objects.filter(feed__internalname="planet").order_by("-posttime")[:7]
+       planet = ImportedRSSItem.objects.filter(feed__internalname="planet").order_by("-posttime")[:10]
 
        traininginfo = Event.objects.filter(approved=True, training=True).extra(where=("startdate <= (CURRENT_DATE + '6 Months'::interval) AND enddate >= CURRENT_DATE",)).aggregate(Count('id'), Count('country', distinct=True))
        # can't figure out how to make django do this
@@ -59,7 +63,8 @@ def home(request):
        return render_to_response('index.html', {
                'title': 'The world\'s most advanced open source database',
                'news': news,
-               'events': events,
+               'community_events': community_events,
+               'other_events': other_events,
                'traininginfo': traininginfo,
                'trainingcompanies': trainingcompanies,
                'quote': quote,
@@ -102,7 +107,7 @@ def fallback(request, url):
                        t = loader.get_template('pages/%s/en.html' % url)
                except TemplateDoesNotExist:
                        raise Http404('Page not found.')
-               
+
        # Guestimate the nav section by looking at the URL and taking the first
        # piece of it.
        try:
@@ -311,7 +316,7 @@ def admin_mergeorg(request):
                                p.save()
                        # Now that everything is moved, we can delete the organisation
                        f.delete()
-                       
+
                        return HttpResponseRedirect("/admin/core/organisation/")
                # Else fall through to re-render form with errors
        else:
index 78cb794b972543343db6ea72844c90a2809f71ea..b0028b9a0b3445895769ef5826c983860d1b19c0 100644 (file)
@@ -5,12 +5,18 @@ from pgweb.core.models import Organisation
 from models import Event
 
 class EventForm(forms.ModelForm):
-       toggle_fields = [{
+       toggle_fields = [
+               {
                        'name': 'isonline',
                        'invert': True,
                        'fields': ['city', 'state', 'country',]
-                       },
-                                        ]
+               },
+               {
+                       'name': 'badged',
+                       'invert': False,
+                       'fields': ['description_for_badged',]
+               },
+       ]
        def __init__(self, *args, **kwargs):
                super(EventForm, self).__init__(*args, **kwargs)
        def filter_by_user(self, user):
diff --git a/pgweb/events/migrations/0002_event_badged.py b/pgweb/events/migrations/0002_event_badged.py
new file mode 100644 (file)
index 0000000..edab01d
--- /dev/null
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('events', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='event',
+            name='badged',
+            field=models.BooleanField(default=False, help_text=b'Choose "Badged" if this is a community recognized event following the <a href="/community/recognition/#conferences" target="_blank">community event guidelines</a>.', verbose_name=b'Community event'),
+        ),
+        migrations.AddField(
+            model_name='event',
+            name='description_for_badged',
+            field=models.TextField(help_text=b'Please describe how this is a community recognized event following the <a href="/community/recognition/#conferences" target="_blank">community event guidelines</a>. Please be as detailed as possible.', null=True, blank=True),
+        ),
+    ]
index afc2cc3da55626de73e438c000c8dc44bd027b97..e097bd8e1fbe8075409b94c95ccff3dbca7984aa 100644 (file)
@@ -14,6 +14,8 @@ class Event(models.Model):
        language = models.ForeignKey(Language, null=True, blank=True, default='eng', help_text="Primary language for event. When multiple languages, specify this in the event description")
 
        training = models.BooleanField(null=False, blank=False, default=False)
+       badged = models.BooleanField(null=False, blank=False, default=False, verbose_name='Community event', help_text='Choose "Badged" if this is a community recognized event following the <a href="/community/recognition/#conferences" target="_blank">community event guidelines</a>.')
+       description_for_badged = models.TextField(blank=True, null=True, help_text='Please describe how this is a community recognized event following the <a href="/community/recognition/#conferences" target="_blank">community event guidelines</a>. Please be as detailed as possible.')
        startdate = models.DateField(null=False, blank=False, verbose_name="Start date")
        enddate = models.DateField(null=False, blank=False, verbose_name="End date")
 
index 411a8c004ef1ce2406d4f3313cef46566df4fc6f..a49782703de532df9362afe436f5a92a2726de41 100644 (file)
@@ -11,12 +11,14 @@ from models import Event
 from forms import EventForm
 
 def main(request):
-       events = Event.objects.select_related('country').filter(approved=True).filter(training=False, enddate__gt=date.today()).order_by('enddate', 'startdate',)
+       community_events = Event.objects.select_related('country').filter(approved=True, badged=True).filter(training=False, enddate__gt=date.today()).order_by('enddate', 'startdate',)
+       other_events = Event.objects.select_related('country').filter(approved=True, badged=False).filter(training=False, enddate__gt=date.today()).order_by('enddate', 'startdate',)
        training = Event.objects.select_related('country').filter(approved=True).filter(training=True, enddate__gt=date.today()).order_by('enddate', 'startdate',)
        return render_to_response('events/archive.html', {
                'title': 'Upcoming events',
                'eventblocks': (
-                       { 'name': 'Events', 'events': events, 'link': '',},
+                       { 'name': 'Community Events', 'events': community_events, 'link': '',},
+                       { 'name': 'Other Events', 'events': other_events, 'link': '',},
                        { 'name': 'Training', 'events': training, 'link': 'training/',},
                ),
        }, NavContext(request, 'about'))
index 937af6b4d85061efcbd10abfbc190decffb731aa..a9416e04decf6bcd92939023dc49896a42143b4a 100644 (file)
@@ -69,9 +69,9 @@ function toggle_{{f.name}}() {
 {%else%}
    if (!v) {
 {%endif%}
-      $('#id_{{c}}').attr('disabled', true);
+      $('#id_{{c}}').attr('disabled', true).parents('tr').hide();
    } else {
-      $('#id_{{c}}').removeAttr('disabled');
+      $('#id_{{c}}').removeAttr('disabled').parents('tr').show();
    }
 {%endfor%}
 }
index 0425d4c46a66297c315c77fd924b51a863560553..737942e615c39d3192cab45a0f176a7704be5cb2 100644 (file)
            </div> <!-- pgFrontPlanetWrap -->
          </div> <!-- pgFrontPlanet -->
          <div id="pgFrontEvents" class="txtNewsEvent">
-           <a href="/about/events/">
-           <img src="/media/img/hdr/hdr_upcomingevents.png" width="123" height="10" alt="Upcoming Events" />
-           </a>
-           <div class="pgNewsEventsWrap">
-           {% for e in events %}
-            <p>
-             <span class="txtDate">{{e.displaydate|safe}}</span><br />
-             <a href="/about/event/{{e.id}}/">{{e.title}}</a><br/> ({{e.locationstring}})
-            </p>
-           {% endfor %}
+           {% if community_events %}
+             <h3 class="txtHomeHeader">
+               &gt;&nbsp;
+               <a href="/about/events/">Community Events</a>
+             </h3>
+             <div class="pgNewsEventsWrap">
+             {% for e in community_events %}
+              <p>
+               <span class="txtDate">{{e.displaydate|safe}}</span><br />
+               <a href="/about/event/{{e.id}}/">{{e.title}}</a><br/> ({{e.locationstring}})
+              </p>
+             {% endfor %}
+             </div>
+            {% endif %}
+            <h3 class="txtHomeHeader">
+              &gt;&nbsp;
+              <a href="/about/events/">{% if community_events %}Other {% endif %}Events</a>
+            </h3>
+            <div class="pgNewsEventsWrap">
+            {% for e in other_events %}
+             <p>
+              <span class="txtDate">{{e.displaydate|safe}}</span><br />
+              <a href="/about/event/{{e.id}}/">{{e.title}}</a><br/> ({{e.locationstring}})
+             </p>
+            {% endfor %}
            </div>
            <div style="margin-bottom: 10px;">
              <img class="pgArrowImage" src="/media/img/layout/blt_blu_arrow.png" width="6" height="5" alt="" />