Commit c482962182c18a6472f82a8883fd281ce65be414
1 parent
57bf6db3
Exists in
master
and in
5 other branches
Adding model Log to admin
Showing
2 changed files
with
10 additions
and
6 deletions
Show diff stats
core/admin.py
| 1 | 1 | from django.contrib import admin |
| 2 | 2 | |
| 3 | -from .models import Action, Resource, Action_Resource | |
| 3 | +from .models import Action, Resource, Action_Resource, Log | |
| 4 | 4 | |
| 5 | 5 | class ActionAdmin(admin.ModelAdmin): |
| 6 | 6 | list_display = ['name', 'created_date'] |
| ... | ... | @@ -14,6 +14,11 @@ class ActionResourceAdmin(admin.ModelAdmin): |
| 14 | 14 | list_display = ['action', 'resource'] |
| 15 | 15 | search_fields = ['action', 'resource'] |
| 16 | 16 | |
| 17 | +class LogAdmin(admin.ModelAdmin): | |
| 18 | + list_display = ['datetime', 'user', 'action_resource'] | |
| 19 | + search_fields = ['user'] | |
| 20 | + | |
| 17 | 21 | admin.site.register(Action, ActionAdmin) |
| 18 | 22 | admin.site.register(Resource, ResourceAdmin) |
| 19 | -admin.site.register(Action_Resource, ActionResourceAdmin) | |
| 20 | 23 | \ No newline at end of file |
| 24 | +admin.site.register(Action_Resource, ActionResourceAdmin) | |
| 25 | +admin.site.register(Log, LogAdmin) | |
| 21 | 26 | \ No newline at end of file | ... | ... |
core/models.py
| ... | ... | @@ -12,10 +12,6 @@ class Action(models.Model): |
| 12 | 12 | name = models.CharField(_('Name'), max_length = 100) |
| 13 | 13 | created_date = models.DateField(_('Created Date'), auto_now_add=True) |
| 14 | 14 | |
| 15 | - | |
| 16 | - #def __init__(self, name): | |
| 17 | - # self.name = name | |
| 18 | - | |
| 19 | 15 | class Meta: |
| 20 | 16 | verbose_name = "Action" |
| 21 | 17 | verbose_name_plural = "Actions" |
| ... | ... | @@ -49,6 +45,9 @@ class Action_Resource(models.Model): |
| 49 | 45 | class Meta: |
| 50 | 46 | verbose_name = "Action_Resource" |
| 51 | 47 | verbose_name_plural = "Action_Resources" |
| 48 | + | |
| 49 | + def __str__(self): | |
| 50 | + return ''.join([self.action.name, " / ", self.resource.name]) | |
| 52 | 51 | |
| 53 | 52 | |
| 54 | 53 | class Notification(models.Model): | ... | ... |