rebelstuff

Keep track of your stuff
git clone https://git.ce9e.org/rebelstuff.git

commit
771380377130f0f49a96e3fb9301a96fb917edcd
parent
ebd3d3cc8bfaeee1d9f782a25e63da74012487c7
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2021-01-12 19:38
link to contract only if CONTRACT_TEMPLATE is set

Diffstat

M rebelstuff/admin.py 7 +++++++
M rebelstuff/templates/admin/rebelstuff/change_form.html 2 +-

2 files changed, 8 insertions, 1 deletions


diff --git a/rebelstuff/admin.py b/rebelstuff/admin.py

@@ -1,3 +1,4 @@
   -1     1 from django.conf import settings
    1     2 from django.contrib.auth.admin import UserAdmin
    2     3 from django.contrib.auth import models as auth_models
    3     4 from django.contrib import admin
@@ -29,6 +30,12 @@ class Site(admin.AdminSite):
   29    30                 app_dict['models'].append(CALENDAR_ITEM)
   30    31         return app_dict
   31    32 
   -1    33     def each_context(self, request):
   -1    34         return {
   -1    35             **super().each_context(request),
   -1    36             'CONTRACT_TEMPLATE': settings.CONTRACT_TEMPLATE,
   -1    37         }
   -1    38 
   32    39 
   33    40 class StuffAdmin(admin.ModelAdmin):
   34    41     list_display = ['name', 'amount', 'available']

diff --git a/rebelstuff/templates/admin/rebelstuff/change_form.html b/rebelstuff/templates/admin/rebelstuff/change_form.html

@@ -2,7 +2,7 @@
    2     2 {% load i18n admin_urls %}
    3     3 
    4     4 {% block object-tools-items %}
    5    -1     {% if opts.label == 'rebelstuff.Booking' %}
   -1     5     {% if opts.label == 'rebelstuff.Booking' and CONTRACT_TEMPLATE %}
    6     6         <li><a href="{% url opts|admin_urlname:'contract' original.pk %}">{% trans 'Contract' %}</a></li>
    7     7     {% endif %}
    8     8     {{ block.super }}