Commit 8aecd007 authored by Thodoris Nestoridis's avatar Thodoris Nestoridis

JSONField

parent 76a7602c
...@@ -97,13 +97,13 @@ class Prefix(models.Model): ...@@ -97,13 +97,13 @@ class Prefix(models.Model):
system_state = models.TextField(max_length=100, blank=True) system_state = models.TextField(max_length=100, blank=True)
state_value = models.TextField(max_length=100, blank=True) state_value = models.TextField(max_length=100, blank=True)
#occuring functionality #occuring functionality
sys_fun = models.TextField(choices=SYSTEM_OR_FUNCTION_CHOICES, max_length=100, blank=True) sys_fun = models.CharField(choices=SYSTEM_OR_FUNCTION_CHOICES, max_length=100, blank=True)
verb = models.TextField(choices= VERB_CHOICES, max_length=100, blank=True) verb = models.CharField(choices=VERB_CHOICES, max_length=100, blank=True)
item_function_flow = models.TextField(choices=ITEM_FLOW_FUNCTION, max_length=100, blank=True) item_function_flow = models.CharField(choices=ITEM_FLOW_FUNCTION, max_length=100, blank=True)
#Prefix value P1/P2/P3 #Prefix value P1/P2/P3
logical_expression = models.CharField(choices=LOGICAL_EXPRESSION, max_length=100) logical_expression = models.CharField(choices=LOGICAL_EXPRESSION, max_length=100, blank=True)
#add extra prefix #add extra prefix
logic_connective = models.CharField(choices=LOGIC_CONNECTIVE, default='', max_length=100, null=True) logic_connective = models.CharField(choices=LOGIC_CONNECTIVE, default='', max_length=100, blank=True)
simple_prefix = models.CharField(choices=SIMPLE_PREFIX_CHOICES, max_length=100) simple_prefix = models.CharField(choices=SIMPLE_PREFIX_CHOICES, max_length=100)
......
from django.db import models from django.db import models
from reqman.apps.account.models import User from reqman.apps.account.models import User
import jsonfield
from pygments.formatters.html import HtmlFormatter from pygments.formatters.html import HtmlFormatter
from pygments import highlight from pygments import highlight
...@@ -47,15 +49,17 @@ class Suffix(models.Model): ...@@ -47,15 +49,17 @@ class Suffix(models.Model):
boilerplate_of_suffix = models.ForeignKey('reqtool.Boilerplate', related_name='suffix_boilerplate', on_delete=models.CASCADE) boilerplate_of_suffix = models.ForeignKey('reqtool.Boilerplate', related_name='suffix_boilerplate', on_delete=models.CASCADE)
suffix_owner = models.ForeignKey(User, related_name='suffix_owner', on_delete=models.CASCADE) suffix_owner = models.ForeignKey(User, related_name='suffix_owner', on_delete=models.CASCADE)
#prefix templates #prefix templates
s_choices = models.CharField(choices=S_CHOICES, max_length=100) s_choices = models.CharField(choices=S_CHOICES, max_length=100, blank=True)
#if S1 #if S1
numerical = models.IntegerField(default=0, blank=True) numerical = models.IntegerField(default=0, blank=True)
mumerical_units = models.CharField(choices=NUMBER_UNITS_CHOICES, max_length=100) mumerical_units = models.CharField(choices=NUMBER_UNITS_CHOICES, max_length=100, blank=True)
time_units = models.CharField(choices=TIME_UNITS_CHOICES, max_length=100) time_units = models.CharField(choices=TIME_UNITS_CHOICES, max_length=100, blank=True)
#if S2/S3 #if S2/S3
flow = models.CharField(choices=FLOW_CHOICES, max_length=100) flow = models.CharField(choices=FLOW_CHOICES, max_length=100, blank=True)
#find suffix #find suffix
suffix_choices = models.CharField(choices=SUFFIX_CHOICES, max_length=100) suffix_choices = models.CharField(choices=SUFFIX_CHOICES, max_length=100, blank=True)
#custom suffix
custom_suffix = jsonfield.JSONField()
class Meta: class Meta:
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
Ontology_file = "../../Ontologies/Mokos_18_1_7_47.ttl" Ontology_file = "../../Ontologies/Mokos_18_1_7_47.ttl"
list_of_DSO = ["DSO", "DSO-AOCS", "DSO-AOCS-instances"] list_of_DSO = ["DSO", "DSO-AOCS", "DSO-AOCS-instances"]
list_of_RMO = ["RMO", "RMO-instances", "DSO-AOCS-instances"] list_of_RMO = ["RMO", "RMO-instances", "DSO-AOCS-instances", "<http://delab.csd.auth.gr/ontologies/2018/RDO-instances"]
'''Return the Systems and Items from the Ontologies''' '''Return the Systems and Items from the Ontologies'''
......
...@@ -67,19 +67,11 @@ class PrefixListAPIView(ListAPIView): ...@@ -67,19 +67,11 @@ class PrefixListAPIView(ListAPIView):
queryset_prefix = Prefix.objects.filter(prefix_boilerplate = group_pk) queryset_prefix = Prefix.objects.filter(prefix_boilerplate = group_pk)
return queryset_prefix return queryset_prefix
#Custom actions when POST
def perform_create(self, serializer):
serializer.save()
#print the data of the post
#write_fuseki = fuseki.FusekiActions()
#write_fuseki.write(serializer.data)
class PrefixDetailsAPIView(RetrieveUpdateDestroyAPIView): class PrefixDetailsAPIView(RetrieveUpdateDestroyAPIView):
""" """
API view to retrieve, update or delete post API view to retrieve, update or delete post
""" """
permission_classes = [permissions.IsAuthenticatedOrReadOnly] permission_classes = [permissions.IsAuthenticatedOrReadOnly]
serializer_class = PrefixSerializer serializer_class = PrefixSerializer
#queryset = Prefix.objects.all() #queryset = Prefix.objects.all()
...@@ -88,13 +80,25 @@ class PrefixDetailsAPIView(RetrieveUpdateDestroyAPIView): ...@@ -88,13 +80,25 @@ class PrefixDetailsAPIView(RetrieveUpdateDestroyAPIView):
queryset_prefix = Prefix.objects.filter(prefix_boilerplate = group_pk) queryset_prefix = Prefix.objects.filter(prefix_boilerplate = group_pk)
return queryset_prefix return queryset_prefix
def simple_prefix(self, prefix):
if prefix == "If/Unless":
return "P1"
if prefix == "As soon as":
return "P2"
if prefix == "As long as":
return "P3"
#Custom actions when PUT #Custom actions when PUT
def perform_update(self, serializer): def perform_update(self, serializer):
serializer.save()
#print(self.new.changed_data) #print(self.new.changed_data)
instance = serializer.validated_data
sprefix = self.simple_prefix(instance["prefix"])
#instance = serializer.save() #instance = serializer.save()
#write_fuseki = fuseki.FusekiActions() #write_fuseki = fuseki.FusekiActions()
#write_fuseki.write(serializer.data) #write_fuseki.write(serializer.data)
serializer.save(simple_prefix = sprefix)
#Custom actions when DELETE #Custom actions when DELETE
def perform_destroy(self, instance): def perform_destroy(self, instance):
......
...@@ -65,6 +65,7 @@ pillow==6.1.0 ...@@ -65,6 +65,7 @@ pillow==6.1.0
#Ontologies #Ontologies
rdflib==5.0.0 rdflib==5.0.0
sparqlwrapper==1.8.5 sparqlwrapper==1.8.5
django-jsonfield==1.4.1
# The following packages are considered to be unsafe in a requirements file: # The following packages are considered to be unsafe in a requirements file:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment