Commit 5d37010a authored by okhin's avatar okhin 🚴

Adding django-nested-admin modules to allow nice nested values straight from...

Adding django-nested-admin modules to allow nice nested values straight from the admin page of a dossier.
parent 6829259c
Pipeline #1098 failed with stage
in 11 minutes and 43 seconds
......@@ -33,7 +33,8 @@ setup(name='meopol',
'django-haystack==2.6.0',
'pysolr==3.6.0',
'Whoosh==2.7.4',
'alabaster==0.7.10',
'alabaster==0.7.10',
'django-nested-admin',
],
extras_require={
# Full version hardcode for testing dependencies so that
......
......@@ -59,6 +59,7 @@ INSTALLED_APPS = (
'rest_framework',
'taggit',
'haystack',
'nested_admin',
# memopol apps
'core',
......
......@@ -248,4 +248,10 @@ urlpatterns = [
name="representative-search-name-autocomplete"
),
# Nested admin
url(
r'^nested_admin/',
include('nested_admin.urls')
),
] + legacy_patterns
......@@ -2,12 +2,12 @@
from django.contrib import admin
from .models import Dossier, Document, Proposal, Vote
import nested_admin
from representatives_recommendations.models import Recommendation
from representatives_recommendations.forms import RecommendationForm
class DossierAdmin(admin.ModelAdmin):
list_display = ('id', 'reference', 'title')
search_fields = ('reference', 'title')
from .models import Dossier, Document, Proposal, Vote
class DocumentAdmin(admin.ModelAdmin):
......@@ -18,6 +18,15 @@ class DocumentAdmin(admin.ModelAdmin):
return obj.dossier.reference
class RecommendationStackedInline(nested_admin.NestedStackedInline):
model = Recommendation
min_num = 1
max_num = 1
fields = ('title', 'description',
'recommendation', 'weight', 'id', 'proposal',)
form = RecommendationForm
class ProposalAdmin(admin.ModelAdmin):
list_display = (
'reference',
......@@ -25,11 +34,35 @@ class ProposalAdmin(admin.ModelAdmin):
'title',
'kind')
search_fields = ('reference', 'dossier__reference', 'title')
inlines = [
RecommendationStackedInline,
]
def dossier_reference(self, obj):
return obj.dossier.reference
class ProposalStackedInline(nested_admin.NestedStackedInline):
model = Proposal
extra = 0
can_delete = False
min_num = 0
readonly_fields = ('title', 'description',)
fields = ('title', 'description',)
show_change_link = True
inlines = [
RecommendationStackedInline,
]
class DossierAdmin(nested_admin.NestedModelAdmin):
list_display = ('id', 'reference', 'title')
search_fields = ('reference', 'title')
inlines = [
ProposalStackedInline,
]
class NoneMatchingFilter(admin.SimpleListFilter):
title = 'Representative'
parameter_name = 'representative'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment