Add conf file to configure project name

This commit is contained in:
Stefan Wehrmeyer 2023-02-03 15:26:20 +01:00
parent 9f402f476a
commit 2521759625
5 changed files with 15 additions and 7 deletions

View file

@ -12,6 +12,7 @@ from froide.helper.admin_utils import make_choose_object_action, make_emptyfilte
from froide.helper.widgets import TagAutocompleteWidget from froide.helper.widgets import TagAutocompleteWidget
from froide.organization.models import Organization from froide.organization.models import Organization
from . import conf
from .api_views import GovernmentPlanViewSet from .api_views import GovernmentPlanViewSet
from .auth import get_allowed_plans, has_limited_access from .auth import get_allowed_plans, has_limited_access
from .forms import ( from .forms import (
@ -33,8 +34,8 @@ api_router.register(r"governmentplan", GovernmentPlanViewSet, basename="governme
class GovPlanAdminSite(admin.AdminSite): class GovPlanAdminSite(admin.AdminSite):
site_header = "Regierungsvorhaben" site_header = conf.GOVPLAN_NAME
site_url = "/koalitionstracker/" site_url = None
class GovernmentPlanAdminForm(GovernmentPlanForm): class GovernmentPlanAdminForm(GovernmentPlanForm):

View file

@ -4,6 +4,8 @@ from django.utils.translation import gettext_lazy as _
from cms.toolbar_base import CMSToolbar from cms.toolbar_base import CMSToolbar
from cms.toolbar_pool import toolbar_pool from cms.toolbar_pool import toolbar_pool
from . import conf
class GovPlanToolbar(CMSToolbar): class GovPlanToolbar(CMSToolbar):
def populate(self): def populate(self):
@ -12,7 +14,7 @@ class GovPlanToolbar(CMSToolbar):
and self.request.current_page.application_namespace != "govplan" and self.request.current_page.application_namespace != "govplan"
): ):
return return
menu = self.toolbar.get_or_create_menu("govplan-menu", "Koalitionstracker") menu = self.toolbar.get_or_create_menu("govplan-menu", conf.GOVPLAN_NAME)
url = reverse( url = reverse(
"admin:app_list", "admin:app_list",

4
froide_govplan/conf.py Normal file
View file

@ -0,0 +1,4 @@
from django.conf import settings
GOVPLAN_ENABLE_FOIREQUEST = getattr(settings, "GOVPLAN_ENABLE_FOIREQUEST", True)
GOVPLAN_NAME = getattr(settings, "GOVPLAN_NAME", "GovPlan")

View file

@ -21,7 +21,8 @@ from froide.georegion.models import GeoRegion
from froide.organization.models import Organization from froide.organization.models import Organization
from froide.publicbody.models import Category, Jurisdiction, PublicBody from froide.publicbody.models import Category, Jurisdiction, PublicBody
from .utils import TAG_NAME, make_request_url from . import conf
from .utils import make_request_url
try: try:
from cms.models.fields import PlaceholderField from cms.models.fields import PlaceholderField
@ -317,7 +318,7 @@ class GovernmentPlan(models.Model):
visibility=FoiRequest.VISIBILITY.VISIBLE_TO_PUBLIC, visibility=FoiRequest.VISIBILITY.VISIBLE_TO_PUBLIC,
public_body=self.responsible_publicbody, public_body=self.responsible_publicbody,
) )
.filter(tags__name=TAG_NAME) .filter(tags__name=conf.GOVPLAN_NAME)
.filter(reference=self.get_foirequest_reference()) .filter(reference=self.get_foirequest_reference())
.order_by("-created_at") .order_by("-created_at")
) )

View file

@ -3,7 +3,7 @@ from urllib.parse import quote, urlencode
from django.conf import settings from django.conf import settings
from django.urls import reverse from django.urls import reverse
TAG_NAME = "Koalitionstracker" from . import conf
def make_request_url(plan, publicbody): def make_request_url(plan, publicbody):
@ -19,7 +19,7 @@ def make_request_url(plan, publicbody):
"subject": subject.encode("utf-8"), "subject": subject.encode("utf-8"),
"body": body, "body": body,
"ref": plan.get_foirequest_reference(), "ref": plan.get_foirequest_reference(),
"tags": TAG_NAME, "tags": conf.GOVPLAN_NAME,
} }
hide_features = ["hide_public", "hide_similar", "hide_draft"] hide_features = ["hide_public", "hide_similar", "hide_draft"]