Skip to content

Commit

Permalink
Revert "Update models.py"
Browse files Browse the repository at this point in the history
This reverts commit b71763e.
  • Loading branch information
hakanaktas0 committed Nov 10, 2023
1 parent b71763e commit 8d09b5f
Showing 1 changed file with 35 additions and 37 deletions.
72 changes: 35 additions & 37 deletions project/backend/database/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,42 @@
from datetime import datetime


class SemanticTag(models.Model):
created_at = models.DateTimeField(auto_now_add=True)
label = models.CharField(max_length=50, unique=True)
desc = models.CharField(max_length=100)
parent_tag = models.ForeignKey("SemanticTag", on_delete=models.CASCADE, null=True, blank=True,
related_name="sub_tags")

@property
def count(self):
return self.node_set.all().count()

@property
def nodes(self):
return self.node_set.all()

@property
def recursive_nodes(self):
nodes = list(self.nodes)

for sub in self.sub_tags.all():
nodes.extend(sub.recursive_nodes)

return nodes

@property
def recursive_count(self):
return len(self.recursive_nodes)

class Meta:
constraints = [
models.UniqueConstraint(fields=['label', 'parent_tag'],
name='semantictag_label_parenttag_unique_constraint')
]

class WikiTag(models.Model):
pass
class Request(models.Model):
"""
This class definition is written beforehand (to be implemented afterwards)
Expand Down Expand Up @@ -83,43 +118,6 @@ def delete_workspace(self, workspace_to_delete): # Note that this functio
if workspace_to_delete in self.workspaces.all(): # Workspace but pops from the list to prevent
self.workspaces.remove(workspace_to_delete) # errors if multiple Contributors present


class SemanticTag(models.Model):
created_at = models.DateTimeField(auto_now_add=True)
label = models.CharField(max_length=50, unique=True)
desc = models.CharField(max_length=100)
parent_tag = models.ForeignKey("SemanticTag", on_delete=models.CASCADE, null=True, blank=True,
related_name="sub_tags")

@property
def count(self):
return self.node_set.all().count()

@property
def nodes(self):
return self.node_set.all()

@property
def recursive_nodes(self):
nodes = list(self.nodes)

for sub in self.sub_tags.all():
nodes.extend(sub.recursive_nodes)

return nodes

@property
def recursive_count(self):
return len(self.recursive_nodes)

class Meta:
constraints = [
models.UniqueConstraint(fields=['label', 'parent_tag'],
name='semantictag_label_parenttag_unique_constraint')
]

class WikiTag(models.Model):
pass
class Reviewer(Contributor):

def __str__(self):
Expand Down

0 comments on commit 8d09b5f

Please sign in to comment.