Add usergroup listing module
authorMagnus Hagander <magnus@hagander.net>
Wed, 8 May 2013 20:07:30 +0000 (22:07 +0200)
committerMagnus Hagander <magnus@hagander.net>
Wed, 8 May 2013 20:07:30 +0000 (22:07 +0200)
Jonathan Katz

pgweb/pugs/__init__.py [new file with mode: 0644]
pgweb/pugs/admin.py [new file with mode: 0644]
pgweb/pugs/models.py [new file with mode: 0644]
pgweb/pugs/views.py [new file with mode: 0644]
pgweb/settings.py
pgweb/urls.py
pgweb/util/contexts.py
templates/pugs/index.html [new file with mode: 0644]

diff --git a/pgweb/pugs/__init__.py b/pgweb/pugs/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/pgweb/pugs/admin.py b/pgweb/pugs/admin.py
new file mode 100644 (file)
index 0000000..a436eed
--- /dev/null
@@ -0,0 +1,11 @@
+from django.contrib import admin
+
+from util.admin import PgwebAdmin
+from models import *
+
+class PUGAdmin(PgwebAdmin):
+       list_display = ('title', 'approved', )
+       list_filter = ('approved', )
+       search_fields = ('title', )
+
+admin.site.register(PUG, PUGAdmin)
diff --git a/pgweb/pugs/models.py b/pgweb/pugs/models.py
new file mode 100644 (file)
index 0000000..0f7aaea
--- /dev/null
@@ -0,0 +1,17 @@
+from django.db import models
+from pgweb.util.bases import PgModel
+
+class PUG(PgModel, models.Model):
+    """
+    contains information about a local PostgreSQL user group
+    """
+    country = models.ForeignKey('core.Country')
+    org = models.ForeignKey('core.Organisation', null=True, blank=True, help_text='Organization that manages the PUG and its contents')
+    approved = models.BooleanField(null=False, blank=False, default=False)
+    locale = models.CharField(max_length=255, help_text="Locale where the PUG meets, e.g. 'New York City'")
+    title = models.CharField(max_length=255, help_text="Title/Name of the PUG, e.g. 'NYC PostgreSQL User Group'")
+    website_url = models.TextField(null=True, blank=True)
+    mailing_list_url = models.TextField(null=True, blank=True)
+
+    def __unicode__(self):
+        return self.title
diff --git a/pgweb/pugs/views.py b/pgweb/pugs/views.py
new file mode 100644 (file)
index 0000000..9d7f8ac
--- /dev/null
@@ -0,0 +1,23 @@
+from django.shortcuts import render_to_response
+
+from pgweb.util.decorators import cache
+from pgweb.util.contexts import NavContext
+
+from models import PUG
+
+def index(request):
+    """
+    contains list of PUGs, in country/locale alphabetical order
+    """
+    pug_list = []
+    for pug in PUG.objects.filter(approved=True).order_by('country__name', 'title').all():
+        if pug_list and pug_list[-1].get('country') == pug.country.name:
+            pug_list['pugs'].append(pug)
+        else:
+            pug_list.append({
+                'country': pug.country.name,
+                'pugs': [pug]
+            })
+    return render_to_response('pugs/index.html', {
+        'pug_list': pug_list,
+    }, NavContext(request, 'community'))
index c4e69589e1bedeb915ba2a8ddd95d65c8aa7eebf..8bf9fde6e87379cac8cd2306a4124ff2a6fc21f3 100644 (file)
@@ -110,6 +110,7 @@ INSTALLED_APPS = [
     'pgweb.featurematrix',
        'pgweb.pwn',
        'pgweb.search',
+    'pgweb.pugs',
 ]
 
 
index 0d7f8770b810638ba573ded39c7c0e7ec6f1fc57..66ff168cfe0be3471cc2e76f1f418a91bafed4a1 100644 (file)
@@ -56,6 +56,7 @@ urlpatterns = patterns('',
     (r'^community/lists/listinfo/$', 'lists.views.listinfo'),
     (r'^community/survey/vote/(\d+)/$', 'survey.views.vote'),
     (r'^community/survey[/\.](\d+)(-.*)?/$', 'survey.views.results'),
+    (r'^community/user-groups/$', 'pugs.views.index'),
        (r'^community/weeklynews/$', 'pwn.views.index'),
        (r'^community/weeklynews/pwn(\d{4})(\d{2})(\d{2})/$', 'pwn.views.post'),
 
index 7618fb5eef1b462e93303c50cfd246742d25ee97..c091a4c5b4680efe92ff275a0a1d21eaf42b5cda 100644 (file)
@@ -51,6 +51,7 @@ sitenav = {
                        {'title': 'Archives',   'link':'/list/'},
                ]},
                {'title': 'IRC',                'link':'/community/irc/'},
+               {'title': 'Local User Groups',  'link':'/community/user-groups/'},
                {'title': 'Featured Users',     'link':'/about/users/'},
                {'title': 'International Sites','link':'/community/international/'},
                {'title': 'Propaganda',         'link':'/community/propaganda/'},
diff --git a/templates/pugs/index.html b/templates/pugs/index.html
new file mode 100644 (file)
index 0000000..0e5c61d
--- /dev/null
@@ -0,0 +1,27 @@
+{%extends "base/page.html"%}
+{%block title%}Local PostgreSQL User Groups (PUGS){%endblock%}
+{%block contents%}
+
+<h1>Local User Groups</h1>
+<p>The PostgreSQL community is proud to have many local chapters that advocate and educate users about PostgreSQL.  Below is a list of PostgreSQL User Groups (PUGs) sorted by country and local area.  If you would like to start a PostgreSQL User Group, please join the <a href="{% url lists.views.subscribe %}">pgsql-advocacy mailing list</a> and describe the PUG that you want to create.</p>
+<p>If a PUG already exists in your area, follow the URLs below to find out how to attend and participate.</p>
+
+
+{% for pug_group in pug_list %}
+  <h2>{{ pug_group.country }}</h2>
+  <ul>
+  {% for pug in pug_group.pugs %}
+    <li>
+      <strong>{{ pug.locale }}</strong>:
+      {{ pug.title }}
+      {% if pug.website_url %}
+        (<a href="{{ pug.website_url }}">website</a>)
+      {% endif %}
+      {% if pug.mailing_list_url %}
+        (<a href="{{ pug.mailing_list_url }}">mailing list</a>)
+      {% endif %}
+    </li>
+  {% endfor %}
+  </ul>
+{% endfor %}
+{%endblock%}