diff --git a/aggregator/admin.py b/aggregator/admin.py index 7d46eb5c78..29c2dbb7a9 100644 --- a/aggregator/admin.py +++ b/aggregator/admin.py @@ -1,6 +1,13 @@ from django.contrib import admin -from .models import APPROVED_FEED, DENIED_FEED, Feed, FeedItem, FeedType, LocalDjangoCommunity +from .models import ( + APPROVED_FEED, + DENIED_FEED, + Feed, + FeedItem, + FeedType, + LocalDjangoCommunity, +) @admin.action(description="Mark selected feeds as approved.") diff --git a/aggregator/models.py b/aggregator/models.py index 64efe6acb3..6a5fc4fecf 100644 --- a/aggregator/models.py +++ b/aggregator/models.py @@ -4,8 +4,8 @@ import feedparser from django.conf import settings from django.contrib.auth.models import User -from django.db import models from django.core.exceptions import ValidationError +from django.db import models from django_countries.fields import CountryField from django_push.subscriber import signals as push_signals from django_push.subscriber.models import Subscription @@ -203,6 +203,7 @@ def feed_updated(sender, notification, **kwargs): ("Antarctica", "Antarctica"), ] + class LocalDjangoCommunity(models.Model): name = models.CharField(max_length=120) description = models.TextField() @@ -211,7 +212,9 @@ class LocalDjangoCommunity(models.Model): country = CountryField() continent = models.CharField(choices=CONTINENTS, max_length=15) website_url = models.URLField(max_length=250, default=None, blank=True, null=True) - event_site_url = models.URLField(max_length=250, default=None, blank=True, null=True) + event_site_url = models.URLField( + max_length=250, default=None, blank=True, null=True + ) is_active = models.BooleanField(default=True) created_at = models.DateTimeField(auto_now_add=True) @@ -219,17 +222,19 @@ class Meta: constraints = [ models.CheckConstraint( check=( - models.Q(website_url__isnull=False, event_site_url__isnull=False) | - models.Q(website_url__isnull=True, event_site_url__isnull=False) | - models.Q(website_url__isnull=False, event_site_url__isnull=True) + models.Q(website_url__isnull=False, event_site_url__isnull=False) + | models.Q(website_url__isnull=True, event_site_url__isnull=False) + | models.Q(website_url__isnull=False, event_site_url__isnull=True) ), - name="website_url_and_or_event_site_url" + name="website_url_and_or_event_site_url", ), ] def clean(self): if not self.website_url and not self.event_site_url: - raise ValidationError("You must provide at least a website or event site URL") + raise ValidationError( + "You must provide at least a website or event site URL" + ) def __str__(self): return self.name diff --git a/aggregator/urls.py b/aggregator/urls.py index e5e3a6d0d6..32f5af9578 100644 --- a/aggregator/urls.py +++ b/aggregator/urls.py @@ -4,7 +4,11 @@ urlpatterns = [ path("", views.index, name="community-index"), - path("local/", views.LocalDjangoCommunitiesListView.as_view(), name="local-django-communities"), + path( + "local/", + views.LocalDjangoCommunitiesListView.as_view(), + name="local-django-communities", + ), path("mine/", views.my_feeds, name="community-my-feeds"), path("/", views.FeedListView.as_view(), name="community-feed-list"), path("add//", views.add_feed, name="community-add-feed"), diff --git a/djangoproject/templates/aggregator/index.html b/djangoproject/templates/aggregator/index.html index 0a616fb000..5d509db941 100644 --- a/djangoproject/templates/aggregator/index.html +++ b/djangoproject/templates/aggregator/index.html @@ -4,7 +4,7 @@

Forum

{% include "includes/forum.html" %} - +

Local Django Community

To find your local Django community, please Click Here diff --git a/djangoproject/templates/aggregator/local-django-community.html b/djangoproject/templates/aggregator/local-django-community.html index 603300b2ca..8cb669898c 100644 --- a/djangoproject/templates/aggregator/local-django-community.html +++ b/djangoproject/templates/aggregator/local-django-community.html @@ -3,47 +3,47 @@ {% block content %} {# Group meetups by country and then by location #} -{% regroup django_communities|dictsort:"continent" by continent as grouped_django_communities %} + {% regroup django_communities|dictsort:"continent" by continent as grouped_django_communities %} -

Local Django Communities

- +

Local Django Communities

+

Table of contents

- - -{% for local_django_community in grouped_django_communities %} -
-

{{ local_django_community.grouper.title }}

-
    - {% for django_community in local_django_community.list %} -
  • -

    {{ django_community.name }}

    -

    {{ django_community.city }}, {{ django_community.country }}   - {% if django_community.is_active %} - Active - {% else %} - Inactive - {% endif %} -

    -

    {{ django_community.description|safe }}

    -

    - {% if django_community.website_url %} - Community Website   - {% endif %} - {% if django_community.event_site_url %} - Event Website - {% endif %} -

    -
  • + + + {% for local_django_community in grouped_django_communities %} +
    +

    {{ local_django_community.grouper.title }}

    +
      + {% for django_community in local_django_community.list %} +
    • +

      {{ django_community.name }}

      +

      {{ django_community.city }}, {{ django_community.country }}   + {% if django_community.is_active %} + Active + {% else %} + Inactive + {% endif %} +

      +

      {{ django_community.description|safe }}

      +

      + {% if django_community.website_url %} + Community Website   + {% endif %} + {% if django_community.event_site_url %} + Event Website + {% endif %} +

      +
    • + {% endfor %} +
    +
    + {% endfor %} -
-
- -{% endfor %} {##} {% endblock %}