Skip to content

Commit

Permalink
Merge pull request #1477 from laws-africa/legislation-profiles
Browse files Browse the repository at this point in the history
locality legislation view uses entity profiles from locality
  • Loading branch information
longhotsummer authored Aug 25, 2023
2 parents 72a9043 + 1566aac commit d48f36e
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 27 deletions.
18 changes: 10 additions & 8 deletions lawlibrary/templates/liiweb/locality_legislation_list.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{% extends 'liiweb/locality_legislation_list.html' %}
{% block breadcrumbs %}
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="{{ breadcrumb_link }}">{{ locality_legislation_title }}</a>
</li>
<li class="breadcrumb-item active" aria-current="page">{{ locality.name }}</li>
</ol>
</nav>
<div class="container">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="{{ breadcrumb_link }}">{{ locality_legislation_title }}</a>
</li>
<li class="breadcrumb-item active" aria-current="page">{{ locality.name }}</li>
</ol>
</nav>
</div>
{% endblock %}
7 changes: 6 additions & 1 deletion liiweb/templates/liiweb/legislation_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@
{% trans 'Legislation' %}
{% endblock %}
{% block page-content %}
{% block breadcrumbs %}{% endblock %}
{% block entity-profile %}
{% if entity_profile %}
<div class="mt-3">{% include 'peachjam/_entity_profile.html' %}</div>
{% endif %}
{% endblock %}
<section class="pb-5">
<div class="container">
{% block breadcrumbs %}{% endblock %}
{% block page-heading %}
<h1 class="my-4">{% trans 'Legislation' %}</h1>
{% endblock %}
Expand Down
18 changes: 10 additions & 8 deletions liiweb/templates/liiweb/locality_legislation_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
{% load i18n %}
{% block title %}{{ locality_legislation_title }}{% endblock %}
{% block breadcrumbs %}
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="{% url 'locality_legislation' %}">{{ locality_legislation_title }}</a>
</li>
<li class="breadcrumb-item active" aria-current="page">{{ locality.name }}</li>
</ol>
</nav>
<div class="container">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="{% url 'locality_legislation' %}">{{ locality_legislation_title }}</a>
</li>
<li class="breadcrumb-item active" aria-current="page">{{ locality.name }}</li>
</ol>
</nav>
</div>
{% endblock %}
{% block page-heading %}
<h1 class="my-4">{{ page_heading }}</h1>
Expand Down
2 changes: 2 additions & 0 deletions liiweb/views/legislation.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,7 @@ def get_context_data(self, **kwargs):
locality=self.locality,
locality_legislation_title="Provincial Legislation",
page_heading=_("%(locality)s Legislation" % {"locality": self.locality}),
entity_profile=self.locality.entity_profile.first(),
entity_profile_title=self.locality.name,
**kwargs,
)
18 changes: 10 additions & 8 deletions open_by_laws/templates/open_by_laws/municipal_by_laws_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
{% blocktrans with locality=locality.name %}{{ locality }} By-laws{% endblocktrans %}
{% endblock %}
{% block breadcrumbs %}
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="{% url 'home_page' %}">{% trans 'Municipalities' %}</a>
</li>
<li class="breadcrumb-item active" aria-current="page">{{ locality }}</li>
</ol>
</nav>
<div class="container">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="{% url 'home_page' %}">{% trans 'Municipalities' %}</a>
</li>
<li class="breadcrumb-item active" aria-current="page">{{ locality }}</li>
</ol>
</nav>
</div>
{% endblock %}
{% block page-heading %}
<h1 class="my-4">{% blocktrans with locality=locality.name %}{{ locality }} By-laws{% endblocktrans %}</h1>
Expand Down
1 change: 1 addition & 0 deletions peachjam/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,7 @@ class LocalityAdmin(admin.ModelAdmin):
list_display = ("name", "jurisdiction", "code")
prepopulated_fields = {"code": ("name",)}
search_fields = ("name", "code")
inlines = [EntityProfileInline]


@admin.register(Judge)
Expand Down
4 changes: 4 additions & 0 deletions peachjam/models/core_document_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from cobalt.uri import FrbrUri
from countries_plus.models import Country
from django.conf import settings
from django.contrib.contenttypes.fields import GenericRelation
from django.contrib.postgres.fields import ArrayField
from django.core.exceptions import ValidationError
from django.core.files import File
Expand Down Expand Up @@ -87,6 +88,9 @@ class Locality(models.Model):
Country, on_delete=models.PROTECT, verbose_name=_("jurisdiction")
)
code = models.CharField(_("code"), max_length=20, null=False)
entity_profile = GenericRelation(
"peachjam.EntityProfile", verbose_name=_("profile")
)

class Meta:
verbose_name = _("locality")
Expand Down
8 changes: 6 additions & 2 deletions peachjam/models/taxonomies.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
from django.contrib.contenttypes.fields import GenericRelation
from django.db import models
from django.utils.text import slugify
from django.utils.translation import gettext_lazy as _
from treebeard.mp_tree import MP_Node

from peachjam.models import CoreDocument, EntityProfile
from peachjam.models import CoreDocument


class Taxonomy(MP_Node):
name = models.CharField(_("name"), max_length=255)
slug = models.SlugField(_("slug"), max_length=255, unique=True)
node_order_by = ["name"]
entity_profile = GenericRelation(
"peachjam.EntityProfile", verbose_name=_("profile")
)

class Meta:
verbose_name = _("taxonomies")
Expand All @@ -21,7 +25,7 @@ def __str__(self):
def get_entity_profile(self):
"""Get the entity profile for this taxonomy, starting with the current taxonomy and then
looking up the tree until one is found."""
entity_profile = EntityProfile.objects.filter(object_id=self.pk).first()
entity_profile = self.entity_profile.first()
if entity_profile:
return entity_profile
if self.is_root():
Expand Down

0 comments on commit d48f36e

Please sign in to comment.