summaryrefslogtreecommitdiff
path: root/gstudio/admin
diff options
context:
space:
mode:
Diffstat (limited to 'gstudio/admin')
-rw-r--r--gstudio/admin/attribute.py10
-rw-r--r--gstudio/admin/forms.py16
-rw-r--r--gstudio/admin/relation.py15
3 files changed, 25 insertions, 16 deletions
diff --git a/gstudio/admin/attribute.py b/gstudio/admin/attribute.py
index 336509e8..7a34cb8e 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 37b578c8..a2415c10 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 688ad6ef..3d2f2e4d 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()