diff options
author | Anuja <anujag@anujag-Latitude-D630.(none)> | 2012-04-26 15:45:13 +0530 |
---|---|---|
committer | Anuja <anujag@anujag-Latitude-D630.(none)> | 2012-04-26 15:45:13 +0530 |
commit | eebf47e459a51288494ca2a3c8ae19a0ffbf4eac (patch) | |
tree | d2b613abb61be9567b3fc703ad798177f9b605f0 /gstudio/admin | |
parent | 546cfb06395189d476c53c1f059013dc8d51a8b8 (diff) | |
download | gnowsys-eebf47e459a51288494ca2a3c8ae19a0ffbf4eac.tar.gz |
Modified Relation and Attribute admin forms
Diffstat (limited to 'gstudio/admin')
-rw-r--r-- | gstudio/admin/attribute.py | 10 | ||||
-rw-r--r-- | gstudio/admin/forms.py | 16 | ||||
-rw-r--r-- | gstudio/admin/relation.py | 15 |
3 files changed, 25 insertions, 16 deletions
diff --git a/gstudio/admin/attribute.py b/gstudio/admin/attribute.py index 336509e..7a34cb8 100644 --- a/gstudio/admin/attribute.py +++ b/gstudio/admin/attribute.py @@ -6,15 +6,23 @@ from django.utils.html import escape from gstudio.admin.forms import AttributeAdminForm from gstudio.models import * import reversion +from django.template.defaultfilters import slugify class AttributeAdmin(reversion.VersionAdmin): + fieldsets=((_('Attribute'),{'fields': ('subject','subject_scope','attributetype','attributetype_scope','svalue','value_scope','last_update','creation_date')}), + +) + + class Media: js = ("gstudio/js/gstudiojs.js",) def save_model(self, request, attribute, form, change): - attribute.title = attribute.composed_attribution + attribute.title = attribute.composed_sentence + attribute.slug = slugify(attribute.title) attribute.save() + diff --git a/gstudio/admin/forms.py b/gstudio/admin/forms.py index 37b578c..a2415c1 100644 --- a/gstudio/admin/forms.py +++ b/gstudio/admin/forms.py @@ -154,7 +154,7 @@ class RelationtypeAdminForm(forms.ModelForm): super(RelationtypeAdminForm, self).__init__(*args, **kwargs) prior = ManyToManyRel(Nodetype, 'id') post = ManyToManyRel(Nodetype, 'id') - + self.fields['priornodes'].widget = RelatedFieldWidgetWrapper( @@ -207,18 +207,6 @@ class RelationAdminForm(forms.ModelForm): AppNodeList = AppNode.objects.all() return AppNodeList - - - - - - - - - - - - class Meta: @@ -289,7 +277,7 @@ class AttributetypeAdminForm(forms.ModelForm): super(AttributetypeAdminForm, self).__init__(*args, **kwargs) prior = ManyToManyRel(Nodetype, 'id') post = ManyToManyRel(Nodetype, 'id') - + self.fields['sites'].initial = [Site.objects.get_current()] self.fields['priornodes'].widget = RelatedFieldWidgetWrapper( self.fields['priornodes'].widget, prior, self.admin_site) diff --git a/gstudio/admin/relation.py b/gstudio/admin/relation.py index 688ad6e..3d2f2e4 100644 --- a/gstudio/admin/relation.py +++ b/gstudio/admin/relation.py @@ -5,12 +5,25 @@ from django.utils.translation import ugettext_lazy as _ from gstudio.admin.forms import RelationAdminForm import reversion +from django.template.defaultfilters import slugify class RelationAdmin(reversion.VersionAdmin): - fieldsets=((_('Relation'),{'fields': ('title','last_update','creation_date','relationtype_scope','relationtype','left_subject_scope','left_subject' ,'right_subject_scope','right_subject')}), + fieldsets=((_('Relation'),{'fields': ('relationtype','relationtype_scope','left_subject' ,'left_subject_scope','right_subject','right_subject_scope','last_update','creation_date')}), ) + + def get_title(self, edge): + """Return the title with word count and number of comments""" + title = _('%(title)s (%(word_count)i words)') % \ + {'title': nodetype.title, 'word_count': nodetype.word_count} + comments = nodetype.comments.count() + if comments: + return _('%(title)s (%(comments)i comments)') % \ + {'title': title, 'comments': comments} + return title + get_title.short_description = _('title') def save_model(self, request, relation, form, change): relation.title = relation.composed_sentence + relation.slug = slugify(relation.title) relation.save() |