Skip to content

Commit

Permalink
Added subproject admin (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
pwhipp committed Oct 16, 2014
1 parent 5206c4b commit c413c95
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
1 change: 1 addition & 0 deletions core/settings/includes/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@
("Content",
("cvs.CV",
"projects.Project",
"projects.SubProject",
"pages.Page",
"blog.BlogPost",
"generic.ThreadedComment",
Expand Down
1 change: 1 addition & 0 deletions cvs/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class CVProjectInline(admin.StackedInline):
model = cm.CVProject
extra = 1
fields = ('project',
'subproject',
'from_date',
'to_date',
'position',
Expand Down
19 changes: 17 additions & 2 deletions projects/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class CVProjectInline(admin.StackedInline):
model = cm.CVProject
exclude = ('cv',)
readonly_fields = ('cv_link',)
fields = ('from_date',
fields = ('subproject',
'from_date',
'to_date',
'position',
'activities',
Expand All @@ -40,12 +41,18 @@ def cv_link(self, instance):
return mark_safe(u'<a href="{u}">{name}</a>'.format(u=instance.cv.admin_url, name=instance.cv.title))


class SubProjectInline(admin.TabularInline):
extra = 1
model = pm.SubProject
fields = ('name',)


class ProjectAdmin(admin.ModelAdmin):
list_display = ('name', 'from_date', 'to_date', 'locality', 'region')
list_filter = ('countries', 'to_date')
search_fields = ('title', 'region')
filter_horizontal = ('countries', 'cccs_subthemes', 'cccs_subsectors', 'ifc_subthemes', 'ifc_sectors')
inlines = (CVProjectInline,)
inlines = (CVProjectInline, SubProjectInline)
fieldsets = ((None, {'fields': ('title_en',
'title_fr',
'title_ru',
Expand Down Expand Up @@ -194,3 +201,11 @@ class IFCSectorAdmin(HasProjectsAdmin):

admin.site.register(pm.IFCSector, IFCSectorAdmin)


class SubProjectAdmin(admin.ModelAdmin):
list_display = ('project', 'name')
list_filter = ('project',)
search_fields = ('project__name', 'name')

admin.site.register(pm.SubProject, SubProjectAdmin)

7 changes: 6 additions & 1 deletion projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,9 @@ class SubProject(models.Model):
name = models.CharField(max_length=128)

class Meta:
unique_together = ('project', 'name')
unique_together = ('project', 'name')
verbose_name = 'Sub-project'
verbose_name_plural = 'Sub-projects'

def __unicode__(self):
return u'{0}'.format(self.name)

0 comments on commit c413c95

Please sign in to comment.