Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# -*- coding: utf-8 -*-
from django.contrib import admin
from django.shortcuts import render
from .models import ImpostorLog
@admin.register(ImpostorLog)
class ImpostorAdmin(admin.ModelAdmin):
fields = ('impostor', 'imposted_as', 'logged_in', 'impostor_ip')
list_display = ('impostor', 'imposted_as', 'impostor_ip', 'logged_in', 'logged_out', 'token')
list_editable = ()
actions_on_top = False
actions_on_bottom = False
ordering = ('-logged_in', 'impostor')
readonly_fields = ('impostor', 'imposted_as', 'impostor_ip', 'logged_in', 'logged_out', 'token')
search_fields = ('impostor__username', 'imposted_as__username')
def add_view(self, request, form_url='', extra_context=None):
request.method = 'GET'
return super(ImpostorAdmin, self).add_view(request, form_url, extra_context)
def change_view(self, request, object_id, form_url='', extra_context=None):
request.method = 'GET'
def save(self, *args, **kwargs):
"""
Custom save method
:param args:
:param kwargs:
:return:
"""
if not self.token and self.impostor:
self.token = str(uuid.uuid4())
super(ImpostorLog, self).save(*args, **kwargs)