-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Add Homepage admin view (#723)"
This reverts commit 0acba20.
- Loading branch information
Showing
5 changed files
with
2 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,3 @@ | ||
from django.contrib import admin | ||
from mezzanine.utils.admin import SingletonAdmin | ||
# from django.contrib import admin | ||
|
||
from networkapi.homepage.models import ( | ||
Homepage, | ||
HomepageLeaders, | ||
HomepageNews, | ||
HomepageHighlights, | ||
) | ||
|
||
|
||
# Base class for the inline forms for People, News, and Highlights | ||
# containing the common config for each of the forms | ||
class FeatureInlineAdmin(admin.StackedInline): | ||
extra = 0 # Allows us to show the 'Add another' link | ||
min_num = 3 | ||
# We override the default template for stacked inlines so that we can | ||
# customize the label for each field | ||
template = 'admin/homepage/homepage/edit_inline/stacked.html' | ||
|
||
# To disable the icons that allow you to add/change the related models, | ||
# we set the flags that allow these operations to False on the widgets | ||
# associated with those related model fields. We override the formset | ||
# method to get access to those fields. | ||
def get_formset(self, request, obj=None, **kwargs): | ||
formset = super().get_formset(request, obj, **kwargs) | ||
base_fields = formset.form.base_fields | ||
|
||
for field in base_fields: | ||
base_fields[field].widget.can_add_related = False | ||
base_fields[field].widget.can_change_related = False | ||
base_fields[field].label = 'Feature' | ||
|
||
return formset | ||
|
||
# Only superusers can add new homepage fields | ||
def has_add_permission(self, request): | ||
return request.user.is_superuser | ||
|
||
|
||
class LeaderInlineAdmin(FeatureInlineAdmin): | ||
model = HomepageLeaders | ||
fields = ('leader',) | ||
|
||
|
||
class NewsInlineAdmin(FeatureInlineAdmin): | ||
model = HomepageNews | ||
fields = ('news',) | ||
min_num = 4 | ||
|
||
|
||
class HighlightInlineAdmin(FeatureInlineAdmin): | ||
model = HomepageHighlights | ||
fields = ('highlights',) | ||
|
||
|
||
class HomepageAdmin(SingletonAdmin): | ||
inlines = [ | ||
LeaderInlineAdmin, | ||
NewsInlineAdmin, | ||
HighlightInlineAdmin, | ||
] | ||
|
||
# We override this function so that we can rename the header shown for this | ||
# admin view | ||
def change_view(self, request, object_id, form_url='', extra_context=None): | ||
extra_context = extra_context or {} | ||
extra_context['title'] = 'Homepage Features' | ||
|
||
return super().change_view( | ||
request, | ||
object_id, | ||
form_url, | ||
extra_context=extra_context, | ||
) | ||
|
||
|
||
admin.site.register(Homepage, HomepageAdmin) | ||
# Register your models here. |
Empty file.
53 changes: 0 additions & 53 deletions
53
network-api/app/networkapi/homepage/templatetags/homepage_customization.py
This file was deleted.
Oops, something went wrong.
55 changes: 0 additions & 55 deletions
55
network-api/app/networkapi/templates/admin/homepage/homepage/edit_inline/stacked.html
This file was deleted.
Oops, something went wrong.
31 changes: 0 additions & 31 deletions
31
network-api/app/networkapi/templates/admin/homepage/homepage/includes/fieldset.html
This file was deleted.
Oops, something went wrong.