diff options
author | Arun yadav <arunkumar5587@gmail.com> | 2012-04-30 12:53:38 +0530 |
---|---|---|
committer | Arun yadav <arunkumar5587@gmail.com> | 2012-04-30 12:53:38 +0530 |
commit | 123bc5f63ba7523229f1cb3cbce5cad8cc61c0fc (patch) | |
tree | 28c781d4fa23992a6659ba769e7327ce8b7b16b6 /gstudio/models.py | |
parent | 3a6f1bb43f49c071ea86944022e65b83fed0ad5d (diff) | |
parent | 80ae25b8ec38ba00eded83d7341dee851e77e838 (diff) | |
download | gnowsys-123bc5f63ba7523229f1cb3cbce5cad8cc61c0fc.tar.gz |
Merge branch 'master' of https://github.com/gnowgi/gnowsys-studio
Diffstat (limited to 'gstudio/models.py')
-rw-r--r-- | gstudio/models.py | 191 |
1 files changed, 189 insertions, 2 deletions
diff --git a/gstudio/models.py b/gstudio/models.py index 56e6a7a..100e4e2 100644 --- a/gstudio/models.py +++ b/gstudio/models.py @@ -106,6 +106,7 @@ import json import reversion from reversion.models import Version from django.core import serializers +from reversion.models import * NODETYPE_CHOICES = ( ('ND', 'Nodes'), @@ -376,6 +377,11 @@ class Node(NID): class Meta: abstract=False + @reversion.create_revision() + def save(self, *args, **kwargs): + super(Node, self).save(*args, **kwargs) # Call the "real" save() method. + + class Edge(NID): @@ -384,6 +390,11 @@ class Edge(NID): class Meta: abstract=False + @reversion.create_revision() + # Save for edge + def save(self, *args, **kwargs): + super(Edge, self).save(*args, **kwargs) # Call the "real" save() method. + class Metatype(Node): @@ -565,6 +576,12 @@ class Metatype(Node): verbose_name = _('metatype') verbose_name_plural = _('metatypes') + # Save for metatype + @reversion.create_revision() + def save(self, *args, **kwargs): + super(Metatype, self).save(*args, **kwargs) # Call the "real" save() method. + + @@ -1191,6 +1208,12 @@ class Nodetype(Node): verbose_name_plural = _('node types') permissions = (('can_view_all', 'Can view all'), ('can_change_author', 'Can change author'), ) + + # Save for nodetype + @reversion.create_revision() + def save(self, *args, **kwargs): + super(Nodetype, self).save(*args, **kwargs) # Call the "real" save() method. + class Objecttype(Nodetype): @@ -1370,6 +1393,12 @@ class Objecttype(Nodetype): permissions = (('can_view_all', 'Can view all'), ('can_change_author', 'Can change author'), ) + # Save for Objecttype + @reversion.create_revision() + def save(self, *args, **kwargs): + super(Objecttype, self).save(*args, **kwargs) # Call the "real" save() method. + + @@ -1379,10 +1408,10 @@ class Relationtype(Nodetype): ''' inverse = models.CharField(_('inverse name'), help_text=_('when subjecttypes are interchanged, what should be the name of the relation type? This is mandatory field. If the relation is symmetric, same name will do.'), max_length=255,db_index=True ) left_subjecttype = models.ForeignKey(NID,related_name="left_subjecttype_of", verbose_name='left role') - left_applicable_nodetypes = models.CharField(max_length=2,choices=NODETYPE_CHOICES,default='OT', verbose_name='Node types for left role') + left_applicable_nodetypes = models.CharField(max_length=2,choices=NODETYPE_CHOICES,default='OT', verbose_name='Applicable node types for left role') left_cardinality = models.IntegerField(null=True, blank=True, verbose_name='cardinality for the left role') right_subjecttype = models.ForeignKey(NID,related_name="right_subjecttype_of", verbose_name='right role') - right_applicable_nodetypes = models.CharField(max_length=2,choices=NODETYPE_CHOICES,default='OT', verbose_name='Node types for right role') + right_applicable_nodetypes = models.CharField(max_length=2,choices=NODETYPE_CHOICES,default='OT', verbose_name='Applicable node types for right role') right_cardinality = models.IntegerField(null=True, blank=True, verbose_name='cardinality for the right role') is_symmetrical = models.NullBooleanField(verbose_name='Is symmetrical?') is_reflexive = models.NullBooleanField(verbose_name='Is reflexive?') @@ -1411,6 +1440,12 @@ class Relationtype(Nodetype): permissions = (('can_view_all', 'Can view all'), ('can_change_author', 'Can change author'), ) + # Save for Relationtype + @reversion.create_revision() + def save(self, *args, **kwargs): + super(Relationtype, self).save(*args, **kwargs) # Call the "real" save() method. + + class Attributetype(Nodetype): ''' @@ -1454,6 +1489,12 @@ class Attributetype(Nodetype): permissions = (('can_view_all', 'Can view all'), ('can_change_author', 'Can change author'), ) + # Save for Attributetype + @reversion.create_revision() + def save(self, *args, **kwargs): + super(Attributetype, self).save(*args, **kwargs) # Call the "real" save() method. + + class Relation(Edge): @@ -1544,6 +1585,13 @@ class Relation(Edge): function that composes the right_subject and relation name, as in "x as a friend", "y as a sibling" ''' return '%s as a %s' % (self.right_subject, self.relationtype) + + + # Save for Relation + @reversion.create_revision() + def save(self, *args, **kwargs): + super(Relation, self).save(*args, **kwargs) # Call the "real" save() method. + class Attribute(Edge): @@ -1620,6 +1668,12 @@ class Attribute(Edge): for each in Objecttype.objects.all(): if attr.subjecttype.id == each.id: return each.get_members + + # Save for Attribute + @reversion.create_revision() + def save(self, *args, **kwargs): + super(Attribute, self).save(*args, **kwargs) # Call the "real" save() method. + @@ -1630,12 +1684,23 @@ class AttributeCharField(Attribute): def __unicode__(self): return self.title + + @reversion.create_revision() + def save(self, *args, **kwargs): + super(AttributeCharField, self).save(*args, **kwargs) # Call the "real" save() method. + + class AttributeTextField(Attribute): value = models.TextField(verbose_name='text') def __unicode__(self): return self.title + + @reversion.create_revision() + def save(self, *args, **kwargs): + super(AttributeTextField, self).save(*args, **kwargs) # Call the "real" save() method. + class AttributeIntegerField(Attribute): value = models.IntegerField(max_length=100, verbose_name='Integer') @@ -1643,6 +1708,12 @@ class AttributeIntegerField(Attribute): def __unicode__(self): return self.title + @reversion.create_revision() + def save(self, *args, **kwargs): + super(AttributeIntegerField, self).save(*args, **kwargs) # Call the "real" save() method. + + + class AttributeCommaSeparatedIntegerField(Attribute): value = models.CommaSeparatedIntegerField(max_length=100, verbose_name='integers separated by comma') @@ -1650,6 +1721,10 @@ class AttributeCommaSeparatedIntegerField(Attribute): def __unicode__(self): return self.title + @reversion.create_revision() + def save(self, *args, **kwargs): + super(AttributeCommaSeparatedIntegerField, self).save(*args, **kwargs) # Call the "real" save() method. + class AttributeBigIntegerField(Attribute): value = models.BigIntegerField(max_length=100, verbose_name='big integer') @@ -1664,12 +1739,19 @@ class AttributePositiveIntegerField(Attribute): def __unicode__(self): return self.title + @reversion.create_revision() + def save(self, *args, **kwargs): + super(AttributePositiveIntegerField, self).save(*args, **kwargs) # Call the "real" save() method. + + class AttributeDecimalField(Attribute): value = models.DecimalField(max_digits=3, decimal_places=2, verbose_name='decimal') def __unicode__(self): return self.title + def save(self, *args, **kwargs): + super(AttributeDecimalField, self).save(*args, **kwargs) # Call the "real" save() method. class AttributeFloatField(Attribute): @@ -1678,12 +1760,20 @@ class AttributeFloatField(Attribute): def __unicode__(self): return self.title + @reversion.create_revision() + def save(self, *args, **kwargs): + super(AttributeFloatField, self).save(*args, **kwargs) # Call the "real" save() method. + + class AttributeBooleanField(Attribute): value = models.BooleanField(verbose_name='boolean') def __unicode__(self): return self.title + def save(self, *args, **kwargs): + super(AttributeBooleanField, self).save(*args, **kwargs) # Call the "real" save() method. + class AttributeNullBooleanField(Attribute): @@ -1692,6 +1782,11 @@ class AttributeNullBooleanField(Attribute): def __unicode__(self): return self.title + @reversion.create_revision() + def save(self, *args, **kwargs): + super(AttributeNullBooleanField, self).save(*args, **kwargs) # Call the "real" save() method. + + class AttributeDateField(Attribute): value = models.DateField(max_length=100, verbose_name='date') @@ -1699,12 +1794,22 @@ class AttributeDateField(Attribute): def __unicode__(self): return self.title + @reversion.create_revision() + def save(self, *args, **kwargs): + super(AttributeDateField, self).save(*args, **kwargs) # Call the "real" save() method. + + class AttributeDateTimeField(Attribute): value = models.DateTimeField(max_length=100, verbose_name='date time') def __unicode__(self): return self.title + + @reversion.create_revision() + def save(self, *args, **kwargs): + super(AttributeDateTimeField, self).save(*args, **kwargs) # Call the "real" save() method. + class AttributeTimeField(Attribute): @@ -1713,6 +1818,11 @@ class AttributeTimeField(Attribute): def __unicode__(self): return self.title + @reversion.create_revision() + def save(self, *args, **kwargs): + super(AttributeTimeField, self).save(*args, **kwargs) # Call the "real" save() method. + + class AttributeEmailField(Attribute): value = models.CharField(max_length=100,verbose_name='value') @@ -1720,6 +1830,11 @@ class AttributeEmailField(Attribute): def __unicode__(self): return self.title + @reversion.create_revision() + def save(self, *args, **kwargs): + super(AttributeEmailField, self).save(*args, **kwargs) # Call the "real" save() method. + + class AttributeFileField(Attribute): value = models.FileField(upload_to='/media', verbose_name='file') @@ -1727,6 +1842,11 @@ class AttributeFileField(Attribute): def __unicode__(self): return self.title + @reversion.create_revision() + def save(self, *args, **kwargs): + super(AttributeFileField, self).save(*args, **kwargs) # Call the "real" save() method. + + class AttributeFilePathField(Attribute): value = models.FilePathField(verbose_name='path of file') @@ -1734,6 +1854,11 @@ class AttributeFilePathField(Attribute): def __unicode__(self): return self.title + @reversion.create_revision() + def save(self, *args, **kwargs): + super(AttributeFilePathField, self).save(*args, **kwargs) # Call the "real" save() method. + + class AttributeImageField(Attribute): value = models.ImageField(upload_to='/media', verbose_name='image') @@ -1741,6 +1866,11 @@ class AttributeImageField(Attribute): def __unicode__(self): return self.title + @reversion.create_revision() + def save(self, *args, **kwargs): + super(AttributeImageField, self).save(*args, **kwargs) # Call the "real" save() method. + + class AttributeURLField(Attribute): value = models.URLField(max_length=100, verbose_name='url') @@ -1748,6 +1878,11 @@ class AttributeURLField(Attribute): def __unicode__(self): return self.title + @reversion.create_revision() + def save(self, *args, **kwargs): + super(AttributeURLField, self).save(*args, **kwargs) # Call the "real" save() method. + + class AttributeIPAddressField(Attribute): value = models.IPAddressField(max_length=100, verbose_name='ip address') @@ -1755,6 +1890,11 @@ class AttributeIPAddressField(Attribute): def __unicode__(self): return self.title + @reversion.create_revision() + def save(self, *args, **kwargs): + super(AttributeIPAddressField, self).save(*args, **kwargs) # Call the "real" save() method. + + class Processtype(Nodetype): @@ -1778,6 +1918,10 @@ class Processtype(Nodetype): verbose_name_plural = _('process types') permissions = (('can_view_all', 'Can view all'), ('can_change_author', 'Can change author'), ) + @reversion.create_revision() + def save(self, *args, **kwargs): + super(Processtype, self).save(*args, **kwargs) # Call the "real" save() method. + @@ -1809,6 +1953,11 @@ class Systemtype(Nodetype): verbose_name_plural = _('system types') permissions = (('can_view_all', 'Can view all'), ('can_change_author', 'Can change author'), ) + + @reversion.create_revision() + def save(self, *args, **kwargs): + super(Systemtype, self).save(*args, **kwargs) # Call the "real" save() method. + class AttributeSpecification(Node): @@ -1842,6 +1991,12 @@ class AttributeSpecification(Node): permissions = (('can_view_all', 'Can view all'), ('can_change_author', 'Can change author'), ) + @reversion.create_revision() + def save(self, *args, **kwargs): + super(AttributeSpecification, self).save(*args, **kwargs) # Call the "real" save() method. + + + class RelationSpecification(Node): """ @@ -1865,11 +2020,17 @@ class RelationSpecification(Node): return self.composed_subject + class Meta: verbose_name = _('relation specification') permissions = (('can_view_all', 'Can view all'), ('can_change_author', 'Can change author'), ) + @reversion.create_revision() + def save(self, *args, **kwargs): + super(RelationSpecification, self).save(*args, **kwargs) # Call the "real" save() method. + + class NodeSpecification(Node): """ @@ -1901,6 +2062,12 @@ class NodeSpecification(Node): permissions = (('can_view_all', 'Can view all'), ('can_change_author', 'Can change author'), ) + @reversion.create_revision() + def save(self, *args, **kwargs): + super(NodeSpecification, self).save(*args, **kwargs) # Call the "real" save() method. + + + class Expression(Node): """ @@ -1928,6 +2095,11 @@ class Expression(Node): permissions = (('can_view_all', 'Can view all'), ('can_change_author', 'Can change author'), ) + @reversion.create_revision() + def save(self, *args, **kwargs): + super(Expression, self).save(*args, **kwargs) # Call the "real" save() method. + + class Union(Node): @@ -1939,6 +2111,11 @@ class Union(Node): def __unicode__(self): return self.title + @reversion.create_revision() + def save(self, *args, **kwargs): + super(Union, self).save(*args, **kwargs) # Call the "real" save() method. + + class Complement(Node): @@ -1950,6 +2127,11 @@ class Complement(Node): def __unicode__(self): return self.title + @reversion.create_revision() + def save(self, *args, **kwargs): + super(Complement, self).save(*args, **kwargs) # Call the "real" save() method. + + class Intersection(Node): """ Intersection of classes @@ -1958,6 +2140,11 @@ class Intersection(Node): def __unicode__(self): return self.title + + @reversion.create_revision() + def save(self, *args, **kwargs): + super(Intersection, self).save(*args, **kwargs) # Call the "real" save() method. + reversion.register(NID) |