Skip to content
Open
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
33 changes: 33 additions & 0 deletions uipa_org/fixtures/regular.user.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[
{
"model": "account.user",
"pk": 2,
"fields": {
"password": "pbkdf2_sha256$600000$4RkadkjMlrpld6VzlCKmKU$F1iqZCndTSwbanwfbg6sZgjsuW2coh4uKUgzOobaJJU=",
"last_login": "2024-05-01T18:37:21Z",
"is_superuser": true,
"username": "lani",
"first_name": "Lani",
"last_name": "Aloha",
"email": "lani@uipa.org",
"is_staff": false,
"is_active": true,
"date_joined": "2024-04-30T22:40:55Z",
"organization_name": "",
"organization_url": "",
"language": "en",
"private": false,
"terms": true,
"profile_text": "",
"profile_photo": "",
"is_trusted": false,
"is_blocked": false,
"date_deactivated": null,
"is_deleted": false,
"date_left": null,
"notes": "",
"groups": [],
"user_permissions": []
}
}
]
17 changes: 5 additions & 12 deletions uipa_org/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ class UipaOrgThemeBase(Base):
SITE_NAME = "UIPA.org"
SITE_EMAIL = "info@uipa.org"
SITE_URL = 'http://localhost:8000'

FRONTEND_BUILD_DIR = THEME_ROOT.parent / "build"
STATIC_ROOT = values.Value(THEME_ROOT.parent / "public")

FIXTURE_DIRS = ('fixtures',)

@property
def STATICFILES_DIRS(self):
return [THEME_ROOT / "theme/static"] + super().STATICFILES_DIRS

@property
def TEMPLATES(self):
TEMP = super().TEMPLATES
Expand All @@ -53,20 +53,13 @@ def TEMPLATES(self):
TEMP[0]["DIRS"] = [
THEME_ROOT / "templates",
] + list(TEMP[0]["DIRS"])
cps = TEMP[0]["OPTIONS"]["context_processors"]
cps.extend(
[
# "sekizai.context_processors.sekizai",
# "cms.context_processors.cms_settings",
]
)
return TEMP

@property
def INSTALLED_APPS(self):
installed = super(UipaOrgThemeBase, self).INSTALLED_APPS
installed = (
installed.default +
installed.default +
[
"django.contrib.postgres",
"django.db.backends.postgresql",
Expand All @@ -77,7 +70,7 @@ def INSTALLED_APPS(self):
]
)
return installed

MIDDLEWARE = [
"django.middleware.locale.LocaleMiddleware", # needs to be before CommonMiddleware
"django.middleware.common.CommonMiddleware",
Expand Down
93 changes: 84 additions & 9 deletions uipa_org/settings/development.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,10 @@ class Dev(UipaOrgThemeBase):

CACHES = {"default": {"BACKEND": "django.core.cache.backends.dummy.DummyCache"}}

# setup GDAL and GEOS
GDAL_LIBRARY_PATH = values.Value('/usr/lib/libgdal.so.34', environ=True, environ_name="GDAL_LIBRARY_PATH",
environ_prefix="")
GEOS_LIBRARY_PATH = values.PathValue('/usr/lib/libgeos_c.so.1', environ=True, environ_name="GEOS_LIBRARY_PATH",
environ_prefix="")

ELASTICSEARCH_HOST = values.Value("localhost", environ=True, environ_name="ELASTICSEARCH_HOST")
ELASTICSEARCH_USER = values.Value("elastic", environ=True, environ_name="ELASTICSEARCH_USER")
ELASTICSEARCH_PASSWORD = values.Value("****", environ=True, environ_name="ELASTICSEARCH_PASSWORD")
ELASTICSEARCH_HOST = values.Value("localhost", environ_prefix=None, environ_name="ELASTICSEARCH_HOST")
ELASTICSEARCH_USER = values.Value("elastic", environ_prefix=None, environ_name="ELASTICSEARCH_USER")
ELASTICSEARCH_PASSWORD = values.Value("froide", environ_prefix=None, environ_name="ELASTICSEARCH_PASSWORD")

ELASTICSEARCH_DSL = {
"default": {
"hosts": "http://%s:9200" % ELASTICSEARCH_HOST,
Expand All @@ -36,6 +31,86 @@ def TEMPLATES(self):
TEMP[0]["OPTIONS"]["debug"] = True
return TEMP

LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'root': {
'level': 'DEBUG',
'handlers': ['uipa_org_logfile',],
},
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
},
'require_debug_true': {
'()': 'django.utils.log.RequireDebugTrue',
},
},
'formatters': {
'verbose': {
'format': '[%(asctime)s] %(levelname)s (pid: %(process)d) [%(name)s.%(module)s: %(funcName)s:%(lineno)d] %(message)s',
},
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
},
'console': {
'level': 'DEBUG',
'filters': ['require_debug_true'],
'class': 'logging.StreamHandler',
},
'uipa_org_logfile': {
'level': 'DEBUG',
'class': 'logging.handlers.RotatingFileHandler',
'filename': 'uipa_org_dev_app.log', # put in the working directory
'maxBytes': 1024*1024*5, # 5MB
'backupCount': 10,
'formatter': 'verbose',
},
},
'loggers': {
'froide': {
'handlers': ['uipa_org_logfile'],
'level': 'DEBUG',
'propagate': False,
},
'django': {
'handlers': ['uipa_org_logfile'],
'level': 'DEBUG',
'propagate': False,
},
# Use instead of 'django.request' to log all requests; added in Django 1.11.
'django.server': {
'handlers': ['uipa_org_logfile'],
'level': 'DEBUG',
'propagate': False,
},
'django.security': {
'handlers': ['uipa_org_logfile'],
'level': 'DEBUG',
'propagate': False,
},
'django.db.backends': {
'level': 'DEBUG',
'handlers': ['uipa_org_logfile'],
'propagate': False,
},
'django.template': {
'level': 'INFO',
'handlers': ['uipa_org_logfile'],
'propagate': False,
},
'uipa_org': {
'handlers': ['uipa_org_logfile'],
'level': 'DEBUG',
'propagate': False,
},
}
}

