django-cas-server/cas_server/admin.py

104 lines
3.4 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.
#
2016-06-30 22:00:53 +00:00
# (c) 2015-2016 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 .models import FederatedIendityProvider
2015-05-27 19:56:39 +00:00
from .forms import TicketForm
2015-05-16 21:43:46 +00:00
2016-06-26 14:13:09 +00:00
TICKETS_READONLY_FIELDS = ('validate', 'service', 'service_pattern',
2015-06-12 16:10:52 +00:00
'creation', 'renew', 'single_log_out', 'value')
2016-06-26 14:13:09 +00:00
TICKETS_FIELDS = ('validate', 'service', 'service_pattern',
2015-06-12 16:10:52 +00:00
'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
2016-06-26 14:13:09 +00:00
readonly_fields = TICKETS_READONLY_FIELDS
fields = TICKETS_FIELDS
2015-06-12 16:10:52 +00:00
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
2016-06-26 14:13:09 +00:00
readonly_fields = TICKETS_READONLY_FIELDS
fields = TICKETS_FIELDS
2015-06-12 16:10:52 +00:00
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
2016-06-26 14:13:09 +00:00
readonly_fields = TICKETS_READONLY_FIELDS
fields = TICKETS_FIELDS[1:]
2015-05-16 21:43:46 +00:00
2015-06-12 16:10:52 +00:00
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)
2015-06-12 16:10:52 +00:00
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-06-12 16:10:52 +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
2015-06-12 16:10:52 +00:00
2015-05-18 18:30:00 +00:00
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
2015-06-12 16:10:52 +00:00
2015-05-18 18:30:00 +00:00
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
2015-06-12 16:10:52 +00:00
2015-05-18 18:30:00 +00:00
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-06-12 16:10:52 +00:00
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
)
2015-06-12 16:10:52 +00:00
list_display = ('pos', 'name', 'pattern', 'proxy',
'single_log_out', 'proxy_callback', 'restrict_users')
2015-05-16 21:43:46 +00:00
class FederatedIendityProviderAdmin(admin.ModelAdmin):
2016-07-04 18:02:00 +00:00
"""`FederatedIendityProvider` in admin interface"""
fields = ('pos', 'suffix', 'server_url', 'cas_protocol_version', 'verbose_name', 'display')
list_display = ('verbose_name', 'suffix', 'display')
2015-05-16 21:43:46 +00:00
admin.site.register(User, UserAdmin)
admin.site.register(ServicePattern, ServicePatternAdmin)
admin.site.register(FederatedIendityProvider, FederatedIendityProviderAdmin)