django-cas-server/cas_server/admin.py

78 lines
3.0 KiB
Python
Raw Normal View History

2015-05-27 20:10:06 +00:00
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License version 3 for
# more details.
#
# You should have received a copy of the GNU General Public License version 3
# along with this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# (c) 2015 Valentin Samir
2015-05-27 19:56:39 +00:00
"""module for the admin interface of the app"""
2015-05-16 21:43:46 +00:00
from django.contrib import admin
2015-05-27 19:56:39 +00:00
from .models import ServiceTicket, ProxyTicket, ProxyGrantingTicket, User, ServicePattern
from .models import Username, ReplaceAttributName, ReplaceAttributValue, FilterAttributValue
from .forms import TicketForm
2015-05-16 21:43:46 +00:00
tickets_readonly_fields=('validate', 'service', 'service_pattern', 'creation', 'renew', 'single_log_out', 'value')
tickets_fields = ('validate', 'service', 'service_pattern', 'creation', 'renew', 'single_log_out')
2015-05-16 21:43:46 +00:00
class ServiceTicketInline(admin.TabularInline):
2015-05-27 19:56:39 +00:00
"""`ServiceTicket` in admin interface"""
2015-05-16 21:43:46 +00:00
model = ServiceTicket
extra = 0
form = TicketForm
readonly_fields = tickets_readonly_fields
fields = tickets_fields
2015-05-16 21:43:46 +00:00
class ProxyTicketInline(admin.TabularInline):
2015-05-27 19:56:39 +00:00
"""`ProxyTicket` in admin interface"""
2015-05-16 21:43:46 +00:00
model = ProxyTicket
extra = 0
form = TicketForm
readonly_fields = tickets_readonly_fields
fields = tickets_fields
2015-05-16 21:43:46 +00:00
class ProxyGrantingInline(admin.TabularInline):
2015-05-27 19:56:39 +00:00
"""`ProxyGrantingTicket` in admin interface"""
2015-05-16 21:43:46 +00:00
model = ProxyGrantingTicket
extra = 0
form = TicketForm
readonly_fields = tickets_readonly_fields
fields = tickets_fields[1:]
2015-05-16 21:43:46 +00:00
class UserAdmin(admin.ModelAdmin):
2015-05-27 19:56:39 +00:00
"""`User` in admin interface"""
2015-05-16 21:43:46 +00:00
inlines = (ServiceTicketInline, ProxyTicketInline, ProxyGrantingInline)
readonly_fields=('username', 'date', "session_key")
fields = ('username', 'date', "session_key")
2015-06-12 14:37:50 +00:00
list_display = ('username', 'date', "session_key")
2015-05-16 21:43:46 +00:00
2015-05-18 18:30:00 +00:00
class UsernamesInline(admin.TabularInline):
2015-05-27 19:56:39 +00:00
"""`Username` in admin interface"""
model = Username
2015-05-18 18:30:00 +00:00
extra = 0
class ReplaceAttributNameInline(admin.TabularInline):
2015-05-27 19:56:39 +00:00
"""`ReplaceAttributName` in admin interface"""
2015-05-18 18:30:00 +00:00
model = ReplaceAttributName
extra = 0
class ReplaceAttributValueInline(admin.TabularInline):
2015-05-27 19:56:39 +00:00
"""`ReplaceAttributValue` in admin interface"""
2015-05-18 18:30:00 +00:00
model = ReplaceAttributValue
extra = 0
class FilterAttributValueInline(admin.TabularInline):
2015-05-27 19:56:39 +00:00
"""`FilterAttributValue` in admin interface"""
2015-05-18 18:30:00 +00:00
model = FilterAttributValue
extra = 0
2015-05-16 21:43:46 +00:00
class ServicePatternAdmin(admin.ModelAdmin):
2015-05-27 19:56:39 +00:00
"""`ServicePattern` in admin interface"""
inlines = (
UsernamesInline,
ReplaceAttributNameInline,
ReplaceAttributValueInline,
FilterAttributValueInline
)
list_display = ('pos', 'name', 'pattern', 'proxy', 'single_log_out', 'proxy_callback', 'restrict_users')
2015-05-16 21:43:46 +00:00
admin.site.register(User, UserAdmin)
admin.site.register(ServicePattern, ServicePatternAdmin)