# Start of email settings
# Read the docs about these settings here: https://github.com/okfde/froide/blob/2dc1899cfe732c3f1d658f07ca86626dd5baa1a3/docs/configuration.rst#settings-for-sending-e-mail
# The exact settings can be seen https://github.com/okfde/froide/blob/2dc1899cfe732c3f1d658f07ca86626dd5baa1a3/froide/settings.py#L618
Expand Down
182 changes: 182 additions & 0 deletions uipa_org/templates/publicbody/show.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
{% extends 'publicbody/base.html' %}
{% load i18n %}
{% load static %}
{% load markup %}
{% load permission_helper %}
{% block title %}{{ object.name }} - {{ SITE_NAME }}{% endblock %}
{% block metadescription %}
{% spaceless %}
{% if object.classification %}
{% blocktrans with name=object.name classification=object.classification juris=object.jurisdiction.name site_name=SITE_NAME %}{{ name }} is a public agency ({{ classification }}) in {{ juris }} on {{ site_name }}{% endblocktrans %}
{% else %}
{% blocktrans with name=object.name juris=object.jurisdiction.name site_name=SITE_NAME %}{{ name }} is a public agency in {{ juris }} on {{ site_name }}{% endblocktrans %}
{% endif %}
{% endspaceless %}
{% endblock %}
{% block extra_head %}
{% if not object.confirmed %}<meta name="robots" content="noindex" />{% endif %}
<link rel="alternate"
type="application/rss+xml"
title="{% trans "RSS Feed" %}"
href="{% url 'foirequest-list_feed' publicbody=object.slug %}" />
<link rel="alternate"
type="application/atom+xml"
title="{% trans "Atom Feed" %}"
href="{% url 'foirequest-list_feed_atom' publicbody=object.slug %}" />
{% endblock %}
{% block app_body %}
<div itemscope itemtype="http://schema.org/Organization">
<h2 itemprop="name">{{ object.name }}</h2>

<p>{{ object.description }}</p>
<br>

