forked from Kamva-Academy/Kamva-Backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: make attributes django admin better
- Loading branch information
1 parent
880297b
commit 16ddbd8
Showing
2 changed files
with
35 additions
and
14 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,59 @@ | ||
from django.contrib import admin | ||
|
||
from apps.attributes.models.base import Attribute, IntrinsicAttribute, PerformableAction | ||
from apps.attributes.models.intrinsic_attributes import Enabled, Condition, Cost, Reward | ||
from apps.attributes.models.performable_actions import Buy, Submission, Transition | ||
|
||
|
||
class AttributeCustomAdmin(admin.ModelAdmin): | ||
list_display = ['title', 'get_related_attributes'] | ||
|
||
|
||
class IntrinsicAttributeCustomAdmin(AttributeCustomAdmin): | ||
list_display = AttributeCustomAdmin.list_display + ['value'] | ||
|
||
|
||
class PerformableActionCustomAdmin(admin.ModelAdmin): | ||
list_display = AttributeCustomAdmin.list_display + [] | ||
|
||
|
||
################ INTRINSIC ATTRIBUTES ################ | ||
|
||
|
||
@admin.register(Enabled) | ||
class EnabledCustomAdmin(admin.ModelAdmin): | ||
list_display = ['title', 'description', 'value'] | ||
class EnabledCustomAdmin(IntrinsicAttributeCustomAdmin): | ||
list_display = IntrinsicAttributeCustomAdmin.list_display + [] | ||
|
||
|
||
@admin.register(Condition) | ||
class ConditionCustomAdmin(admin.ModelAdmin): | ||
list_display = ['title', 'description', 'value'] | ||
class ConditionCustomAdmin(IntrinsicAttributeCustomAdmin): | ||
list_display = IntrinsicAttributeCustomAdmin.list_display + [] | ||
|
||
|
||
@admin.register(Cost) | ||
class CostCustomAdmin(admin.ModelAdmin): | ||
list_display = ['title', 'description', 'value'] | ||
class CostCustomAdmin(IntrinsicAttributeCustomAdmin): | ||
list_display = IntrinsicAttributeCustomAdmin.list_display + [] | ||
|
||
|
||
@admin.register(Reward) | ||
class RewardCustomAdmin(admin.ModelAdmin): | ||
list_display = ['title', 'description', 'value'] | ||
class RewardCustomAdmin(IntrinsicAttributeCustomAdmin): | ||
list_display = IntrinsicAttributeCustomAdmin.list_display + [] | ||
|
||
|
||
################ PERFORMABLE ACTIONS ################ | ||
|
||
|
||
@admin.register(Transition) | ||
class TransitionCustomAdmin(admin.ModelAdmin): | ||
list_display = ['title', 'description', 'destination_state_id'] | ||
class TransitionCustomAdmin(PerformableActionCustomAdmin): | ||
list_display = PerformableActionCustomAdmin.list_display + \ | ||
['destination_state_id'] | ||
|
||
|
||
@admin.register(Buy) | ||
class BuyCustomAdmin(admin.ModelAdmin): | ||
list_display = ['title', 'description'] | ||
class BuyCustomAdmin(PerformableActionCustomAdmin): | ||
list_display = PerformableActionCustomAdmin.list_display + [] | ||
|
||
|
||
@admin.register(Submission) | ||
class SubmissionCustomAdmin(admin.ModelAdmin): | ||
list_display = ['title', 'description'] | ||
class SubmissionCustomAdmin(PerformableActionCustomAdmin): | ||
list_display = PerformableActionCustomAdmin.list_display + [] |
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