Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jun 5, 2023
1 parent 3bf154a commit 1478bb6
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 46 deletions.
9 changes: 8 additions & 1 deletion aggregator/admin.py
Original file line number Diff line number Diff line change
@@ -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.")
Expand Down
19 changes: 12 additions & 7 deletions aggregator/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -211,25 +212,29 @@ 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)

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
6 changes: 5 additions & 1 deletion aggregator/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("<feed_type_slug>/", views.FeedListView.as_view(), name="community-feed-list"),
path("add/<feed_type_slug>/", views.add_feed, name="community-add-feed"),
Expand Down
2 changes: 1 addition & 1 deletion djangoproject/templates/aggregator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<h2>Forum</h2>
{% include "includes/forum.html" %}

<h2>Local Django Community</h2>
To find your local Django community, please
<a href="/community/local/">Click Here</a>
Expand Down
72 changes: 36 additions & 36 deletions djangoproject/templates/aggregator/local-django-community.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}


<h2>Local Django Communities</h2>
<h2>Local Django Communities</h2>

<h3>Table of contents<a class="plink" href="#table-of-contents"></a></h3>
<ul>
{% for local_django_community in grouped_django_communities %}
<li><a href="#{{ local_django_community.grouper.title }}-meetups">{{ local_django_community.grouper.title }}</a></li>
{% endfor %}
{% for local_django_community in grouped_django_communities %}
<li><a href="#{{ local_django_community.grouper.title }}-meetups">{{ local_django_community.grouper.title }}</a></li>
{% endfor %}
</ul>


{% for local_django_community in grouped_django_communities %}
<div class="section">
<h2>{{ local_django_community.grouper.title }}<a class="plink" href="#{{ local_django_community.grouper.title }}-meetups"></a></h2>
<ul style="list-style-type:none;">
{% for django_community in local_django_community.list %}
<li>
<h3 id="{{ django_community.slug }}-team">{{ django_community.name }}<a class="plink" href="#{{ django_community.slug }}-meetup"></a></h3>
<p class="meta">{{ django_community.city }}, {{ django_community.country }} &nbsp;
{% if django_community.is_active %}
Active
{% else %}
Inactive
{% endif %}
</p>
<p>{{ django_community.description|safe }}</p>
<p>
{% if django_community.website_url %}
<a href="{{ django_community.website_url }}">Community Website</a> &nbsp;
{% endif %}
{% if django_community.event_site_url %}
<a href="{{ django_community.event_site_url }}">Event Website</a>
{% endif %}
</p>
</li>


{% for local_django_community in grouped_django_communities %}
<div class="section">
<h2>{{ local_django_community.grouper.title }}<a class="plink" href="#{{ local_django_community.grouper.title }}-meetups"></a></h2>
<ul style="list-style-type:none;">
{% for django_community in local_django_community.list %}
<li>
<h3 id="{{ django_community.slug }}-team">{{ django_community.name }}<a class="plink" href="#{{ django_community.slug }}-meetup"></a></h3>
<p class="meta">{{ django_community.city }}, {{ django_community.country }} &nbsp;
{% if django_community.is_active %}
Active
{% else %}
Inactive
{% endif %}
</p>
<p>{{ django_community.description|safe }}</p>
<p>
{% if django_community.website_url %}
<a href="{{ django_community.website_url }}">Community Website</a> &nbsp;
{% endif %}
{% if django_community.event_site_url %}
<a href="{{ django_community.event_site_url }}">Event Website</a>
{% endif %}
</p>
</li>
{% endfor %}
</ul>
</div>

{% endfor %}
</ul>
</div>

{% endfor %}
{##}
{% endblock %}

0 comments on commit 1478bb6

Please sign in to comment.