{% if object.email and object.confirmed %}
<p>
<a class="btn btn-primary"
href="{% url 'foirequest-make_request' publicbody_slug=object.slug %}">{% blocktrans %}Make a Request to this public agency!{% endblocktrans %}</a>
</p>
{% endif %}
<div class="row">
<div class="col-lg-4 col-md-4 mb-5">
<dl>
<dt>{% blocktrans %}Jurisdiction{% endblocktrans %}:</dt>
<dd>
<a href="{{ object.jurisdiction.get_absolute_url }}">{{ object.jurisdiction }}</a>
</dd>
{% if object.classification %}
<dt>{% blocktrans %}Classification:{% endblocktrans %}</dt>
<dd>
{{ object.classification }}
</dd>
{% endif %}
{% with categories=object.categories.all %}
{% if categories %}
<dt>{% blocktrans %}Categories:{% endblocktrans %}</dt>
<dd>
{% for category in categories %}
{{ category.name }}
{% if not forloop.last %},{% endif %}
{% endfor %}
</dd>
{% endif %}
{% endwith %}
{% if object.url %}
<dt>{% blocktrans %}Website:{% endblocktrans %}</dt>
<dd>
<a href="{{ object.url }}" target="_blank" rel="noopener">{{ object.url|truncatechars:30 }}</a>
</dd>
{% endif %}
{% if object.email %}
<dt>{% blocktrans %}Email:{% endblocktrans %}</dt>
<dd>
<span itemprop="email">{{ object.email }}</span>
</dd>
{% endif %}
{% if object.fax %}
<dt>{% blocktrans %}Fax:{% endblocktrans %}</dt>
<dd>
<span itemprop="fax">{{ object.fax }}</span>
</dd>
{% endif %}
<dt>{% blocktrans %}Contact:{% endblocktrans %}</dt>
<dd>
{{ object.contact|urlizetrunc:35|linebreaksbr }}
</dd>
{% if object.file_index %}
<dt>{% blocktrans %}File Index:{% endblocktrans %}</dt>
<dd>
<a href="{{ object.file_index }}">{{ object.file_index|urlizetrunc:40 }}</a>
</dd>
{% endif %}
{% if object.org_chart %}
<dt>{% blocktrans %}Organization Chart:{% endblocktrans %}</dt>
<dd>
<a href="{{ object.org_chart }}">{{ object.org_chart|urlizetrunc:40 }}</a>
</dd>
{% endif %}
</dl>
{% if request.user.is_staff and request.user|has_perm:"publicbody.view_publicbody" %}
{% if object.confirmed %}
{% url 'admin:publicbody_publicbody_change' object.id as admin_url %}
{% else %}
{% url 'admin:publicbody_proposedpublicbody_change' object.id as admin_url %}
{% endif %}
<br />
<a class="btn btn-secondary mt-2" href="{{ admin_url }}">
<i class="fa fa-cog"></i>
{% trans "View on Admin site" %}
</a>
{% endif %}
</div>
<div class="col-lg-8 col-md-8">
{% if not object.confirmed %}
<div class="alert alert-warning">
<h3>{% trans "Proposal" %}</h3>
{% if object.created_by == request.user %}
<p>{% trans "You have proposed this public agency, but it has not been confirmed yet." %}</p>
{% else %}
<p>{% trans "This public agency has been proposed and has not been confirmed yet." %}</p>
{% endif %}
</div>
{% endif %}
{% if object.request_note %}
<div class="panel panel-info">
<div class="card-header">
<h3 class="card-title">{% trans "Special note" %}</h3>
</div>
<div class="card-body">{{ object.request_note_html|safe }}</div>
</div>
{% endif %}
{% if foirequest_count %}
<h3>{% trans "Summary of Results" %}</h3>
<table class="table">
{% for res in resolutions %}
<tr>
<td>
<span class="icon status-{{ res.resolution }}"></span>
</td>
<td>
{% block result_image %}
{% endblock result_image %}
<a href="{% url 'foirequest-list' publicbody=object.slug %}?status={{ res.url_slug }}">{{ res.name }}</a>
<br />
<small class="text-body-secondary">{{ res.description }}</small>
</td>
<td class="text-end">{{ res.count }}</td>
</tr>
{% endfor %}
</table>
<h3>
{% blocktrans count count=foirequest_count %}One requests to this public agency{% plural %}{{ count }} requests to this public agency{% endblocktrans %}
</h3>
<ul class="list-unstyled">
{% for object in foirequests %}
<li>{% include "foirequest/snippets/request_item.html" %}</li>
{% endfor %}
</ul>
<p>
<a href="{% url 'foirequest-list_feed' publicbody=object.slug %}">
<i class="fa fa-rss" aria-hidden="true"></i>
{% trans "RSS Feed" %}
</a>
<br />
<a href="{% url 'foirequest-list_feed_atom' publicbody=object.slug %}">
<i class="fa fa-rss-square" aria-hidden="true"></i>
{% trans "Atom Feed" %}
</a>
</p>
{% if foirequest_count > foirequests|length %}
<p>
<a href="{% url 'foirequest-list' publicbody=object.slug %}">
{% trans "See all FOI requests for this public agency" %}
</a>
</p>
{% endif %}
{% else %}
<p>{% trans "There are no requests for this public agency yet." %}</p>
{% endif %}
</div>
</div>
</div>
{% endblock %}