1- from django import forms
21from django .contrib import admin
2+ from .models import (
3+ Sourcebook , Descriptor , Type , Focus , Ability , Skill , Equipment ,
4+ Cypher , Artifact , Attack , Character , FocusAbility , TypeAbility ,
5+ CharacterSkill , CharacterEquipment , CharacterAbility , CharacterCypher ,
6+ CharacterArtifact , Creature
7+ )
38admin .site .site_header = 'Cypher System'
49admin .site .site_title = 'Cypher System'
510admin .site .index_title = 'Admin'
611
712# Register your models here.
8- from .models import (
9- Sourcebook , Descriptor , Type , Focus , Ability , Skill , Equipment , Cypher , Artifact , Attack , Character ,
10- FocusAbility , TypeAbility , CharacterSkill , CharacterEquipment , CharacterAbility , CharacterCypher , CharacterArtifact
11- )
13+
1214
1315@admin .register (Sourcebook )
1416class SourcebookAdmin (admin .ModelAdmin ):
1517 list_display = ('name' ,)
1618 search_fields = ['name' ]
1719
20+
1821@admin .register (Descriptor )
1922class DescriptorAdmin (admin .ModelAdmin ):
20- list_display = ('name' , 'prefix' , 'truncated_description' , 'slug' , 'sourcebook' )
23+ list_display = (
24+ 'name' , 'prefix' , 'truncated_description' , 'slug' , 'sourcebook' )
25+ prepopulated_fields = {'slug' : ('name' ,)}
2126 search_fields = ['name' ]
2227
28+
2329class TypeAbilitiesInline (admin .TabularInline ):
2430 model = TypeAbility
2531 autocomplete_fields = ['ability' ]
2632 extra = 0
33+
2734 def get_queryset (self , request ):
2835 qs = super (TypeAbilitiesInline , self ).get_queryset (request )
2936 qs = qs .prefetch_related ('ability' )
3037 return qs
3138
39+
3240@admin .register (Type )
3341class TypeAdmin (admin .ModelAdmin ):
3442 fieldsets = [
35- ('TYPE DEFINITION' , {'fields' : [('name' ), ('description' ), ('base_abilities' ), ('slug' , 'sourcebook' )]}),
36- ('BASE STATS' ,
37- {'fields' : [
38- ('might_pool' , 'speed_pool' , 'intellect_pool' ),
39- ('might_edge' , 'speed_edge' , 'intellect_edge' ),
40- ('cypher_limit' , 'effort' , 'pool_points' )
41- ]}
43+ (
44+ 'TYPE DEFINITION' , {
45+ 'fields' : [
46+ ('name' ), ('description' ),
47+ ('base_abilities' ), ('slug' , 'sourcebook' )
48+ ]}
49+ ),
50+ (
51+ 'BASE STATS' , {
52+ 'fields' : [
53+ ('might_pool' , 'speed_pool' , 'intellect_pool' ),
54+ ('might_edge' , 'speed_edge' , 'intellect_edge' ),
55+ ('cypher_limit' , 'effort' , 'pool_points' )
56+ ]}
4257 )
4358 ]
4459 inlines = [TypeAbilitiesInline ]
45- list_display = ('name' , 'might_pool' , 'speed_pool' , 'intellect_pool' , 'truncated_description' , 'slug' , 'sourcebook' )
60+ list_display = (
61+ 'name' , 'might_pool' , 'speed_pool' , 'intellect_pool' ,
62+ 'truncated_description' , 'slug' , 'sourcebook' )
4663 prepopulated_fields = {'slug' : ('name' ,)}
4764 search_fields = ['name' ]
4865
66+
4967class CharacterAbilitiesInline (admin .TabularInline ):
5068 model = CharacterAbility
5169 autocomplete_fields = ['ability' ]
5270 extra = 0
5371 fields = ('ability' , 'note' )
72+
5473 def get_queryset (self , request ):
5574 qs = super (CharacterAbilitiesInline , self ).get_queryset (request )
5675 qs = qs .prefetch_related ('ability' )
5776 return qs
5877
78+
5979class FocusAbilitiesInline (admin .TabularInline ):
6080 model = FocusAbility
6181 autocomplete_fields = ['ability' ]
6282 extra = 0
83+
6384 def get_queryset (self , request ):
6485 qs = super (FocusAbilitiesInline , self ).get_queryset (request )
6586 qs = qs .prefetch_related ('ability' )
6687 return qs
6788
89+
6890@admin .register (Focus )
6991class FocusAdmin (admin .ModelAdmin ):
7092 inlines = [FocusAbilitiesInline ]
7193 list_display = ('name' , 'truncated_description' , 'slug' , 'sourcebook' )
94+ prepopulated_fields = {'slug' : ('name' ,)}
7295 search_fields = ['name' ]
7396
97+
7498class AbilityFociInline (admin .TabularInline ):
7599 model = FocusAbility
76100 autocomplete_fields = ['focus' ]
@@ -79,6 +103,7 @@ class AbilityFociInline(admin.TabularInline):
79103 verbose_name = "Related Focus"
80104 verbose_name_plural = "Related Foci"
81105
106+
82107class AbilityTypesInline (admin .TabularInline ):
83108 model = TypeAbility
84109 autocomplete_fields = ['type' ]
@@ -87,112 +112,170 @@ class AbilityTypesInline(admin.TabularInline):
87112 verbose_name = "Related Type"
88113 verbose_name_plural = "Related Types"
89114
115+
90116@admin .register (Ability )
91117class AbilityAdmin (admin .ModelAdmin ):
92118 inlines = [AbilityFociInline , AbilityTypesInline ]
93- list_display = ('name' , 'usage' , 'cost' , 'truncated_description' , 'slug' , 'sourcebook' )
119+ list_display = (
120+ 'name' , 'usage' , 'cost' , 'truncated_description' , 'slug' , 'sourcebook' )
94121 prepopulated_fields = {'slug' : ('name' ,)}
95122 search_fields = ['name' ]
96123
124+
97125@admin .register (Skill )
98126class SkillAdmin (admin .ModelAdmin ):
99127 list_display = ('name' ,)
100128 search_fields = ['name' ]
101129
130+
102131@admin .register (Equipment )
103132class EquipmentAdmin (admin .ModelAdmin ):
104- list_display = ('name' , 'type' , 'base_cost' , 'truncated_notes' , 'slug' , 'sourcebook' )
133+ list_display = (
134+ 'name' , 'type' , 'base_cost' , 'truncated_notes' , 'slug' , 'sourcebook' )
105135 prepopulated_fields = {'slug' : ('name' ,)}
106136 search_fields = ['name' , 'type' , 'base_cost' ]
107137
138+
108139@admin .register (Cypher )
109140class CypherAdmin (admin .ModelAdmin ):
110- list_display = ('name' , 'level_range' , 'truncated_effect' , 'slug' , 'sourcebook' )
141+ list_display = (
142+ 'name' , 'level_range' , 'truncated_effect' , 'slug' , 'sourcebook' )
111143 prepopulated_fields = {'slug' : ('name' ,)}
112144 search_fields = ['name' ]
113145
146+
114147@admin .register (Artifact )
115148class ArtifactAdmin (admin .ModelAdmin ):
116- list_display = ('name' , 'level_range' , 'truncated_form' , 'truncated_effect' , 'depletion' , 'slug' , 'sourcebook' )
149+ list_display = (
150+ 'name' , 'level_range' , 'truncated_form' , 'truncated_effect' ,
151+ 'depletion' , 'slug' , 'sourcebook' )
117152 prepopulated_fields = {'slug' : ('name' ,)}
118153 search_fields = ['name' ]
119154
155+
120156class AttackInline (admin .TabularInline ):
121157 model = Attack
122158 extra = 0
123159 fields = ('name' , 'modifier' , 'damage' )
124160
161+
125162class CharacterEquipmentInline (admin .TabularInline ):
126163 model = CharacterEquipment
127164 autocomplete_fields = ['equipment' ]
128165 extra = 0
129166 fields = ('equipment' , 'quantity' , 'brief_note' )
130167
168+
131169class CharacterSkillsInline (admin .TabularInline ):
132170 model = CharacterSkill
133171 autocomplete_fields = ['skill' ]
134172 extra = 0
135173 fields = ('skill' , 'skill_level' )
136174
175+
137176class CharacterCyphersInline (admin .TabularInline ):
138177 model = CharacterCypher
139178 autocomplete_fields = ['cypher' ]
140179 extra = 0
141180 fields = ('cypher' , 'level' , 'appearance' )
142181
182+
143183class CharacterArtifactsInline (admin .TabularInline ):
144184 model = CharacterArtifact
145185 autocomplete_fields = ['artifact' ]
146186 extra = 0
147187 fields = ('artifact' , 'level' )
148188
189+
149190@admin .register (Character )
150191class CharacterAdmin (admin .ModelAdmin ):
151192 fieldsets = [
152- ('CHARACTER DEFINITION' ,
153- {'fields' : [
154- ('name' , 'slug' ), 'descriptor' , 'type' , 'focus' ,
155- ('cypher_limit' , 'effort' , 'tier' ),
156- ('armor' , 'money' , 'xp' ),
157- 'background' ,
158- 'notes' ,
159- 'portrait_link'
160- ]}
193+ (
194+ 'CHARACTER DEFINITION' , {
195+ 'fields' : [
196+ ('name' , 'slug' ), 'descriptor' , 'type' , 'focus' ,
197+ ('cypher_limit' , 'effort' , 'tier' ),
198+ ('armor' , 'money' , 'xp' ),
199+ 'background' ,
200+ 'notes' ,
201+ 'portrait_link'
202+ ]}
161203 ),
162- ('STATS' ,
163- {'fields' : [
164- ('might_pool' , 'might_current' , 'might_edge' ),
165- ('speed_pool' , 'speed_current' , 'speed_edge' ),
166- ('intellect_pool' , 'intellect_current' , 'intellect_edge' )
167- ]}
204+ (
205+ 'STATS' , {
206+ 'fields' : [
207+ ('might_pool' , 'might_current' , 'might_edge' ),
208+ ('speed_pool' , 'speed_current' , 'speed_edge' ),
209+ ('intellect_pool' , 'intellect_current' , 'intellect_edge' )
210+ ]}
168211 ),
169- ('DAMAGE TRACK' ,
170- {'fields' : [
171- ('recovery_roll' , 'one_action' , 'ten_minutes' , 'one_hour' , 'ten_hours' , 'impaired' , 'debilitated' )
172- ]}
212+ (
213+ 'DAMAGE TRACK' , {
214+ 'fields' : [
215+ (
216+ 'recovery_roll' , 'one_action' , 'ten_minutes' ,
217+ 'one_hour' , 'ten_hours' , 'impaired' , 'debilitated'
218+ )
219+ ]}
173220 ),
174- ('ADVANCEMENT' ,
175- {'fields' : [
176- (
177- 'tier_1_edge' , 'tier_1_effort' , 'tier_1_pools' , 'tier_1_skills' , 'tier_1_other' ,
178- 'tier_2_edge' , 'tier_2_effort' , 'tier_2_pools' , 'tier_2_skills' , 'tier_2_other'
179- ),
180- (
181- 'tier_3_edge' , 'tier_3_effort' , 'tier_3_pools' , 'tier_3_skills' , 'tier_3_other' ,
182- 'tier_4_edge' , 'tier_4_effort' , 'tier_4_pools' , 'tier_4_skills' , 'tier_4_other'
183- ),
184- (
185- 'tier_5_edge' , 'tier_5_effort' , 'tier_5_pools' , 'tier_5_skills' , 'tier_5_other' ,
186- 'tier_6_edge' , 'tier_6_effort' , 'tier_6_pools' , 'tier_6_skills' , 'tier_6_other'
187- )
188- ]}
221+ (
222+ 'ADVANCEMENT' , {
223+ 'fields' : [
224+ (
225+ 'tier_1_edge' , 'tier_1_effort' , 'tier_1_pools' ,
226+ 'tier_1_skills' , 'tier_1_other' ,
227+ 'tier_2_edge' , 'tier_2_effort' , 'tier_2_pools' ,
228+ 'tier_2_skills' , 'tier_2_other'
229+ ),
230+ (
231+ 'tier_3_edge' , 'tier_3_effort' , 'tier_3_pools' ,
232+ 'tier_3_skills' , 'tier_3_other' ,
233+ 'tier_4_edge' , 'tier_4_effort' , 'tier_4_pools' ,
234+ 'tier_4_skills' , 'tier_4_other'
235+ ),
236+ (
237+ 'tier_5_edge' , 'tier_5_effort' , 'tier_5_pools' ,
238+ 'tier_5_skills' , 'tier_5_other' ,
239+ 'tier_6_edge' , 'tier_6_effort' , 'tier_6_pools' ,
240+ 'tier_6_skills' , 'tier_6_other'
241+ )
242+ ]}
189243 )
190244 ]
191245 inlines = [
192- CharacterAbilitiesInline , AttackInline , CharacterSkillsInline , CharacterEquipmentInline ,
193- CharacterCyphersInline , CharacterArtifactsInline
246+ CharacterAbilitiesInline , AttackInline , CharacterSkillsInline ,
247+ CharacterEquipmentInline , CharacterCyphersInline ,
248+ CharacterArtifactsInline
194249 ]
195250 list_display = ('name' , 'descriptor' , 'type' , 'focus' , 'tier' , 'slug' )
196251 prepopulated_fields = {'slug' : ('name' ,)}
197252 save_as = True
198253 search_fields = ['name' ]
254+
255+
256+ @admin .register (Creature )
257+ class CreatureAdmin (admin .ModelAdmin ):
258+ fieldsets = [
259+ (
260+ 'CREATURE DEFINITION' , {
261+ 'fields' : [
262+ ('name' , 'slug' ),
263+ ('level' , 'health' , 'armor' ),
264+ ('damage_inflicted' , 'environment' ),
265+ ('motive' , 'movement' ),
266+ 'description' ,
267+ 'sourcebook' ,
268+ 'portrait_link'
269+ ]}
270+ ),
271+ (
272+ 'DETAILS' , {'fields' : [
273+ 'combat' , 'interaction' , 'modifications' ,
274+ 'use' , 'loot' , 'gm_intrusion'
275+ ]}
276+ )
277+ ]
278+ list_display = ('name' , 'level' , 'truncated_description' )
279+ prepopulated_fields = {'slug' : ('name' ,)}
280+ save_as = True
281+ search_fields = ['name' ]
0 commit comments