Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
Requirement Formalization Tool
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Thodoris Nestoridis
Requirement Formalization Tool
Commits
60f5e7fa
Commit
60f5e7fa
authored
Jan 21, 2021
by
Thodoris Nestoridis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add M1-M4
parent
f44def27
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
402 additions
and
16 deletions
+402
-16
main_req.py
reqtool/reqman/api/reqman/apps/reqtool/models/main_req.py
+151
-10
main_req.py
.../api/reqman/apps/reqtool/rest_api/serializers/main_req.py
+34
-2
urls.py
reqtool/reqman/api/reqman/apps/reqtool/rest_api/urls.py
+13
-1
main_req_views.py
.../api/reqman/apps/reqtool/rest_api/views/main_req_views.py
+204
-3
No files found.
reqtool/reqman/api/reqman/apps/reqtool/models/main_req.py
View file @
60f5e7fa
...
...
@@ -4,10 +4,11 @@ from reqman.apps.account.models import User
from
pygments.formatters.html
import
HtmlFormatter
from
pygments
import
highlight
MAIN_CHOICES
=
(
(
""
,
""
),
(
"M1"
,
"M1 : system/function shall [not] set [<quantifier>] item [to stateValue]"
),
MAIN_CHOICES
=
(
(
""
,
""
),
(
"M1"
,
"M1 : system/function shall [not] set [<quantifier>] item [to stateValue]"
),
(
"M2"
,
"M2 : system/function shall [not] set state to stateValue"
),
(
"M3"
,
"M3 : system/function shall [not] send [<quantifier>] item"
),
(
"M4"
,
"M4 : system/function shall [not] receive [<quantifi
er>] item"
),
(
"M4"
,
"M4 : system/function shall [not] receive [<quantifier>] item"
),
(
"M5"
,
"M5 : system/function shall [not] ingest flow"
),
(
"M6"
,
"M6 : system/function shall [not] emit flow"
),
(
"M7"
,
"M7 : system shall [not] perform function"
),
...
...
@@ -22,26 +23,100 @@ MAIN_CHOICES = ( ("",""), ("M1", "M1 : system/function shall [not] set [<quant
(
"M16"
,
"M16 : system shall [not] contain system"
)
)
#to be updated with domains from DSO
SYSTEM_OR_FUNCTION_CHOICES
=
((
"SYSTEM"
,
"SYSTEM"
),
(
"FUNCTION"
,
"FUNCTION"
))
SHALL_CHOICES
=
(
(
"shall"
,
"SHALL"
),
(
"shall not"
,
"SHALL NOT"
))
QUANTIFIER_CHOICES
=
(
(
"none"
,
"NONE"
),
(
"all"
,
"ALL"
),
(
"only"
,
"ONLY"
),
(
"more than"
,
"MORE THAN"
),
(
"less than"
,
"LESS THAN"
),
(
"exactly"
,
"EXACTLY"
),
(
"at least"
,
"AT LEAST"
),
(
"at most"
,
"AT MOST"
)
)
NUMBER_UNITS_CHOICES
=
((
""
,
""
),
(
"meters"
,
"METERS"
),
(
"kilometers"
,
"KILOMETERS"
),
(
"volt"
,
"VOLT"
))
ITEM_CHOICES
=
((
"ITEM"
,
"ITEM"
),
(
"ITEM2"
,
"ITEM2"
)
)
STATE_VALUE_CHOICES
=
((
"enabled"
,
"ENABLED"
),
(
"disabled"
,
"DISABLED"
))
def
create_main
(
instance
):
'''Create the Main Model for the Boilerplate'''
try
:
main
=
Main
.
objects
.
get
(
boilerplate_of_main
=
instance
,
prefix_owner_of_main
=
instance
.
owner
)
main
=
Main
.
objects
.
get
(
boilerplate_of_main
=
instance
,
main_owner
=
instance
.
owner
)
if
instance
.
has_main
:
return
main
=
Main
.
objects
.
get
(
boilerplate_of_main
=
instance
,
prefix_owner_of_main
=
instance
.
owner
)
main
=
Main
.
objects
.
get
(
boilerplate_of_main
=
instance
,
main_owner
=
instance
.
owner
)
main
.
delete
()
except
Main
.
DoesNotExist
:
if
instance
.
has_main
:
main
=
Main
(
boilerplate_of_main
=
instance
,
prefix_owner_of_main
=
instance
.
owner
)
main
=
Main
(
boilerplate_of_main
=
instance
,
main_owner
=
instance
.
owner
)
main
.
save
()
def
create_m1
(
instance
,
now_main
,
prev_main
):
try
:
main
=
Main_M1
.
objects
.
get
(
main_owner_of_m1
=
instance
,
boilerplate_of_m1
=
instance
.
boilerplate_of_main
)
if
now_main
==
prev_main
:
return
main
=
Main_M1
.
objects
.
get
(
main_owner_of_m1
=
instance
,
boilerplate_of_m1
=
instance
.
boilerplate_of_main
)
main
.
delete
()
if
now_main
==
MAIN_CHOICES
[
1
][
0
]:
main
=
Main_M1
(
main_owner_of_m1
=
instance
,
boilerplate_of_m1
=
instance
.
boilerplate_of_main
)
main
.
save
()
except
Main_M1
.
DoesNotExist
:
if
now_main
==
MAIN_CHOICES
[
1
][
0
]:
main
=
Main_M1
(
main_owner_of_m1
=
instance
,
boilerplate_of_m1
=
instance
.
boilerplate_of_main
)
main
.
save
()
def
create_m2
(
instance
,
now_main
,
prev_main
):
try
:
main
=
Main_M2
.
objects
.
get
(
main_owner_of_m2
=
instance
,
boilerplate_of_m2
=
instance
.
boilerplate_of_main
)
if
now_main
==
prev_main
:
return
main
=
Main_M2
.
objects
.
get
(
main_owner_of_m2
=
instance
,
boilerplate_of_m2
=
instance
.
boilerplate_of_main
)
main
.
delete
()
if
now_main
==
MAIN_CHOICES
[
2
][
0
]:
main
=
Main_M2
(
main_owner_of_m2
=
instance
,
boilerplate_of_m2
=
instance
.
boilerplate_of_main
)
main
.
save
()
except
Main_M2
.
DoesNotExist
:
if
now_main
==
MAIN_CHOICES
[
2
][
0
]:
main
=
Main_M2
(
main_owner_of_m2
=
instance
,
boilerplate_of_m2
=
instance
.
boilerplate_of_main
)
main
.
save
()
def
create_m3
(
instance
,
now_main
,
prev_main
):
try
:
main
=
Main_M3
.
objects
.
get
(
main_owner_of_m3
=
instance
,
boilerplate_of_m3
=
instance
.
boilerplate_of_main
)
if
now_main
==
prev_main
:
return
main
=
Main_M3
.
objects
.
get
(
main_owner_of_m3
=
instance
,
boilerplate_of_m3
=
instance
.
boilerplate_of_main
)
main
.
delete
()
if
now_main
==
MAIN_CHOICES
[
3
][
0
]:
main
=
Main_M3
(
main_owner_of_m3
=
instance
,
boilerplate_of_m3
=
instance
.
boilerplate_of_main
)
main
.
save
()
except
Main_M3
.
DoesNotExist
:
if
now_main
==
MAIN_CHOICES
[
3
][
0
]:
main
=
Main_M3
(
main_owner_of_m3
=
instance
,
boilerplate_of_m3
=
instance
.
boilerplate_of_main
)
main
.
save
()
def
create_m4
(
instance
,
now_main
,
prev_main
):
try
:
main
=
Main_M4
.
objects
.
get
(
main_owner_of_m4
=
instance
,
boilerplate_of_m4
=
instance
.
boilerplate_of_main
)
if
now_main
==
prev_main
:
return
main
=
Main_M4
.
objects
.
get
(
main_owner_of_m4
=
instance
,
boilerplate_of_m4
=
instance
.
boilerplate_of_main
)
main
.
delete
()
if
now_main
==
MAIN_CHOICES
[
4
][
0
]:
main
=
Main_M4
(
main_owner_of_m4
=
instance
,
boilerplate_of_m4
=
instance
.
boilerplate_of_main
)
main
.
save
()
except
Main_M4
.
DoesNotExist
:
if
now_main
==
MAIN_CHOICES
[
4
][
0
]:
main
=
Main_M4
(
main_owner_of_m4
=
instance
,
boilerplate_of_m4
=
instance
.
boilerplate_of_main
)
main
.
save
()
class
Main
(
models
.
Model
):
boilerplate_of_main
=
models
.
ForeignKey
(
'reqtool.Boilerplate'
,
related_name
=
'main'
,
on_delete
=
models
.
CASCADE
)
prefix_owner_of_main
=
models
.
ForeignKey
(
User
,
related_name
=
'main_owner'
,
on_delete
=
models
.
CASCADE
)
boilerplate_of_main
=
models
.
ForeignKey
(
'reqtool.Boilerplate'
,
related_name
=
'main
_boilerplate
'
,
on_delete
=
models
.
CASCADE
)
main_owner
=
models
.
ForeignKey
(
User
,
related_name
=
'main_owner'
,
on_delete
=
models
.
CASCADE
)
main_choices
=
models
.
CharField
(
choices
=
MAIN_CHOICES
,
max_length
=
100
)
...
...
@@ -61,9 +136,75 @@ class Main(models.Model):
orig
=
'__original_
%
s'
%
field
previous_main
=
getattr
(
self
,
orig
)
prev_main_list
.
append
(
previous_main
)
'''Create Main '''
#create_M1( self, self.simple_prefix_1, prev_prefix_list[0], '1')
'''Create [M1 - M16]'''
create_m1
(
self
,
self
.
main_choices
,
prev_main_list
[
0
])
create_m2
(
self
,
self
.
main_choices
,
prev_main_list
[
0
])
create_m3
(
self
,
self
.
main_choices
,
prev_main_list
[
0
])
create_m4
(
self
,
self
.
main_choices
,
prev_main_list
[
0
])
class
Meta
:
ordering
=
[
'prefix_owner_of_main'
]
\ No newline at end of file
ordering
=
[
'boilerplate_of_main'
]
class
Main_M1
(
models
.
Model
):
boilerplate_of_m1
=
models
.
ForeignKey
(
'reqtool.Boilerplate'
,
related_name
=
'main_boilerplate_of_M1'
,
on_delete
=
models
.
CASCADE
)
main_owner_of_m1
=
models
.
ForeignKey
(
Main
,
related_name
=
'main_owner_of_M1'
,
on_delete
=
models
.
CASCADE
)
sys_fun_m1
=
models
.
CharField
(
choices
=
SYSTEM_OR_FUNCTION_CHOICES
,
max_length
=
100
)
shall_m1
=
models
.
CharField
(
choices
=
SHALL_CHOICES
,
max_length
=
100
)
quantifier_m1
=
models
.
CharField
(
choices
=
QUANTIFIER_CHOICES
,
max_length
=
100
)
numerical_m1
=
models
.
IntegerField
(
default
=
0
,
blank
=
True
)
mumerical_units_m1
=
models
.
CharField
(
choices
=
NUMBER_UNITS_CHOICES
,
max_length
=
100
)
item_m1
=
models
.
CharField
(
choices
=
ITEM_CHOICES
,
max_length
=
100
)
statevalue_m1
=
models
.
CharField
(
choices
=
STATE_VALUE_CHOICES
,
max_length
=
100
)
class
Meta
:
ordering
=
[
'boilerplate_of_m1'
]
class
Main_M2
(
models
.
Model
):
boilerplate_of_m2
=
models
.
ForeignKey
(
'reqtool.Boilerplate'
,
related_name
=
'main_boilerplate_of_M2'
,
on_delete
=
models
.
CASCADE
)
main_owner_of_m2
=
models
.
ForeignKey
(
Main
,
related_name
=
'main_owner_of_M2'
,
on_delete
=
models
.
CASCADE
)
sys_fun_m2
=
models
.
CharField
(
choices
=
SYSTEM_OR_FUNCTION_CHOICES
,
max_length
=
100
)
shall_m2
=
models
.
CharField
(
choices
=
SHALL_CHOICES
,
max_length
=
100
)
state_m2
=
models
.
CharField
(
default
=
' '
,
max_length
=
100
)
statevalue_m2
=
models
.
CharField
(
choices
=
STATE_VALUE_CHOICES
,
max_length
=
100
)
class
Meta
:
ordering
=
[
'boilerplate_of_m2'
]
class
Main_M3
(
models
.
Model
):
boilerplate_of_m3
=
models
.
ForeignKey
(
'reqtool.Boilerplate'
,
related_name
=
'main_boilerplate_of_M3'
,
on_delete
=
models
.
CASCADE
)
main_owner_of_m3
=
models
.
ForeignKey
(
Main
,
related_name
=
'main_owner_of_M3'
,
on_delete
=
models
.
CASCADE
)
sys_fun_m3
=
models
.
CharField
(
choices
=
SYSTEM_OR_FUNCTION_CHOICES
,
max_length
=
100
)
shall_m3
=
models
.
CharField
(
choices
=
SHALL_CHOICES
,
max_length
=
100
)
quantifier_m3
=
models
.
CharField
(
choices
=
QUANTIFIER_CHOICES
,
max_length
=
100
)
numerical_m3
=
models
.
IntegerField
(
default
=
0
,
blank
=
True
)
mumerical_units_m3
=
models
.
CharField
(
choices
=
NUMBER_UNITS_CHOICES
,
max_length
=
100
)
item_m3
=
models
.
CharField
(
choices
=
ITEM_CHOICES
,
max_length
=
100
)
class
Meta
:
ordering
=
[
'boilerplate_of_m3'
]
class
Main_M4
(
models
.
Model
):
boilerplate_of_m4
=
models
.
ForeignKey
(
'reqtool.Boilerplate'
,
related_name
=
'main_boilerplate_of_M4'
,
on_delete
=
models
.
CASCADE
)
main_owner_of_m4
=
models
.
ForeignKey
(
Main
,
related_name
=
'main_owner_of_M4'
,
on_delete
=
models
.
CASCADE
)
sys_fun_m4
=
models
.
CharField
(
choices
=
SYSTEM_OR_FUNCTION_CHOICES
,
max_length
=
100
)
shall_m4
=
models
.
CharField
(
choices
=
SHALL_CHOICES
,
max_length
=
100
)
quantifier_m4
=
models
.
CharField
(
choices
=
QUANTIFIER_CHOICES
,
max_length
=
100
)
numerical_m4
=
models
.
IntegerField
(
default
=
0
,
blank
=
True
)
mumerical_units_m4
=
models
.
CharField
(
choices
=
NUMBER_UNITS_CHOICES
,
max_length
=
100
)
item_m4
=
models
.
CharField
(
choices
=
ITEM_CHOICES
,
max_length
=
100
)
class
Meta
:
ordering
=
[
'boilerplate_of_m4'
]
reqtool/reqman/api/reqman/apps/reqtool/rest_api/serializers/main_req.py
View file @
60f5e7fa
from
rest_framework
import
serializers
from
reqman.apps.reqtool.models.main_req
import
Main
from
reqman.apps.reqtool.models.main_req
import
Main
,
Main_M1
,
Main_M2
,
Main_M3
,
Main_M4
class
MainSerializer
(
serializers
.
ModelSerializer
):
boilerplate_of_main
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
prefix_owner_of_main
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
class
Meta
:
model
=
Main
fields
=
(
'id'
,
'prefix_owner_of_main'
,
'boilerplate_of_main'
,
'main_choices'
)
\ No newline at end of file
fields
=
(
'id'
,
'prefix_owner_of_main'
,
'boilerplate_of_main'
,
'main_choices'
)
class
Main_M1Serializer
(
serializers
.
ModelSerializer
):
boilerplate_of_m1
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
main_owner_of_m1
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
class
Meta
:
model
=
Main_M1
fields
=
(
'id'
,
'boilerplate_of_m1'
,
'main_owner_of_m1'
,
'sys_fun_m1'
,
'shall_m1'
,
'quantifier_m1'
,
'numerical_m1'
,
'mumerical_units_m1'
,
'item_m1'
,
'statevalue_m1'
)
class
Main_M2Serializer
(
serializers
.
ModelSerializer
):
boilerplate_of_m2
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
main_owner_of_m2
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
class
Meta
:
model
=
Main_M2
fields
=
(
'id'
,
'boilerplate_of_m2'
,
'main_owner_of_m2'
,
'sys_fun_m2'
,
'shall_m2'
,
'state_m2'
,
'statevalue_m2'
)
class
Main_M3Serializer
(
serializers
.
ModelSerializer
):
boilerplate_of_m3
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
main_owner_of_m3
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
class
Meta
:
model
=
Main_M3
fields
=
(
'id'
,
'boilerplate_of_m3'
,
'main_owner_of_m3'
,
'sys_fun_m3'
,
'shall_m3'
,
'quantifier_m3'
,
'numerical_m3'
,
'mumerical_units_m3'
,
'item_m3'
)
class
Main_M4Serializer
(
serializers
.
ModelSerializer
):
boilerplate_of_m4
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
main_owner_of_m4
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
class
Meta
:
model
=
Main_M4
fields
=
(
'id'
,
'boilerplate_of_m4'
,
'main_owner_of_m4'
,
'sys_fun_m4'
,
'shall_m4'
,
'quantifier_m4'
,
'numerical_m4'
,
'mumerical_units_m4'
,
'item_m4'
)
\ No newline at end of file
reqtool/reqman/api/reqman/apps/reqtool/rest_api/urls.py
View file @
60f5e7fa
...
...
@@ -30,5 +30,17 @@ urlpatterns = [
#'''MAIN'''
path
(
'requirements/<int:boilerplate>/main/'
,
main_req_views
.
MainListCreateAPIView
.
as_view
(),
name
=
'api-main-list'
),
path
(
'requirements/<int:boilerplate>/main/<int:pk>/'
,
main_req_views
.
MainDetailsAPIView
.
as_view
(),
name
=
'api-main-details'
),
#'''M1'''
path
(
'requirements/<int:boilerplate>/main/<int:mains>/m1'
,
main_req_views
.
Main_M1ListCreateAPIView
.
as_view
(),
name
=
'api-main-m1-list'
),
path
(
'requirements/<int:boilerplate>/main/<int:mains>/m1/<int:pk>/'
,
main_req_views
.
Main_M1DetailsAPIView
.
as_view
(),
name
=
'api-main-m1-details'
),
#'''M2'''
path
(
'requirements/<int:boilerplate>/main/<int:mains>/m2'
,
main_req_views
.
Main_M2ListCreateAPIView
.
as_view
(),
name
=
'api-main-m2-list'
),
path
(
'requirements/<int:boilerplate>/main/<int:mains>/m2/<int:pk>/'
,
main_req_views
.
Main_M2DetailsAPIView
.
as_view
(),
name
=
'api-main-m2-details'
),
#'''M3'''
path
(
'requirements/<int:boilerplate>/main/<int:mains>/m3'
,
main_req_views
.
Main_M3ListCreateAPIView
.
as_view
(),
name
=
'api-main-m3-list'
),
path
(
'requirements/<int:boilerplate>/main/<int:mains>/m3/<int:pk>/'
,
main_req_views
.
Main_M3DetailsAPIView
.
as_view
(),
name
=
'api-main-m3-details'
),
#'''M4'''
path
(
'requirements/<int:boilerplate>/main/<int:mains>/m4'
,
main_req_views
.
Main_M4ListCreateAPIView
.
as_view
(),
name
=
'api-main-m4-list'
),
path
(
'requirements/<int:boilerplate>/main/<int:mains>/m4/<int:pk>/'
,
main_req_views
.
Main_M4DetailsAPIView
.
as_view
(),
name
=
'api-main-m4-details'
),
]
\ No newline at end of file
reqtool/reqman/api/reqman/apps/reqtool/rest_api/views/main_req_views.py
View file @
60f5e7fa
...
...
@@ -5,8 +5,8 @@ from django.http import HttpResponse, JsonResponse
from
django.views.decorators.csrf
import
csrf_exempt
from
rest_framework.parsers
import
JSONParser
from
reqman.apps.reqtool.models.main_req
import
Main
from
reqman.apps.reqtool.rest_api.serializers.main_req
import
MainSerializer
from
reqman.apps.reqtool.models.main_req
import
Main
,
Main_M1
,
Main_M2
,
Main_M3
,
Main_M4
from
reqman.apps.reqtool.rest_api.serializers.main_req
import
MainSerializer
,
Main_M1Serializer
,
Main_M2Serializer
,
Main_M3Serializer
,
Main_M4Serializer
from
reqman.apps.permissions
import
IsOwnerOrReadOnly
from
reqman.apps.reqtool.rest_api.services
import
fuseki
...
...
@@ -57,4 +57,205 @@ class MainDetailsAPIView(RetrieveUpdateDestroyAPIView):
#Custom actions when DELETE
def
perform_destroy
(
self
,
instance
):
#print("deleted")
instance
.
delete
()
\ No newline at end of file
instance
.
delete
()
class
Main_M1ListCreateAPIView
(
ListCreateAPIView
):
"""
API view to retrieve list of posts or create new
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Main_M1Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
mn
=
self
.
kwargs
[
'mains'
]
#print(group_pk)
queryset_main
=
Main_M1
.
objects
.
filter
(
boilerplate_of_m1
=
bp
,
main_owner_of_m1
=
mn
)
return
queryset_main
#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
Main_M1DetailsAPIView
(
RetrieveUpdateDestroyAPIView
):
"""
API view to retrieve, update or delete post
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Main_M1Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
mn
=
self
.
kwargs
[
'mains'
]
#print(group_pk)
queryset_main
=
Main_M1
.
objects
.
filter
(
boilerplate_of_m1
=
bp
,
main_owner_of_m1
=
mn
)
return
queryset_main
#Custom actions when PUT
def
perform_update
(
self
,
serializer
):
serializer
.
save
()
#print(self.new.changed_data)
#instance = serializer.save()
#write_fuseki = fuseki.FusekiActions()
#write_fuseki.write(serializer.data)
#Custom actions when DELETE
def
perform_destroy
(
self
,
instance
):
#print("deleted")
instance
.
delete
()
class
Main_M2ListCreateAPIView
(
ListCreateAPIView
):
"""
API view to retrieve list of posts or create new
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Main_M2Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
mn
=
self
.
kwargs
[
'mains'
]
#print(group_pk)
queryset_main
=
Main_M2
.
objects
.
filter
(
boilerplate_of_m2
=
bp
,
main_owner_of_m2
=
mn
)
return
queryset_main
#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
Main_M2DetailsAPIView
(
RetrieveUpdateDestroyAPIView
):
"""
API view to retrieve, update or delete post
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Main_M2Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
mn
=
self
.
kwargs
[
'mains'
]
#print(group_pk)
queryset_main
=
Main_M2
.
objects
.
filter
(
boilerplate_of_m2
=
bp
,
main_owner_of_m2
=
mn
)
return
queryset_main
#Custom actions when PUT
def
perform_update
(
self
,
serializer
):
serializer
.
save
()
#print(self.new.changed_data)
#instance = serializer.save()
#write_fuseki = fuseki.FusekiActions()
#write_fuseki.write(serializer.data)
#Custom actions when DELETE
def
perform_destroy
(
self
,
instance
):
#print("deleted")
instance
.
delete
()
class
Main_M3ListCreateAPIView
(
ListCreateAPIView
):
"""
API view to retrieve list of posts or create new
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Main_M3Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
mn
=
self
.
kwargs
[
'mains'
]
#print(group_pk)
queryset_main
=
Main_M3
.
objects
.
filter
(
boilerplate_of_m3
=
bp
,
main_owner_of_m3
=
mn
)
return
queryset_main
#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
Main_M3DetailsAPIView
(
RetrieveUpdateDestroyAPIView
):
"""
API view to retrieve, update or delete post
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Main_M3Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
mn
=
self
.
kwargs
[
'mains'
]
#print(group_pk)
queryset_main
=
Main_M3
.
objects
.
filter
(
boilerplate_of_m3
=
bp
,
main_owner_of_m3
=
mn
)
return
queryset_main
#Custom actions when PUT
def
perform_update
(
self
,
serializer
):
serializer
.
save
()
#print(self.new.changed_data)
#instance = serializer.save()
#write_fuseki = fuseki.FusekiActions()
#write_fuseki.write(serializer.data)
#Custom actions when DELETE
def
perform_destroy
(
self
,
instance
):
#print("deleted")
instance
.
delete
()
class
Main_M4ListCreateAPIView
(
ListCreateAPIView
):
"""
API view to retrieve list of posts or create new
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Main_M4Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
mn
=
self
.
kwargs
[
'mains'
]
#print(group_pk)
queryset_main
=
Main_M4
.
objects
.
filter
(
boilerplate_of_m4
=
bp
,
main_owner_of_m4
=
mn
)
return
queryset_main
#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
Main_M4DetailsAPIView
(
RetrieveUpdateDestroyAPIView
):
"""
API view to retrieve, update or delete post
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Main_M4Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
mn
=
self
.
kwargs
[
'mains'
]
#print(group_pk)
queryset_main
=
Main_M4
.
objects
.
filter
(
boilerplate_of_m4
=
bp
,
main_owner_of_m4
=
mn
)
return
queryset_main
#Custom actions when PUT
def
perform_update
(
self
,
serializer
):
serializer
.
save
()
#print(self.new.changed_data)
#instance = serializer.save()
#write_fuseki = fuseki.FusekiActions()
#write_fuseki.write(serializer.data)
#Custom actions when DELETE
def
perform_destroy
(
self
,
instance
):
#print("deleted")
instance
.
delete
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment