diff options
author | shefali shetty <sshefali44@gmail.com> | 2012-05-03 12:20:58 +0530 |
---|---|---|
committer | shefali shetty <sshefali44@gmail.com> | 2012-05-03 12:20:58 +0530 |
commit | 974f2f6221459cde5187fa0f60132224a8963b80 (patch) | |
tree | 3acee0ad0e7ea5d12f6e10668989d6d2f7bbe89c /gstudio/models.py | |
parent | 7f9656341b47f6e1aeba7c650217f5c654a80005 (diff) | |
parent | c59a5bea01179051d337262751f04a166ae33114 (diff) | |
download | gnowsys-974f2f6221459cde5187fa0f60132224a8963b80.tar.gz |
Merge remote branch 'gn/master'
Diffstat (limited to 'gstudio/models.py')
-rw-r--r-- | gstudio/models.py | 198 |
1 files changed, 195 insertions, 3 deletions
diff --git a/gstudio/models.py b/gstudio/models.py index 8952bde..65262cc 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'), @@ -323,6 +324,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): @@ -331,6 +337,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): @@ -512,6 +523,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. + + @@ -1140,6 +1157,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): @@ -1319,6 +1342,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. + + @@ -1328,10 +1357,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?') @@ -1360,6 +1389,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): ''' @@ -1403,6 +1438,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): @@ -1493,6 +1534,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): @@ -1569,6 +1617,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. + @@ -1579,12 +1633,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') @@ -1592,6 +1657,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') @@ -1599,6 +1670,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') @@ -1613,12 +1688,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): @@ -1627,12 +1709,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): @@ -1641,6 +1731,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') @@ -1648,12 +1743,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): @@ -1662,6 +1767,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') @@ -1669,6 +1779,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') @@ -1676,6 +1791,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') @@ -1683,6 +1803,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') @@ -1690,6 +1815,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') @@ -1697,6 +1827,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') @@ -1704,6 +1839,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): @@ -1727,6 +1867,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. + @@ -1758,6 +1902,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): @@ -1791,6 +1940,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): """ @@ -1814,11 +1969,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): """ @@ -1850,6 +2011,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): """ @@ -1877,6 +2044,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): @@ -1888,6 +2060,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): @@ -1899,6 +2076,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 @@ -1907,6 +2089,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) @@ -1959,5 +2146,10 @@ post_save.connect(ping_directories_handler, sender=Nodetype, post_save.connect(ping_external_urls_handler, sender=Nodetype, dispatch_uid='gstudio.nodetype.post_save.ping_external_urls') +class Peer(User): + """Subclass for non-human users""" + def __unicode__(self): + return self.ip - + ip = models.IPAddressField("Peer's IP address") + pkey = models.CharField(("Peer's public-key"), max_length=255) |