Commit 57bf6db346c54c2b1fb1686cdd8efed57930d696
1 parent
865762bc
Exists in
master
and in
5 other branches
Adding 'Action', 'Resource' and 'Action_Resource' to admin
Showing
2 changed files
with
22 additions
and
9 deletions
Show diff stats
core/admin.py
| 1 | 1 | from django.contrib import admin |
| 2 | 2 | |
| 3 | -# Register your models here. | |
| 3 | +from .models import Action, Resource, Action_Resource | |
| 4 | + | |
| 5 | +class ActionAdmin(admin.ModelAdmin): | |
| 6 | + list_display = ['name', 'created_date'] | |
| 7 | + search_fields = ['name', 'created_date'] | |
| 8 | + | |
| 9 | +class ResourceAdmin(admin.ModelAdmin): | |
| 10 | + list_display = ['name', 'created_date'] | |
| 11 | + search_fields = ['name', 'created_date'] | |
| 12 | + | |
| 13 | +class ActionResourceAdmin(admin.ModelAdmin): | |
| 14 | + list_display = ['action', 'resource'] | |
| 15 | + search_fields = ['action', 'resource'] | |
| 16 | + | |
| 17 | +admin.site.register(Action, ActionAdmin) | |
| 18 | +admin.site.register(Resource, ResourceAdmin) | |
| 19 | +admin.site.register(Action_Resource, ActionResourceAdmin) | |
| 4 | 20 | \ No newline at end of file | ... | ... |
core/models.py
| ... | ... | @@ -13,15 +13,15 @@ class Action(models.Model): |
| 13 | 13 | created_date = models.DateField(_('Created Date'), auto_now_add=True) |
| 14 | 14 | |
| 15 | 15 | |
| 16 | - def __init__(self, name): | |
| 17 | - self.name = name | |
| 16 | + #def __init__(self, name): | |
| 17 | + # self.name = name | |
| 18 | 18 | |
| 19 | 19 | class Meta: |
| 20 | 20 | verbose_name = "Action" |
| 21 | 21 | verbose_name_plural = "Actions" |
| 22 | 22 | |
| 23 | 23 | def __str__(self): |
| 24 | - pass | |
| 24 | + return self.name | |
| 25 | 25 | |
| 26 | 26 | |
| 27 | 27 | class Resource(models.Model): |
| ... | ... | @@ -38,7 +38,7 @@ class Resource(models.Model): |
| 38 | 38 | verbose_name_plural = "Resources" |
| 39 | 39 | |
| 40 | 40 | def __str__(self): |
| 41 | - pass | |
| 41 | + return self.name | |
| 42 | 42 | |
| 43 | 43 | |
| 44 | 44 | class Action_Resource(models.Model): |
| ... | ... | @@ -49,9 +49,6 @@ class Action_Resource(models.Model): |
| 49 | 49 | class Meta: |
| 50 | 50 | verbose_name = "Action_Resource" |
| 51 | 51 | verbose_name_plural = "Action_Resources" |
| 52 | - | |
| 53 | - def __str__(self): | |
| 54 | - pass | |
| 55 | 52 | |
| 56 | 53 | |
| 57 | 54 | class Notification(models.Model): |
| ... | ... | @@ -66,7 +63,7 @@ class Notification(models.Model): |
| 66 | 63 | verbose_name_plural = _("Notifications") |
| 67 | 64 | |
| 68 | 65 | def __str__(self): |
| 69 | - pass | |
| 66 | + return self.message | |
| 70 | 67 | |
| 71 | 68 | class Log(models.Model): |
| 72 | 69 | datetime = models.DateTimeField(_("Date and Time of action"), auto_now_add = True) | ... | ... |