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
from django.contrib import admin | |
from django.contrib.admin.models import LogEntry, DELETION | |
from django.utils.html import escape | |
from django.urls import reverse | |
from django.utils.safestring import mark_safe | |
@admin.register(LogEntry) | |
class LogEntryAdmin(admin.ModelAdmin): | |
date_hierarchy = 'action_time' |
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
def has_add_permission(self, request): | |
return False | |
def has_change_permission(self, request, obj=None): | |
return False | |
def has_delete_permission(self, request, obj=None): | |
return False | |
def has_view_permission(self, request, obj=None): | |
return request.user.is_superuser |
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
from django.contrib.admin.models import DELETION | |
from django.utils.html import escape | |
from django.urls import reverse | |
from django.utils.safestring import mark_safe | |
def object_link(self, obj): | |
if obj.action_flag == DELETION: | |
link = escape(obj.object_repr) | |
else: | |
ct = obj.content_type |
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
from django.contrib.admin.models import LogEntry | |
@admin.register(LogEntry) | |
class LogEntryAdmin(admin.ModelAdmin): | |
# to have a date-based drilldown navigation in the admin page | |
date_hierarchy = 'action_time' | |
# to filter the resultes by users, content types and action flags | |
list_filter = [ | |
'user', |
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
import sys | |
import dropbox | |
from dropbox.files import WriteMode | |
from dropbox.exceptions import ApiError, AuthError | |
import datetime | |
dt = datetime.datetime.today() | |
TOKEN = '<Replace with your Access Token>' | |
LOCALFILE = '<Replace with the file that you want to backup>' | |
# Don't forget to add the file extension at the end of BACKUPPATH. |