Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make headshot backend configurable #292

Merged
merged 9 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11"]

services:
postgres:
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repos:

# Black config (Python formatter)
- repo: https://github.com/psf/black
rev: 22.3.0
rev: 24.4.2
hooks:
- id: black
exclude: ^(councilmatic_core/migrations/)
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The django-councilmatic app provides the core functionality for the `Councilmati

Requirements
------------
- Python >= 3.6
- Python >= 3.8

Features
--------
Expand Down
8 changes: 8 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Release notes for django-councilmatic

## Version 3.3

_Changes_

Allows storage backend for Person headshots to be configured via `COUNCILMATIC_HEADSHOT_STORAGE_BACKEND` setting.

**Release date:** 07-15-2024

## Version 3.2

_Changes_
Expand Down
3 changes: 1 addition & 2 deletions councilmatic_core/feeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ class EventsFeed(Feed):

title = settings.CITY_COUNCIL_NAME + " " + "Recent Events"
link = reverse_lazy("events")
description = "Recently announced events."

def item_link(self, event):
# return the Councilmatic URL for the event
Expand All @@ -272,7 +271,7 @@ def item_pubdate(self, event):
return event.start_time

def description(self, obj):
return "Events"
return "Recently Announced Events"

def items(self, obj):
return Event.objects.all()[: self.NUM_RECENT_EVENTS]
9 changes: 4 additions & 5 deletions councilmatic_core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@
import opencivicdata.legislative.models
import opencivicdata.core.models


static_storage = FileSystemStorage(
location=os.path.join(settings.STATIC_ROOT), base_url="/"
)

MANUAL_HEADSHOTS = (
settings.MANUAL_HEADSHOTS if hasattr(settings, "MANUAL_HEADSHOTS") else {}
HEADSHOT_STORAGE_BACKEND = getattr(
settings, "COUNCILMATIC_HEADSHOT_STORAGE_BACKEND", static_storage
)


Expand Down Expand Up @@ -62,7 +61,7 @@ class Person(opencivicdata.core.models.Person):

headshot = models.FileField(
upload_to="images/headshots",
storage=static_storage,
storage=HEADSHOT_STORAGE_BACKEND,
default="images/headshot_placeholder.png",
)

Expand Down Expand Up @@ -352,7 +351,7 @@ class Meta:
null=True,
# Membership will just unlink if the post goes away
on_delete=models.SET_NULL,
help_text=" The Post held by the member in the Organization.",
help_text=" The Post held by the member in the Organization.",
)


Expand Down
15 changes: 8 additions & 7 deletions councilmatic_core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,13 +366,14 @@ def get_context_data(self, **kwargs):
seo.update(settings.SITE_META)
if person.current_council_seat:
short_name = re.sub(r",.*", "", person.name)
seo[
"site_desc"
] = "%s - %s representative in %s. See what %s has been up to!" % (
person.name,
person.current_council_seat,
settings.CITY_COUNCIL_NAME,
short_name,
seo["site_desc"] = (
"%s - %s representative in %s. See what %s has been up to!"
% (
person.name,
person.current_council_seat,
settings.CITY_COUNCIL_NAME,
short_name,
)
)
else:
seo["site_desc"] = "Details on %s, %s" % (
Expand Down
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ DJANGO_SETTINGS_MODULE = tests.test_config
django_find_project = false
testpaths = tests
addopts = -sxv
pythonpath = .
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
setup(
name="django-councilmatic",
python_requires=">=3.6",
version="3.2",
version="3.3",
packages=find_packages(exclude=("tests",)),
include_package_data=True,
license="MIT License", # example license
Expand Down
Loading
Loading