Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notice admin updated #225

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 2 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
46 changes: 25 additions & 21 deletions notices/admin.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,46 @@
from django.contrib import admin
from notices.models import Notice, BookmarkedNotice, TrendingInCollege
from import_export.admin import ImportExportModelAdmin
from notices.models import Notice, BookmarkedNotice, TrendingInCollege


class NoticeAdmin(ImportExportModelAdmin):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we shouldn't remove the ImportExportModelAdmin from Notice admin.

list_display = ('id', 'faculty', 'title', 'course_branch_year', 'created', 'modified', 'visible_for_student',
'visible_for_faculty', 'visible_for_hod', 'visible_for_others', 'visible_for_management'
)
list_display_links = ('title', 'faculty')
list_filter = ('category',)
list_per_page = 15
# search_fields = ['title', 'faculty']

class BookmarkedNoticeAdmin(admin.TabularInline):
model = BookmarkedNotice
extra = 1
fieldsets = (
(None, {
'classes': ('wide', 'extrapretty'),
'fields': ('faculty', 'category', 'title', 'description', 'file_attached', 'course_branch_year', 'visible_for_student', 'visible_for_faculty', 'visible_for_hod', 'visible_for_others', 'visible_for_management', ),
'classes': ('extrapretty', 'wide'),
'fields': (('user', 'notice'), 'pinned'),
}),
)


class BookmarkedNoticeAdmin(ImportExportModelAdmin):
list_display = ('user', 'pinned', 'notice', )
# list_filter = ('notice',)
list_per_page = 25

class NoticeAdmin(ImportExportModelAdmin):
list_display = (
'faculty', 'title', 'course_branch_year',
'created', 'modified', 'visible_for_student',
'visible_for_faculty', 'visible_for_hod',
'visible_for_others', 'visible_for_management'
)
list_display_links = ('title', 'faculty')
list_filter = ('faculty', 'category')
list_per_page = 100
inlines = [BookmarkedNoticeAdmin]
fieldsets = (
(None, {
'classes': ('extrapretty'),
'fields': (('user', 'notice'), 'pinned'),
'classes': ('wide', 'extrapretty'),
'fields': (
'faculty', 'category', 'title', 'description',
'file_attached', 'course_branch_year',
'visible_for_student', 'visible_for_faculty',
'visible_for_hod',
'visible_for_others', 'visible_for_management', ),
}),
)


class TrendingInCollegeAdmin(ImportExportModelAdmin):
class TrendingInCollegeAdmin(admin.ModelAdmin):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The admin class change isn't the part of this PR. We can have a separate PR for it. Can you please change it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure sir. 🙂

list_display = ('title', 'attachment', 'visibility')


admin.site.register(Notice, NoticeAdmin)
admin.site.register(BookmarkedNotice, BookmarkedNoticeAdmin)
admin.site.register(TrendingInCollege, TrendingInCollegeAdmin)