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
76a7602c
Commit
76a7602c
authored
Feb 01, 2021
by
Thodoris Nestoridis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new models
parent
3db478fe
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
119 additions
and
2512 deletions
+119
-2512
main_req.py
reqtool/reqman/api/reqman/apps/reqtool/models/main_req.py
+30
-495
requirements.py
...ool/reqman/api/reqman/apps/reqtool/models/requirements.py
+57
-203
suffix_req.py
reqtool/reqman/api/reqman/apps/reqtool/models/suffix_req.py
+15
-189
main_req.py
.../api/reqman/apps/reqtool/rest_api/serializers/main_req.py
+3
-136
requirements.py
.../reqman/apps/reqtool/rest_api/serializers/requirements.py
+4
-51
suffix_req.py
...pi/reqman/apps/reqtool/rest_api/serializers/suffix_req.py
+2
-50
urls.py
reqtool/reqman/api/reqman/apps/reqtool/rest_api/urls.py
+0
-82
main_req_views.py
.../api/reqman/apps/reqtool/rest_api/views/main_req_views.py
+2
-793
requirements_views.py
.../reqman/apps/reqtool/rest_api/views/requirements_views.py
+4
-217
suffix_req_views.py
...pi/reqman/apps/reqtool/rest_api/views/suffix_req_views.py
+2
-296
No files found.
reqtool/reqman/api/reqman/apps/reqtool/models/main_req.py
View file @
76a7602c
...
...
@@ -41,17 +41,22 @@ ITEM_CHOICES = find_extra_keywords("SAO:Item", 1)
#STATE_VALUE_CHOICES = (("enabled", "ENABLED"), ("disabled", "DISABLED"))
STATE_VALUE_CHOICES
=
find_extra_keywords
(
":StateValue"
,
2
)
#STATE_CHOICES = (("state", "STATE"), ("state2", "STATE2"))
STATE_CHOICES
=
[
x
for
x
in
find_extra_keywords
(
":State"
,
2
)
if
x
not
in
STATE_VALUE_CHOICES
]
STATE_CHOICES
=
tuple
(
[
x
for
x
in
find_extra_keywords
(
":State"
,
2
)
if
x
not
in
STATE_VALUE_CHOICES
])
#FLOW_CHOICES = (("flow","FLOW"), ("flow2","FLOW2"))
FLOW_CHOICES
=
find_extra_keywords
(
":Flow"
,
3
)
#INTERFACE_CHOICES = (("interface","INTERFACE"), ("interface2","INTERFACE2"))
INTERFACE_CHOICES
=
find_extra_keywords
(
":Interface"
,
2
)
#CONNECTION_CHOICES = (("connection","CONNECTION"), ("connection2","CONNECTION2"))
CONNECTION_CHOICES
=
find_extra_keywords
(
":Connection"
,
2
)
VERB_CHOICES
=
((
"set"
,
"set"
),(
"send"
,
"send"
),(
"receive"
,
"receive"
),(
"ingest"
,
"ingest"
),(
"emit"
,
"emit"
),(
"perform"
,
"perform"
),(
"invoke"
,
"invoke"
),
(
"present"
,
"present"
),(
"transfer"
,
"transfer"
),(
"interact with"
,
"interact with"
),(
"have state"
,
"have state"
),(
"have substate"
,
"have substate"
),
(
"take values from"
,
"take values from"
),(
"be composed"
,
"be composed"
),(
"contain"
,
"contain"
))
SYSTEM_INTERFACE_CHOICES
=
SYSTEM_CHOICES
+
INTERFACE_CHOICES
FLOW_ITEM_CHOICES
=
FLOW_CHOICES
+
ITEM_CHOICES
SYSTEM_OR_FUNCTION_CHOICES
=
SYSTEM_CHOICES
+
FUNCTION_CHOICES
FLOW_ITEM_CHOICES
=
FLOW_CHOICES
+
ITEM_CHOICES
SYSTEM_FUNCTION_INTERFACE_CHOICES
=
SYSTEM_CHOICES
+
FUNCTION_CHOICES
+
ITEM_CHOICES
FLOW_FUNCTION_INTERFACE_ITEM_SYSTEM_STATE_CHOICES
=
FLOW_CHOICES
+
FUNCTION_CHOICES
+
INTERFACE_CHOICES
+
ITEM_CHOICES
+
SYSTEM_CHOICES
+
STATE_CHOICES
ITEM_FLOW_FUNCTION
=
ITEM_CHOICES
+
FLOW_CHOICES
+
FUNCTION_CHOICES
def
create_main
(
instance
):
...
...
@@ -68,503 +73,33 @@ def create_main(instance):
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
()
def
create_m5
(
instance
,
now_main
,
prev_main
):
try
:
main
=
Main_M5
.
objects
.
get
(
main_owner_of_m5
=
instance
,
boilerplate_of_m5
=
instance
.
boilerplate_of_main
)
if
now_main
==
prev_main
:
return
main
=
Main_M5
.
objects
.
get
(
main_owner_of_m5
=
instance
,
boilerplate_of_m5
=
instance
.
boilerplate_of_main
)
main
.
delete
()
if
now_main
==
MAIN_CHOICES
[
5
][
0
]:
main
=
Main_M5
(
main_owner_of_m5
=
instance
,
boilerplate_of_m5
=
instance
.
boilerplate_of_main
)
main
.
save
()
except
Main_M5
.
DoesNotExist
:
if
now_main
==
MAIN_CHOICES
[
5
][
0
]:
main
=
Main_M5
(
main_owner_of_m5
=
instance
,
boilerplate_of_m5
=
instance
.
boilerplate_of_main
)
main
.
save
()
def
create_m6
(
instance
,
now_main
,
prev_main
):
try
:
main
=
Main_M6
.
objects
.
get
(
main_owner_of_m6
=
instance
,
boilerplate_of_m6
=
instance
.
boilerplate_of_main
)
if
now_main
==
prev_main
:
return
main
=
Main_M6
.
objects
.
get
(
main_owner_of_m6
=
instance
,
boilerplate_of_m6
=
instance
.
boilerplate_of_main
)
main
.
delete
()
if
now_main
==
MAIN_CHOICES
[
6
][
0
]:
main
=
Main_M6
(
main_owner_of_m6
=
instance
,
boilerplate_of_m6
=
instance
.
boilerplate_of_main
)
main
.
save
()
except
Main_M6
.
DoesNotExist
:
if
now_main
==
MAIN_CHOICES
[
6
][
0
]:
main
=
Main_M6
(
main_owner_of_m6
=
instance
,
boilerplate_of_m6
=
instance
.
boilerplate_of_main
)
main
.
save
()
def
create_m7
(
instance
,
now_main
,
prev_main
):
try
:
main
=
Main_M7
.
objects
.
get
(
main_owner_of_m7
=
instance
,
boilerplate_of_m7
=
instance
.
boilerplate_of_main
)
if
now_main
==
prev_main
:
return
main
=
Main_M7
.
objects
.
get
(
main_owner_of_m7
=
instance
,
boilerplate_of_m7
=
instance
.
boilerplate_of_main
)
main
.
delete
()
if
now_main
==
MAIN_CHOICES
[
7
][
0
]:
main
=
Main_M7
(
main_owner_of_m7
=
instance
,
boilerplate_of_m7
=
instance
.
boilerplate_of_main
)
main
.
save
()
except
Main_M7
.
DoesNotExist
:
if
now_main
==
MAIN_CHOICES
[
7
][
0
]:
main
=
Main_M7
(
main_owner_of_m7
=
instance
,
boilerplate_of_m7
=
instance
.
boilerplate_of_main
)
main
.
save
()
def
create_m8
(
instance
,
now_main
,
prev_main
):
try
:
main
=
Main_M8
.
objects
.
get
(
main_owner_of_m8
=
instance
,
boilerplate_of_m8
=
instance
.
boilerplate_of_main
)
if
now_main
==
prev_main
:
return
main
=
Main_M8
.
objects
.
get
(
main_owner_of_m8
=
instance
,
boilerplate_of_m8
=
instance
.
boilerplate_of_main
)
main
.
delete
()
if
now_main
==
MAIN_CHOICES
[
8
][
0
]:
main
=
Main_M8
(
main_owner_of_m8
=
instance
,
boilerplate_of_m8
=
instance
.
boilerplate_of_main
)
main
.
save
()
except
Main_M8
.
DoesNotExist
:
if
now_main
==
MAIN_CHOICES
[
8
][
0
]:
main
=
Main_M8
(
main_owner_of_m8
=
instance
,
boilerplate_of_m8
=
instance
.
boilerplate_of_main
)
main
.
save
()
def
create_m9
(
instance
,
now_main
,
prev_main
):
try
:
main
=
Main_M9
.
objects
.
get
(
main_owner_of_m9
=
instance
,
boilerplate_of_m9
=
instance
.
boilerplate_of_main
)
if
now_main
==
prev_main
:
return
main
=
Main_M9
.
objects
.
get
(
main_owner_of_m9
=
instance
,
boilerplate_of_m9
=
instance
.
boilerplate_of_main
)
main
.
delete
()
if
now_main
==
MAIN_CHOICES
[
9
][
0
]:
main
=
Main_M9
(
main_owner_of_m9
=
instance
,
boilerplate_of_m9
=
instance
.
boilerplate_of_main
)
main
.
save
()
except
Main_M9
.
DoesNotExist
:
if
now_main
==
MAIN_CHOICES
[
9
][
0
]:
main
=
Main_M9
(
main_owner_of_m9
=
instance
,
boilerplate_of_m9
=
instance
.
boilerplate_of_main
)
main
.
save
()
def
create_m10
(
instance
,
now_main
,
prev_main
):
try
:
main
=
Main_M10
.
objects
.
get
(
main_owner_of_m10
=
instance
,
boilerplate_of_m10
=
instance
.
boilerplate_of_main
)
if
now_main
==
prev_main
:
return
main
=
Main_M10
.
objects
.
get
(
main_owner_of_m10
=
instance
,
boilerplate_of_m10
=
instance
.
boilerplate_of_main
)
main
.
delete
()
if
now_main
==
MAIN_CHOICES
[
10
][
0
]:
main
=
Main_M10
(
main_owner_of_m10
=
instance
,
boilerplate_of_m10
=
instance
.
boilerplate_of_main
)
main
.
save
()
except
Main_M10
.
DoesNotExist
:
if
now_main
==
MAIN_CHOICES
[
10
][
0
]:
main
=
Main_M10
(
main_owner_of_m10
=
instance
,
boilerplate_of_m10
=
instance
.
boilerplate_of_main
)
main
.
save
()
def
create_m11
(
instance
,
now_main
,
prev_main
):
try
:
main
=
Main_M11
.
objects
.
get
(
main_owner_of_m11
=
instance
,
boilerplate_of_m11
=
instance
.
boilerplate_of_main
)
if
now_main
==
prev_main
:
return
main
=
Main_M11
.
objects
.
get
(
main_owner_of_m11
=
instance
,
boilerplate_of_m11
=
instance
.
boilerplate_of_main
)
main
.
delete
()
if
now_main
==
MAIN_CHOICES
[
11
][
0
]:
main
=
Main_M11
(
main_owner_of_m11
=
instance
,
boilerplate_of_m11
=
instance
.
boilerplate_of_main
)
main
.
save
()
except
Main_M11
.
DoesNotExist
:
if
now_main
==
MAIN_CHOICES
[
11
][
0
]:
main
=
Main_M11
(
main_owner_of_m11
=
instance
,
boilerplate_of_m11
=
instance
.
boilerplate_of_main
)
main
.
save
()
def
create_m12
(
instance
,
now_main
,
prev_main
):
try
:
main
=
Main_M12
.
objects
.
get
(
main_owner_of_m12
=
instance
,
boilerplate_of_m12
=
instance
.
boilerplate_of_main
)
if
now_main
==
prev_main
:
return
main
=
Main_M12
.
objects
.
get
(
main_owner_of_m12
=
instance
,
boilerplate_of_m12
=
instance
.
boilerplate_of_main
)
main
.
delete
()
if
now_main
==
MAIN_CHOICES
[
12
][
0
]:
main
=
Main_M12
(
main_owner_of_m12
=
instance
,
boilerplate_of_m12
=
instance
.
boilerplate_of_main
)
main
.
save
()
except
Main_M12
.
DoesNotExist
:
if
now_main
==
MAIN_CHOICES
[
12
][
0
]:
main
=
Main_M12
(
main_owner_of_m12
=
instance
,
boilerplate_of_m12
=
instance
.
boilerplate_of_main
)
main
.
save
()
def
create_m13
(
instance
,
now_main
,
prev_main
):
try
:
main
=
Main_M13
.
objects
.
get
(
main_owner_of_m13
=
instance
,
boilerplate_of_m13
=
instance
.
boilerplate_of_main
)
if
now_main
==
prev_main
:
return
main
=
Main_M13
.
objects
.
get
(
main_owner_of_m13
=
instance
,
boilerplate_of_m13
=
instance
.
boilerplate_of_main
)
main
.
delete
()
if
now_main
==
MAIN_CHOICES
[
13
][
0
]:
main
=
Main_M13
(
main_owner_of_m13
=
instance
,
boilerplate_of_m13
=
instance
.
boilerplate_of_main
)
main
.
save
()
except
Main_M13
.
DoesNotExist
:
if
now_main
==
MAIN_CHOICES
[
13
][
0
]:
main
=
Main_M13
(
main_owner_of_m13
=
instance
,
boilerplate_of_m13
=
instance
.
boilerplate_of_main
)
main
.
save
()
def
create_m14
(
instance
,
now_main
,
prev_main
):
try
:
main
=
Main_M14
.
objects
.
get
(
main_owner_of_m14
=
instance
,
boilerplate_of_m14
=
instance
.
boilerplate_of_main
)
if
now_main
==
prev_main
:
return
main
=
Main_M14
.
objects
.
get
(
main_owner_of_m14
=
instance
,
boilerplate_of_m14
=
instance
.
boilerplate_of_main
)
main
.
delete
()
if
now_main
==
MAIN_CHOICES
[
14
][
0
]:
main
=
Main_M14
(
main_owner_of_m14
=
instance
,
boilerplate_of_m14
=
instance
.
boilerplate_of_main
)
main
.
save
()
except
Main_M14
.
DoesNotExist
:
if
now_main
==
MAIN_CHOICES
[
14
][
0
]:
main
=
Main_M14
(
main_owner_of_m14
=
instance
,
boilerplate_of_m14
=
instance
.
boilerplate_of_main
)
main
.
save
()
def
create_m15
(
instance
,
now_main
,
prev_main
):
try
:
main
=
Main_M15
.
objects
.
get
(
main_owner_of_m15
=
instance
,
boilerplate_of_m15
=
instance
.
boilerplate_of_main
)
if
now_main
==
prev_main
:
return
main
=
Main_M15
.
objects
.
get
(
main_owner_of_m15
=
instance
,
boilerplate_of_m15
=
instance
.
boilerplate_of_main
)
main
.
delete
()
if
now_main
==
MAIN_CHOICES
[
15
][
0
]:
main
=
Main_M15
(
main_owner_of_m15
=
instance
,
boilerplate_of_m15
=
instance
.
boilerplate_of_main
)
main
.
save
()
except
Main_M15
.
DoesNotExist
:
if
now_main
==
MAIN_CHOICES
[
15
][
0
]:
main
=
Main_M15
(
main_owner_of_m15
=
instance
,
boilerplate_of_m15
=
instance
.
boilerplate_of_main
)
main
.
save
()
def
create_m16
(
instance
,
now_main
,
prev_main
):
try
:
main
=
Main_M16
.
objects
.
get
(
main_owner_of_m16
=
instance
,
boilerplate_of_m16
=
instance
.
boilerplate_of_main
)
if
now_main
==
prev_main
:
return
main
=
Main_M16
.
objects
.
get
(
main_owner_of_m16
=
instance
,
boilerplate_of_m16
=
instance
.
boilerplate_of_main
)
main
.
delete
()
if
now_main
==
MAIN_CHOICES
[
16
][
0
]:
main
=
Main_M16
(
main_owner_of_m16
=
instance
,
boilerplate_of_m16
=
instance
.
boilerplate_of_main
)
main
.
save
()
except
Main_M16
.
DoesNotExist
:
if
now_main
==
MAIN_CHOICES
[
16
][
0
]:
main
=
Main_M16
(
main_owner_of_m16
=
instance
,
boilerplate_of_m16
=
instance
.
boilerplate_of_main
)
main
.
save
()
class
Main
(
models
.
Model
):
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
)
#Subject
sys_fun_inter
=
models
.
CharField
(
choices
=
SYSTEM_FUNCTION_INTERFACE_CHOICES
,
max_length
=
100
)
#Between Subject - Verb
state_before_verb
=
models
.
CharField
(
choices
=
STATE_CHOICES
,
max_length
=
100
,
blank
=
True
)
statevalue_before_verb
=
models
.
CharField
(
choices
=
STATE_VALUE_CHOICES
,
max_length
=
100
,
blank
=
True
)
item_before_verb
=
models
.
CharField
(
choices
=
ITEM_CHOICES
,
max_length
=
100
,
blank
=
True
)
#Verb
shall
=
models
.
CharField
(
choices
=
SHALL_CHOICES
,
max_length
=
100
)
verb
=
models
.
CharField
(
choices
=
VERB_CHOICES
,
max_length
=
100
)
#Between Verb - Object
quantifier
=
models
.
CharField
(
choices
=
QUANTIFIER_CHOICES
,
max_length
=
100
,
blank
=
True
)
numerical
=
models
.
IntegerField
(
default
=
0
,
blank
=
True
)
mumerical_units
=
models
.
CharField
(
choices
=
NUMBER_UNITS_CHOICES
,
max_length
=
100
)
item
=
models
.
CharField
(
choices
=
ITEM_CHOICES
,
max_length
=
100
,
blank
=
True
)
state
=
models
.
CharField
(
choices
=
STATE_CHOICES
,
max_length
=
100
,
blank
=
True
)
statevalue
=
models
.
CharField
(
choices
=
STATE_VALUE_CHOICES
,
max_length
=
100
,
blank
=
True
)
#Οbject
#add stateSet
flow_function_interface_item_system_state
=
models
.
CharField
(
choices
=
FLOW_FUNCTION_INTERFACE_ITEM_SYSTEM_STATE_CHOICES
,
max_length
=
100
,
blank
=
True
)
#last definitions
connection
=
models
.
CharField
(
choices
=
CONNECTION_CHOICES
,
max_length
=
100
,
blank
=
True
)
#ID [M1-M16]
main_choices
=
models
.
CharField
(
choices
=
MAIN_CHOICES
,
max_length
=
100
)
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
Main
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
__important_fields
=
[
'main_choices'
]
for
field
in
self
.
__important_fields
:
setattr
(
self
,
'__original_
%
s'
%
field
,
getattr
(
self
,
field
))
def
save
(
self
,
**
kwargs
):
"""Create P1, P2 or P3 """
prev_main_list
=
[]
super
(
Main
,
self
)
.
save
(
**
kwargs
)
for
field
in
self
.
__important_fields
:
orig
=
'__original_
%
s'
%
field
previous_main
=
getattr
(
self
,
orig
)
prev_main_list
.
append
(
previous_main
)
'''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
])
create_m5
(
self
,
self
.
main_choices
,
prev_main_list
[
0
])
create_m6
(
self
,
self
.
main_choices
,
prev_main_list
[
0
])
create_m7
(
self
,
self
.
main_choices
,
prev_main_list
[
0
])
create_m8
(
self
,
self
.
main_choices
,
prev_main_list
[
0
])
create_m9
(
self
,
self
.
main_choices
,
prev_main_list
[
0
])
create_m10
(
self
,
self
.
main_choices
,
prev_main_list
[
0
])
create_m11
(
self
,
self
.
main_choices
,
prev_main_list
[
0
])
create_m12
(
self
,
self
.
main_choices
,
prev_main_list
[
0
])
create_m13
(
self
,
self
.
main_choices
,
prev_main_list
[
0
])
create_m14
(
self
,
self
.
main_choices
,
prev_main_list
[
0
])
create_m15
(
self
,
self
.
main_choices
,
prev_main_list
[
0
])
create_m16
(
self
,
self
.
main_choices
,
prev_main_list
[
0
])
class
Meta
:
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
(
choices
=
STATE_CHOICES
,
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'
]
class
Main_M5
(
models
.
Model
):
boilerplate_of_m5
=
models
.
ForeignKey
(
'reqtool.Boilerplate'
,
related_name
=
'main_boilerplate_of_M5'
,
on_delete
=
models
.
CASCADE
)
main_owner_of_m5
=
models
.
ForeignKey
(
Main
,
related_name
=
'main_owner_of_M5'
,
on_delete
=
models
.
CASCADE
)
sys_fun_m5
=
models
.
CharField
(
choices
=
SYSTEM_OR_FUNCTION_CHOICES
,
max_length
=
100
)
shall_m5
=
models
.
CharField
(
choices
=
SHALL_CHOICES
,
max_length
=
100
)
flow_m5
=
models
.
CharField
(
choices
=
FLOW_CHOICES
,
max_length
=
100
)
class
Meta
:
ordering
=
[
'boilerplate_of_m5'
]
class
Main_M6
(
models
.
Model
):
boilerplate_of_m6
=
models
.
ForeignKey
(
'reqtool.Boilerplate'
,
related_name
=
'main_boilerplate_of_M6'
,
on_delete
=
models
.
CASCADE
)
main_owner_of_m6
=
models
.
ForeignKey
(
Main
,
related_name
=
'main_owner_of_M6'
,
on_delete
=
models
.
CASCADE
)
sys_fun_m6
=
models
.
CharField
(
choices
=
SYSTEM_OR_FUNCTION_CHOICES
,
max_length
=
100
)
shall_m6
=
models
.
CharField
(
choices
=
SHALL_CHOICES
,
max_length
=
100
)
flow_m6
=
models
.
CharField
(
choices
=
FLOW_CHOICES
,
max_length
=
100
)
class
Meta
:
ordering
=
[
'boilerplate_of_m6'
]
class
Main_M7
(
models
.
Model
):
boilerplate_of_m7
=
models
.
ForeignKey
(
'reqtool.Boilerplate'
,
related_name
=
'main_boilerplate_of_M7'
,
on_delete
=
models
.
CASCADE
)
main_owner_of_m7
=
models
.
ForeignKey
(
Main
,
related_name
=
'main_owner_of_M7'
,
on_delete
=
models
.
CASCADE
)
system_m7
=
models
.
CharField
(
choices
=
SYSTEM_CHOICES
,
max_length
=
100
)
shall_m7
=
models
.
CharField
(
choices
=
SHALL_CHOICES
,
max_length
=
100
)
function_m7
=
models
.
CharField
(
choices
=
FUNCTION_CHOICES
,
max_length
=
100
)
class
Meta
:
ordering
=
[
'boilerplate_of_m7'
]
class
Main_M8
(
models
.
Model
):
boilerplate_of_m8
=
models
.
ForeignKey
(
'reqtool.Boilerplate'
,
related_name
=
'main_boilerplate_of_M8'
,
on_delete
=
models
.
CASCADE
)
main_owner_of_m8
=
models
.
ForeignKey
(
Main
,
related_name
=
'main_owner_of_M8'
,
on_delete
=
models
.
CASCADE
)
function_1_m8
=
models
.
CharField
(
choices
=
FUNCTION_CHOICES
,
max_length
=
100
)
shall_m8
=
models
.
CharField
(
choices
=
SHALL_CHOICES
,
max_length
=
100
)
function_2_m8
=
models
.
CharField
(
choices
=
FUNCTION_CHOICES
,
max_length
=
100
)
class
Meta
:
ordering
=
[
'boilerplate_of_m8'
]
class
Main_M9
(
models
.
Model
):
boilerplate_of_m9
=
models
.
ForeignKey
(
'reqtool.Boilerplate'
,
related_name
=
'main_boilerplate_of_M9'
,
on_delete
=
models
.
CASCADE
)
main_owner_of_m9
=
models
.
ForeignKey
(
Main
,
related_name
=
'main_owner_of_M9'
,
on_delete
=
models
.
CASCADE
)
system_1_m9
=
models
.
CharField
(
choices
=
SYSTEM_CHOICES
,
max_length
=
100
)
shall_m9
=
models
.
CharField
(
choices
=
SHALL_CHOICES
,
max_length
=
100
)
interface_m9
=
models
.
CharField
(
choices
=
INTERFACE_CHOICES
,
max_length
=
100
)
system_2_m9
=
models
.
CharField
(
choices
=
SYSTEM_CHOICES
,
max_length
=
100
)
class
Meta
:
ordering
=
[
'boilerplate_of_m9'
]
class
Main_M10
(
models
.
Model
):
boilerplate_of_m10
=
models
.
ForeignKey
(
'reqtool.Boilerplate'
,
related_name
=
'main_boilerplate_of_M10'
,
on_delete
=
models
.
CASCADE
)
main_owner_of_m10
=
models
.
ForeignKey
(
Main
,
related_name
=
'main_owner_of_M10'
,
on_delete
=
models
.
CASCADE
)
sys_inter_m10
=
models
.
CharField
(
choices
=
SYSTEM_INTERFACE_CHOICES
,
max_length
=
100
)
shall_m10
=
models
.
CharField
(
choices
=
SHALL_CHOICES
,
max_length
=
100
)
flow_item_m9
=
models
.
CharField
(
choices
=
FLOW_ITEM_CHOICES
,
max_length
=
100
)
class
Meta
:
ordering
=
[
'boilerplate_of_m10'
]
#need to ask about [as dened in <text>]
class
Main_M11
(
models
.
Model
):
boilerplate_of_m11
=
models
.
ForeignKey
(
'reqtool.Boilerplate'
,
related_name
=
'main_boilerplate_of_M11'
,
on_delete
=
models
.
CASCADE
)
main_owner_of_m11
=
models
.
ForeignKey
(
Main
,
related_name
=
'main_owner_of_M11'
,
on_delete
=
models
.
CASCADE
)
system_1_m11
=
models
.
CharField
(
choices
=
SYSTEM_CHOICES
,
max_length
=
100
)
shall_m11
=
models
.
CharField
(
choices
=
SHALL_CHOICES
,
max_length
=
100
)
system_2_m11
=
models
.
CharField
(
choices
=
SYSTEM_CHOICES
,
max_length
=
100
)
connection_m11
=
models
.
CharField
(
choices
=
CONNECTION_CHOICES
,
max_length
=
100
)
class
Meta
:
ordering
=
[
'boilerplate_of_m11'
]
#need to ask about [with values stateSet]
class
Main_M12
(
models
.
Model
):
boilerplate_of_m12
=
models
.
ForeignKey
(
'reqtool.Boilerplate'
,
related_name
=
'main_boilerplate_of_M12'
,
on_delete
=
models
.
CASCADE
)
main_owner_of_m12
=
models
.
ForeignKey
(
Main
,
related_name
=
'main_owner_of_M12'
,
on_delete
=
models
.
CASCADE
)
system_m12
=
models
.
CharField
(
choices
=
SYSTEM_CHOICES
,
max_length
=
100
)
shall_m12
=
models
.
CharField
(
choices
=
SHALL_CHOICES
,
max_length
=
100
)
state_m12
=
models
.
CharField
(
choices
=
STATE_CHOICES
,
max_length
=
100
)
class
Meta
:
ordering
=
[
'boilerplate_of_m12'
]
#need to ask about [with values stateSet]
class
Main_M13
(
models
.
Model
):
boilerplate_of_m13
=
models
.
ForeignKey
(
'reqtool.Boilerplate'
,
related_name
=
'main_boilerplate_of_M13'
,
on_delete
=
models
.
CASCADE
)
main_owner_of_m13
=
models
.
ForeignKey
(
Main
,
related_name
=
'main_owner_of_M13'
,
on_delete
=
models
.
CASCADE
)
system_m13
=
models
.
CharField
(
choices
=
SYSTEM_CHOICES
,
max_length
=
100
)
state_1_m13
=
models
.
CharField
(
choices
=
STATE_CHOICES
,
max_length
=
100
)
statevalue_m13
=
models
.
CharField
(
choices
=
STATE_VALUE_CHOICES
,
max_length
=
100
)
shall_m13
=
models
.
CharField
(
choices
=
SHALL_CHOICES
,
max_length
=
100
)
state_2_m13
=
models
.
CharField
(
choices
=
STATE_CHOICES
,
max_length
=
100
)
class
Meta
:
ordering
=
[
'boilerplate_of_m13'
]
class
Main_M14
(
models
.
Model
):
boilerplate_of_m14
=
models
.
ForeignKey
(
'reqtool.Boilerplate'
,
related_name
=
'main_boilerplate_of_M14'
,
on_delete
=
models
.
CASCADE
)
main_owner_of_m14
=
models
.
ForeignKey
(
Main
,
related_name
=
'main_owner_of_M14'
,
on_delete
=
models
.
CASCADE
)
system_m14
=
models
.
CharField
(
choices
=
SYSTEM_CHOICES
,
max_length
=
100
)
item_m14
=
models
.
CharField
(
choices
=
ITEM_CHOICES
,
max_length
=
100
)
shall_m14
=
models
.
CharField
(
choices
=
SHALL_CHOICES
,
max_length
=
100
)
#needs stateSET
class
Meta
:
ordering
=
[
'boilerplate_of_m14'
]
class
Main_M15
(
models
.
Model
):
boilerplate_of_m15
=
models
.
ForeignKey
(
'reqtool.Boilerplate'
,
related_name
=
'main_boilerplate_of_M15'
,
on_delete
=
models
.
CASCADE
)
main_owner_of_m15
=
models
.
ForeignKey
(
Main
,
related_name
=
'main_owner_of_M15'
,
on_delete
=
models
.
CASCADE
)
system_m15
=
models
.
CharField
(
choices
=
SYSTEM_CHOICES
,
max_length
=
100
)
item_1_m15
=
models
.
CharField
(
choices
=
ITEM_CHOICES
,
max_length
=
100
)
shall_m15
=
models
.
CharField
(
choices
=
SHALL_CHOICES
,
max_length
=
100
)
item_2_m15
=
models
.
CharField
(
choices
=
ITEM_CHOICES
,
max_length
=
100
)
class
Meta
:
ordering
=
[
'boilerplate_of_m15'
]
class
Main_M16
(
models
.
Model
):
boilerplate_of_m16
=
models
.
ForeignKey
(
'reqtool.Boilerplate'
,
related_name
=
'main_boilerplate_of_M16'
,
on_delete
=
models
.
CASCADE
)
main_owner_of_m16
=
models
.
ForeignKey
(
Main
,
related_name
=
'main_owner_of_M16'
,
on_delete
=
models
.
CASCADE
)
system_1_m16
=
models
.
CharField
(
choices
=
SYSTEM_CHOICES
,
max_length
=
100
)
shall_m16
=
models
.
CharField
(
choices
=
SHALL_CHOICES
,
max_length
=
100
)
system_2_m16
=
models
.
CharField
(
choices
=
SYSTEM_CHOICES
,
max_length
=
100
)
class
Meta
:
ordering
=
[
'boilerplate_of_m16'
]
reqtool/reqman/api/reqman/apps/reqtool/models/requirements.py
View file @
76a7602c
from
django.db
import
models
#from reqman.apps.common.models import CoreModel
from
reqman.apps.account.models
import
User
from
reqman.apps.reqtool.models.main_req
import
create_main
from
reqman.apps.reqtool.models.main_req
import
create_main
,
SYSTEM_OR_FUNCTION_CHOICES
,
ITEM_FLOW_FUNCTION
from
reqman.apps.reqtool.models.suffix_req
import
create_suffix
from
pygments.formatters.html
import
HtmlFormatter
...
...
@@ -13,8 +13,7 @@ SIMPLE_PREFIX_CHOICES = ( ("",""),
(
"P3"
,
"As long as <occuring functionality>"
)
)
LOGIC_CONNECTIVE
=
(
(
""
,
""
),
(
"or"
,
"OR"
),
LOGIC_CONNECTIVE
=
(
(
"or"
,
"OR"
),
(
"and"
,
"AND"
),
(
"xor"
,
"XOR"
)
)
...
...
@@ -24,99 +23,38 @@ LOGICAL_EXPRESSION = ( ("",""),
(
"occuring functionality"
,
"occuring functionality"
)
)
def
create_prefix
(
instance
):
'''Create the Prefix Model for the Boilerplate'''
try
:
prefix
=
Prefix
.
objects
.
get
(
boilerplate
=
instance
,
prefix_owner
=
instance
.
owner
)
if
instance
.
has_prefix
:
return
prefix
=
Prefix
.
objects
.
get
(
boilerplate
=
instance
,
prefix_owner
=
instance
.
owner
)
prefix
.
delete
()
except
Prefix
.
DoesNotExist
:
if
instance
.
has_prefix
:
prefix
=
Prefix
(
boilerplate
=
instance
,
prefix_owner
=
instance
.
owner
)
prefix
.
save
()
def
create_p1
(
instance
,
now_prefix
,
prev_prefix
,
series_of_prefix
):
try
:
prefix
=
LogicalExpression
.
objects
.
get
(
prefix
=
instance
,
prefix_boilerplate
=
instance
.
boilerplate
,
prefix_series
=
series_of_prefix
)
if
now_prefix
==
prev_prefix
:
return
prefix
=
LogicalExpression
.
objects
.
get
(
prefix
=
instance
,
prefix_boilerplate
=
instance
.
boilerplate
,
prefix_series
=
series_of_prefix
)
prefix
.
delete
()
if
now_prefix
==
SIMPLE_PREFIX_CHOICES
[
1
][
0
]:
prefix
=
LogicalExpression
(
prefix
=
instance
,
prefix_boilerplate
=
instance
.
boilerplate
,
prefix_series
=
series_of_prefix
)
prefix
.
save
()
except
LogicalExpression
.
DoesNotExist
:
if
now_prefix
==
SIMPLE_PREFIX_CHOICES
[
1
][
0
]:
prefix
=
LogicalExpression
(
prefix
=
instance
,
prefix_boilerplate
=
instance
.
boilerplate
,
prefix_series
=
series_of_prefix
)
prefix
.
save
()
VERB_CHOICES
=
((
"is"
,
"is"
),(
"send"
,
"send"
),(
"receive"
,
"receive"
),
(
"ingest"
,
"ingest"
),(
"emit"
,
"emit"
),(
"perform"
,
"perform"
))
def
create_p2
(
instance
,
now_prefix
,
prev_prefix
,
series_of_prefix
):
try
:
prefix
=
OccuringFunctionalityP2
.
objects
.
get
(
prefix_of_occuring_functionality_p2
=
instance
,
prefix_boilerplate_of_occuring_functionality_p2
=
instance
.
boilerplate
,
prefix_series_of_occuring_functionality_p2
=
series_of_prefix
)
if
now_prefix
==
prev_prefix
:
return
prefix
=
OccuringFunctionalityP2
.
objects
.
get
(
prefix_of_occuring_functionality_p2
=
instance
,
prefix_boilerplate_of_occuring_functionality_p2
=
instance
.
boilerplate
,
prefix_series_of_occuring_functionality_p2
=
series_of_prefix
)
prefix
.
delete
()
if
now_prefix
==
SIMPLE_PREFIX_CHOICES
[
2
][
0
]:
prefix
=
OccuringFunctionalityP2
(
prefix_of_occuring_functionality_p2
=
instance
,
prefix_boilerplate_of_occuring_functionality_p2
=
instance
.
boilerplate
,
prefix_series_of_occuring_functionality_p2
=
series_of_prefix
)
prefix
.
save
()
except
OccuringFunctionalityP2
.
DoesNotExist
:
if
now_prefix
==
SIMPLE_PREFIX_CHOICES
[
2
][
0
]:
prefix
=
OccuringFunctionalityP2
(
prefix_of_occuring_functionality_p2
=
instance
,
prefix_boilerplate_of_occuring_functionality_p2
=
instance
.
boilerplate
,
prefix_series_of_occuring_functionality_p2
=
series_of_prefix
)
prefix
.
save
()
PREFIX_CHOICES
=
(
(
"If/Unless"
,
"If/Unless"
),
(
"As soon as"
,
"As soon as"
),
(
"As long as"
,
"As long as"
)
)
def
create_p3
(
instance
,
now_prefix
,
prev_prefix
,
series_of_prefix
):
def
create_prefixgroup
(
instance
):
'''Create the PrefixGroup Model for the Boilerplate'''
try
:
prefix
=
OccuringFunctionalityP3
.
objects
.
get
(
prefix_of_occuring_functionality_p3
=
instance
,
prefix_boilerplate_of_occuring_functionality_p3
=
instance
.
boilerplate
,
prefix_series_of_occuring_functionality_p3
=
series_of_prefix
)
if
now_prefix
==
prev
_prefix
:
prefix
=
PrefixGroup
.
objects
.
get
(
boilerplate
=
instance
,
prefix_owner
=
instance
.
owner
)
if
instance
.
has
_prefix
:
return
prefix
=
OccuringFunctionalityP3
.
objects
.
get
(
prefix_of_occuring_functionality_p3
=
instance
,
prefix_boilerplate_of_occuring_functionality_p3
=
instance
.
boilerplate
,
prefix_series_of_occuring_functionality_p3
=
series_of_prefix
)
prefix
=
PrefixGroup
.
objects
.
get
(
boilerplate
=
instance
,
prefix_owner
=
instance
.
owner
)
prefix
.
delete
()
if
now_prefix
==
SIMPLE_PREFIX_CHOICES
[
3
][
0
]:
prefix
=
OccuringFunctionalityP3
(
prefix_of_occuring_functionality_p3
=
instance
,
prefix_boilerplate_of_occuring_functionality_p3
=
instance
.
boilerplate
,
prefix_series_of_occuring_functionality_p3
=
series_of_prefix
)
prefix
.
save
()
except
OccuringFunctionalityP3
.
DoesNotExist
:
if
now_prefix
==
SIMPLE_PREFIX_CHOICES
[
3
][
0
]:
prefix
=
OccuringFunctionalityP3
(
prefix_of_occuring_functionality_p3
=
instance
,
prefix_boilerplate_of_occuring_functionality_p3
=
instance
.
boilerplate
,
prefix_series_of_occuring_functionality_p3
=
series_of_prefix
)
except
PrefixGroup
.
DoesNotExist
:
if
instance
.
has_prefix
:
prefix
=
PrefixGroup
(
boilerplate
=
instance
,
prefix_owner
=
instance
.
owner
)
prefix
.
save
()
def
create_state_value_constraint_from_logical_expression
(
instance
,
logical_expression
,
prev_logical_expression
,
series_of_log_expr
):
try
:
log_expr
=
StateValueConstraint
.
objects
.
get
(
logical_expression
=
instance
,
prefix_of_logical_expression
=
instance
.
prefix
,
log_expr_series
=
series_of_log_expr
)
if
logical_expression
==
prev_logical_expression
:
return
log_expr
=
StateValueConstraint
.
objects
.
get
(
logical_expression
=
instance
,
prefix_of_logical_expression
=
instance
.
prefix
,
log_expr_series
=
series_of_log_expr
)
log_expr
.
delete
()
if
logical_expression
==
LOGICAL_EXPRESSION
[
1
][
0
]:
log_expr
=
StateValueConstraint
(
logical_expression
=
instance
,
prefix_of_logical_expression
=
instance
.
prefix
,
log_expr_series
=
series_of_log_expr
)
log_expr
.
save
()
except
StateValueConstraint
.
DoesNotExist
:
if
logical_expression
==
LOGICAL_EXPRESSION
[
1
][
0
]:
log_expr
=
StateValueConstraint
(
logical_expression
=
instance
,
prefix_of_logical_expression
=
instance
.
prefix
,
log_expr_series
=
series_of_log_expr
)
log_expr
.
save
()
def
create_prefix
(
instance
):
prefix
=
Prefix
(
prefix_boilerplate
=
instance
.
boilerplate
,
prefixgroup
=
instance
)
prefix
.
save
()
def
create_state_occuring_functionality_from_logical_expression
(
instance
,
logical_expression
,
prev_logical_expression
,
series_of_log_expr
):
try
:
log_expr
=
OccuringFunctionalityForLogicalExpression
.
objects
.
get
(
logical_expression_of_occuring
=
instance
,
prefix_of_occuring_for_logical_expression
=
instance
.
prefix
,
log_expres_series
=
series_of_log_expr
)
if
logical_expression
==
prev_logical_expression
:
return
log_expr
=
OccuringFunctionalityForLogicalExpression
.
objects
.
get
(
logical_expression_of_occuring
=
instance
,
prefix_of_occuring_for_logical_expression
=
instance
.
prefix
,
log_expres_series
=
series_of_log_expr
)
log_expr
.
delete
()
if
logical_expression
==
LOGICAL_EXPRESSION
[
2
][
0
]:
log_expr
=
OccuringFunctionalityForLogicalExpression
(
logical_expression_of_occuring
=
instance
,
prefix_of_occuring_for_logical_expression
=
instance
.
prefix
,
log_expres_series
=
series_of_log_expr
)
log_expr
.
save
()
except
OccuringFunctionalityForLogicalExpression
.
DoesNotExist
:
if
logical_expression
==
LOGICAL_EXPRESSION
[
2
][
0
]:
log_expr
=
OccuringFunctionalityForLogicalExpression
(
logical_expression_of_occuring
=
instance
,
prefix_of_occuring_for_logical_expression
=
instance
.
prefix
,
log_expres_series
=
series_of_log_expr
)
log_expr
.
save
()
def
create_extra_prefix
(
instance
,
now_prefix
):
prefix
=
Prefix
(
prefixgroup
=
instance
.
prefixgroup
,
prefix_boilerplate
=
instance
.
prefix_boilerplate
)
prefix
.
save
()
class
Boilerplate
(
models
.
Model
):
...
...
@@ -130,7 +68,7 @@ class Boilerplate(models.Model):
def
save
(
self
,
**
kwargs
):
"""Create prefix, main or suffix """
super
(
Boilerplate
,
self
)
.
save
(
**
kwargs
)
create_prefix
(
self
)
create_prefix
group
(
self
)
create_main
(
self
)
create_suffix
(
self
)
...
...
@@ -138,23 +76,43 @@ class Boilerplate(models.Model):
class
Meta
:
ordering
=
[
'created'
]
class
PrefixGroup
(
models
.
Model
):
boilerplate
=
models
.
ForeignKey
(
Boilerplate
,
related_name
=
'prefixgroup'
,
on_delete
=
models
.
CASCADE
)
prefix_owner
=
models
.
ForeignKey
(
User
,
related_name
=
'prefix_group_owner'
,
on_delete
=
models
.
CASCADE
)
def
save
(
self
,
**
kwargs
):
super
(
PrefixGroup
,
self
)
.
save
(
**
kwargs
)
create_prefix
(
self
)
class
Prefix
(
models
.
Model
):
#boilerplate = models.OneToOneField(Boilerplate, related_name='prefix', on_delete=models.CASCADE, primary_key=True)
boilerplate
=
models
.
ForeignKey
(
Boilerplate
,
related_name
=
'prefix'
,
on_delete
=
models
.
CASCADE
)
prefix_owner
=
models
.
ForeignKey
(
User
,
related_name
=
'prefix_owner'
,
on_delete
=
models
.
CASCADE
)
simple_prefix_1
=
models
.
CharField
(
choices
=
SIMPLE_PREFIX_CHOICES
,
max_length
=
100
)
logic_connective_1
=
models
.
CharField
(
choices
=
LOGIC_CONNECTIVE
,
default
=
''
,
max_length
=
100
,
null
=
True
)
simple_prefix_2
=
models
.
CharField
(
choices
=
SIMPLE_PREFIX_CHOICES
,
default
=
''
,
max_length
=
100
,
null
=
True
)
logic_connective_2
=
models
.
CharField
(
choices
=
LOGIC_CONNECTIVE
,
default
=
''
,
max_length
=
100
,
null
=
True
)
simple_prefix_3
=
models
.
CharField
(
choices
=
SIMPLE_PREFIX_CHOICES
,
default
=
''
,
max_length
=
100
,
null
=
True
)
prefixgroup
=
models
.
ForeignKey
(
PrefixGroup
,
related_name
=
'prefix'
,
on_delete
=
models
.
CASCADE
)
prefix_boilerplate
=
models
.
ForeignKey
(
Boilerplate
,
related_name
=
'prefix_boilerplate'
,
on_delete
=
models
.
CASCADE
)
prefix
=
models
.
CharField
(
choices
=
PREFIX_CHOICES
,
max_length
=
100
)
#state value constraint
item_log
=
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
)
#occuring functionality
sys_fun
=
models
.
TextField
(
choices
=
SYSTEM_OR_FUNCTION_CHOICES
,
max_length
=
100
,
blank
=
True
)
verb
=
models
.
TextField
(
choices
=
VERB_CHOICES
,
max_length
=
100
,
blank
=
True
)
item_function_flow
=
models
.
TextField
(
choices
=
ITEM_FLOW_FUNCTION
,
max_length
=
100
,
blank
=
True
)
#Prefix value P1/P2/P3
logical_expression
=
models
.
CharField
(
choices
=
LOGICAL_EXPRESSION
,
max_length
=
100
)
#add extra prefix
logic_connective
=
models
.
CharField
(
choices
=
LOGIC_CONNECTIVE
,
default
=
''
,
max_length
=
100
,
null
=
True
)
simple_prefix
=
models
.
CharField
(
choices
=
SIMPLE_PREFIX_CHOICES
,
max_length
=
100
)
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
Prefix
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
__important_fields
=
[
'
simple_prefix_1'
,
'simple_prefix_2'
,
'simple_prefix_3
'
]
self
.
__important_fields
=
[
'
logic_connective
'
]
for
field
in
self
.
__important_fields
:
setattr
(
self
,
'__original_
%
s'
%
field
,
getattr
(
self
,
field
))
def
save
(
self
,
**
kwargs
):
"""Create P1, P2 or P3 """
...
...
@@ -163,115 +121,11 @@ class Prefix(models.Model):
for
field
in
self
.
__important_fields
:
orig
=
'__original_
%
s'
%
field
previous_simple_prefix
=
getattr
(
self
,
orig
)
prev_prefix_list
.
append
(
previous_simple_prefix
)
'''Create P1 '''
create_p1
(
self
,
self
.
simple_prefix_1
,
prev_prefix_list
[
0
],
'1'
)
create_p1
(
self
,
self
.
simple_prefix_2
,
prev_prefix_list
[
1
],
'2'
)
create_p1
(
self
,
self
.
simple_prefix_3
,
prev_prefix_list
[
2
],
'3'
)
'''Create P2 '''
create_p2
(
self
,
self
.
simple_prefix_1
,
prev_prefix_list
[
0
],
'1'
)
create_p2
(
self
,
self
.
simple_prefix_2
,
prev_prefix_list
[
1
],
'2'
)
create_p2
(
self
,
self
.
simple_prefix_3
,
prev_prefix_list
[
2
],
'3'
)
'''Create P3 '''
create_p3
(
self
,
self
.
simple_prefix_1
,
prev_prefix_list
[
0
],
'1'
)
create_p3
(
self
,
self
.
simple_prefix_2
,
prev_prefix_list
[
1
],
'2'
)
create_p3
(
self
,
self
.
simple_prefix_3
,
prev_prefix_list
[
2
],
'3'
)
class
Meta
:
ordering
=
[
'boilerplate'
]
class
LogicalExpression
(
models
.
Model
):
prefix
=
models
.
ForeignKey
(
Prefix
,
related_name
=
'log_expr'
,
on_delete
=
models
.
CASCADE
)
prefix_boilerplate
=
models
.
ForeignKey
(
Boilerplate
,
related_name
=
'logic_expr'
,
on_delete
=
models
.
CASCADE
)
prefix_series
=
models
.
TextField
(
default
=
'0'
)
logical_expression_1
=
models
.
CharField
(
choices
=
LOGICAL_EXPRESSION
,
max_length
=
100
)
logic_connective_1
=
models
.
CharField
(
choices
=
LOGIC_CONNECTIVE
,
default
=
''
,
max_length
=
100
,
null
=
True
)
logical_expression_2
=
models
.
CharField
(
choices
=
LOGICAL_EXPRESSION
,
default
=
''
,
max_length
=
100
,
null
=
True
)
logic_connective_2
=
models
.
CharField
(
choices
=
LOGIC_CONNECTIVE
,
default
=
''
,
max_length
=
100
,
null
=
True
)
logical_expression_3
=
models
.
CharField
(
choices
=
LOGICAL_EXPRESSION
,
default
=
''
,
max_length
=
100
,
null
=
True
)
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
LogicalExpression
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
__important_fields
=
[
'logical_expression_1'
,
'logical_expression_2'
,
'logical_expression_3'
,
'prefix_boilerplate'
]
for
field
in
self
.
__important_fields
:
setattr
(
self
,
'__original_
%
s'
%
field
,
getattr
(
self
,
field
))
def
save
(
self
,
**
kwargs
):
"""Create State Value Constraint or Occuring Functionality"""
prev_log_expr_list
=
[]
super
(
LogicalExpression
,
self
)
.
save
(
**
kwargs
)
for
field
in
self
.
__important_fields
:
orig
=
'__original_
%
s'
%
field
previous_log_expr
=
getattr
(
self
,
orig
)
prev_log_expr_list
.
append
(
previous_log_expr
)
'''Create a state value constraint '''
create_state_value_constraint_from_logical_expression
(
self
,
self
.
logical_expression_1
,
prev_log_expr_list
[
0
],
'1'
)
create_state_value_constraint_from_logical_expression
(
self
,
self
.
logical_expression_2
,
prev_log_expr_list
[
1
],
'2'
)
create_state_value_constraint_from_logical_expression
(
self
,
self
.
logical_expression_3
,
prev_log_expr_list
[
2
],
'3'
)
'''Create a occuring functionality '''
create_state_occuring_functionality_from_logical_expression
(
self
,
self
.
logical_expression_1
,
prev_log_expr_list
[
0
],
'1'
)
create_state_occuring_functionality_from_logical_expression
(
self
,
self
.
logical_expression_2
,
prev_log_expr_list
[
1
],
'2'
)
create_state_occuring_functionality_from_logical_expression
(
self
,
self
.
logical_expression_3
,
prev_log_expr_list
[
2
],
'3'
)
prev_prefix_list
.
append
(
previous_simple_prefix
)
if
previous_simple_prefix
==
""
and
not
self
.
logic_connective
==
""
:
create_extra_prefix
(
self
,
self
.
logic_connective
)
class
Meta
:
ordering
=
[
'prefix_boilerplate'
]
class
OccuringFunctionalityP2
(
models
.
Model
):
prefix_of_occuring_functionality_p2
=
models
.
ForeignKey
(
Prefix
,
related_name
=
'occuring_functionality'
,
on_delete
=
models
.
CASCADE
)
prefix_boilerplate_of_occuring_functionality_p2
=
models
.
ForeignKey
(
Boilerplate
,
related_name
=
'occuring_functionality_b'
,
on_delete
=
models
.
CASCADE
)
prefix_series_of_occuring_functionality_p2
=
models
.
TextField
(
default
=
'0'
)
system_for_occuring_functionality_p2
=
models
.
TextField
(
max_length
=
100
,
blank
=
True
,)
perform_for_occuring_functionality_p2
=
models
.
TextField
(
max_length
=
100
,
blank
=
True
,)
function_for_occuring_functionality_p2
=
models
.
TextField
(
max_length
=
100
,
blank
=
True
,)
item_for_occuring_functionality_p2
=
models
.
TextField
(
max_length
=
100
,
blank
=
True
,)
flow_for_occuring_functionality_p2
=
models
.
TextField
(
max_length
=
100
,
blank
=
True
,)
class
Meta
:
ordering
=
[
'prefix_boilerplate_of_occuring_functionality_p2'
]
class
OccuringFunctionalityP3
(
models
.
Model
):
prefix_of_occuring_functionality_p3
=
models
.
ForeignKey
(
Prefix
,
related_name
=
'occuring_functionality_p3'
,
on_delete
=
models
.
CASCADE
)
prefix_boilerplate_of_occuring_functionality_p3
=
models
.
ForeignKey
(
Boilerplate
,
related_name
=
'occuring_functionality_b_p3'
,
on_delete
=
models
.
CASCADE
)
prefix_series_of_occuring_functionality_p3
=
models
.
TextField
(
default
=
'0'
)
system_for_occuring_functionality_p3
=
models
.
TextField
(
max_length
=
100
,
blank
=
True
,)
perform_for_occuring_functionality_p3
=
models
.
TextField
(
max_length
=
100
,
blank
=
True
,)
function_for_occuring_functionality_p3
=
models
.
TextField
(
max_length
=
100
,
blank
=
True
,)
item_for_occuring_functionality_p3
=
models
.
TextField
(
max_length
=
100
,
blank
=
True
,)
flow_for_occuring_functionality_p3
=
models
.
TextField
(
max_length
=
100
,
blank
=
True
,)
class
Meta
:
ordering
=
[
'prefix_boilerplate_of_occuring_functionality_p3'
]
class
StateValueConstraint
(
models
.
Model
):
prefix_of_logical_expression
=
models
.
ForeignKey
(
Prefix
,
related_name
=
'prefix_of_log_expr'
,
on_delete
=
models
.
CASCADE
)
logical_expression
=
models
.
ForeignKey
(
LogicalExpression
,
related_name
=
'own_log_expr'
,
on_delete
=
models
.
CASCADE
)
log_expr_series
=
models
.
TextField
(
default
=
'0'
)
item
=
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
,)
class
Meta
:
ordering
=
[
'logical_expression'
]
class
OccuringFunctionalityForLogicalExpression
(
models
.
Model
):
prefix_of_occuring_for_logical_expression
=
models
.
ForeignKey
(
Prefix
,
related_name
=
'prefix_of_occur_funct'
,
on_delete
=
models
.
CASCADE
)
logical_expression_of_occuring
=
models
.
ForeignKey
(
LogicalExpression
,
related_name
=
'owner_of_log_expr'
,
on_delete
=
models
.
CASCADE
)
log_expres_series
=
models
.
TextField
(
default
=
'0'
)
#model to be done (send,receives, ingests etc.)
system_for_logical_expression
=
models
.
TextField
(
max_length
=
100
,
blank
=
True
,)
perform_for_logical_expression
=
models
.
TextField
(
max_length
=
100
,
blank
=
True
,)
function_for_logical_expression
=
models
.
TextField
(
max_length
=
100
,
blank
=
True
,)
item_for_logical_expression
=
models
.
TextField
(
max_length
=
100
,
blank
=
True
,)
flow_for_logical_expression
=
models
.
TextField
(
max_length
=
100
,
blank
=
True
,)
class
Meta
:
ordering
=
[
'logical_expression_of_occuring'
]
\ No newline at end of file
reqtool/reqman/api/reqman/apps/reqtool/models/suffix_req.py
View file @
76a7602c
...
...
@@ -7,14 +7,14 @@ from pygments import highlight
from
reqman.apps.reqtool.rest_api.services.parse_ontologies
import
*
SUFFIX_CHOICES
=
((
""
,
""
),
(
'S1'
,
'S1: <numerical-a
rmative> j <closed-interval> [per <time-unit>]'
),
SUFFIX_CHOICES
=
((
""
,
""
),
(
'S1'
,
'S1: <numerical-a
ffi
rmative> j <closed-interval> [per <time-unit>]'
),
(
'S2'
,
'S2: after/before flow'
),
(
'S3'
,
'S3: [every/for a period of/within/for at least] <number> <time-unit> [from flow]'
),
(
'S4'
,
'S4: at the beginning/at the end'
),
(
'S5'
,
'S5: at even intervals'
),
(
'S6'
,
'S6: sequentially'
)
)
NUMERICAL_AFFIRMATIVE_CHOICES
=
((
"
"
,
""
),
(
"
more than"
,
"MORE THAN"
),
(
"less than"
,
"LESS THAN"
),
(
"exactly"
,
"EXACTLY"
),
NUMERICAL_AFFIRMATIVE_CHOICES
=
((
"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"
))
TIME_UNITS_CHOICES
=
((
""
,
""
),
(
"seconds"
,
"SECONDS"
),
(
"minutes"
,
"MINUTES"
),
(
"milliseconds"
,
"MILLISECONDS"
))
...
...
@@ -23,8 +23,9 @@ FLOW_CHOICES = find_extra_keywords(":Flow", 3)
S2_CHOICES
=
((
"before"
,
"BEFORE"
),
(
"after"
,
"AFTER"
))
S3_CHOICES
=
((
"every"
,
"EVERY"
),
(
"for a period of"
,
"FOR A PERIOD OF"
),
(
"within"
,
"WITHIN"
),
(
"for at least"
,
"FOR AT LEAST"
))
S4_CHOICES
=
((
"at the beginning"
,
"AT THE BEGINNING"
),
(
"at the end"
,
"AT THE END"
))
S5_CHOICES
=
((
""
,
""
),
(
"at even intervals"
,
"AT EVEN INTERVALS"
))
S6_CHOICES
=
((
""
,
""
),
(
"sequentially"
,
"SEQUENTIALLY"
))
S5_6_CHOICES
=
((
"at even intervals"
,
"AT EVEN INTERVALS"
),
(
"sequentially"
,
"SEQUENTIALLY"
))
S_CHOICES
=
NUMERICAL_AFFIRMATIVE_CHOICES
+
S2_CHOICES
+
S3_CHOICES
+
S4_CHOICES
+
S5_6_CHOICES
def
create_suffix
(
instance
):
...
...
@@ -41,196 +42,21 @@ def create_suffix(instance):
suffix
.
save
()
def
create_s1
(
instance
,
now_suffix
,
prev_suffix
):
try
:
suffix
=
Suffix_S1
.
objects
.
get
(
suffix_owner_of_s1
=
instance
,
boilerplate_of_s1
=
instance
.
boilerplate_of_suffix
)
if
now_suffix
==
prev_suffix
:
return
suffix
=
Suffix_S1
.
objects
.
get
(
suffix_owner_of_s1
=
instance
,
boilerplate_of_s1
=
instance
.
boilerplate_of_suffix
)
suffix
.
delete
()
if
now_suffix
==
SUFFIX_CHOICES
[
1
][
0
]:
suffix
=
Suffix_S1
(
suffix_owner_of_s1
=
instance
,
boilerplate_of_s1
=
instance
.
boilerplate_of_suffix
)
suffix
.
save
()
except
Suffix_S1
.
DoesNotExist
:
if
now_suffix
==
SUFFIX_CHOICES
[
1
][
0
]:
suffix
=
Suffix_S1
(
suffix_owner_of_s1
=
instance
,
boilerplate_of_s1
=
instance
.
boilerplate_of_suffix
)
suffix
.
save
()
def
create_s2
(
instance
,
now_suffix
,
prev_suffix
):
try
:
suffix
=
Suffix_S2
.
objects
.
get
(
suffix_owner_of_s2
=
instance
,
boilerplate_of_s2
=
instance
.
boilerplate_of_suffix
)
if
now_suffix
==
prev_suffix
:
return
suffix
=
Suffix_S2
.
objects
.
get
(
suffix_owner_of_s2
=
instance
,
boilerplate_of_s2
=
instance
.
boilerplate_of_suffix
)
suffix
.
delete
()
if
now_suffix
==
SUFFIX_CHOICES
[
2
][
0
]:
suffix
=
Suffix_S2
(
suffix_owner_of_s2
=
instance
,
boilerplate_of_s2
=
instance
.
boilerplate_of_suffix
)
suffix
.
save
()
except
Suffix_S2
.
DoesNotExist
:
if
now_suffix
==
SUFFIX_CHOICES
[
2
][
0
]:
suffix
=
Suffix_S2
(
suffix_owner_of_s2
=
instance
,
boilerplate_of_s2
=
instance
.
boilerplate_of_suffix
)
suffix
.
save
()
def
create_s3
(
instance
,
now_suffix
,
prev_suffix
):
try
:
suffix
=
Suffix_S3
.
objects
.
get
(
suffix_owner_of_s3
=
instance
,
boilerplate_of_s3
=
instance
.
boilerplate_of_suffix
)
if
now_suffix
==
prev_suffix
:
return
suffix
=
Suffix_S3
.
objects
.
get
(
suffix_owner_of_s3
=
instance
,
boilerplate_of_s3
=
instance
.
boilerplate_of_suffix
)
suffix
.
delete
()
if
now_suffix
==
SUFFIX_CHOICES
[
3
][
0
]:
suffix
=
Suffix_S3
(
suffix_owner_of_s3
=
instance
,
boilerplate_of_s3
=
instance
.
boilerplate_of_suffix
)
suffix
.
save
()
except
Suffix_S3
.
DoesNotExist
:
if
now_suffix
==
SUFFIX_CHOICES
[
3
][
0
]:
suffix
=
Suffix_S3
(
suffix_owner_of_s3
=
instance
,
boilerplate_of_s3
=
instance
.
boilerplate_of_suffix
)
suffix
.
save
()
def
create_s4
(
instance
,
now_suffix
,
prev_suffix
):
try
:
suffix
=
Suffix_S4
.
objects
.
get
(
suffix_owner_of_s4
=
instance
,
boilerplate_of_s4
=
instance
.
boilerplate_of_suffix
)
if
now_suffix
==
prev_suffix
:
return
suffix
=
Suffix_S4
.
objects
.
get
(
suffix_owner_of_s4
=
instance
,
boilerplate_of_s4
=
instance
.
boilerplate_of_suffix
)
suffix
.
delete
()
if
now_suffix
==
SUFFIX_CHOICES
[
4
][
0
]:
suffix
=
Suffix_S4
(
suffix_owner_of_s4
=
instance
,
boilerplate_of_s4
=
instance
.
boilerplate_of_suffix
)
suffix
.
save
()
except
Suffix_S4
.
DoesNotExist
:
if
now_suffix
==
SUFFIX_CHOICES
[
4
][
0
]:
suffix
=
Suffix_S4
(
suffix_owner_of_s4
=
instance
,
boilerplate_of_s4
=
instance
.
boilerplate_of_suffix
)
suffix
.
save
()
def
create_s5
(
instance
,
now_suffix
,
prev_suffix
):
try
:
suffix
=
Suffix_S5
.
objects
.
get
(
suffix_owner_of_s5
=
instance
,
boilerplate_of_s5
=
instance
.
boilerplate_of_suffix
)
if
now_suffix
==
prev_suffix
:
return
suffix
=
Suffix_S5
.
objects
.
get
(
suffix_owner_of_s5
=
instance
,
boilerplate_of_s5
=
instance
.
boilerplate_of_suffix
)
suffix
.
delete
()
if
now_suffix
==
SUFFIX_CHOICES
[
5
][
0
]:
suffix
=
Suffix_S5
(
suffix_owner_of_s5
=
instance
,
boilerplate_of_s5
=
instance
.
boilerplate_of_suffix
)
suffix
.
save
()
except
Suffix_S5
.
DoesNotExist
:
if
now_suffix
==
SUFFIX_CHOICES
[
5
][
0
]:
suffix
=
Suffix_S5
(
suffix_owner_of_s5
=
instance
,
boilerplate_of_s5
=
instance
.
boilerplate_of_suffix
)
suffix
.
save
()
def
create_s6
(
instance
,
now_suffix
,
prev_suffix
):
try
:
suffix
=
Suffix_S6
.
objects
.
get
(
suffix_owner_of_s6
=
instance
,
boilerplate_of_s6
=
instance
.
boilerplate_of_suffix
)
if
now_suffix
==
prev_suffix
:
return
suffix
=
Suffix_S6
.
objects
.
get
(
suffix_owner_of_s6
=
instance
,
boilerplate_of_s6
=
instance
.
boilerplate_of_suffix
)
suffix
.
delete
()
if
now_suffix
==
SUFFIX_CHOICES
[
6
][
0
]:
suffix
=
Suffix_S6
(
suffix_owner_of_s6
=
instance
,
boilerplate_of_s6
=
instance
.
boilerplate_of_suffix
)
suffix
.
save
()
except
Suffix_S6
.
DoesNotExist
:
if
now_suffix
==
SUFFIX_CHOICES
[
6
][
0
]:
suffix
=
Suffix_S6
(
suffix_owner_of_s6
=
instance
,
boilerplate_of_s6
=
instance
.
boilerplate_of_suffix
)
suffix
.
save
()
class
Suffix
(
models
.
Model
):
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
)
#prefix templates
s_choices
=
models
.
CharField
(
choices
=
S_CHOICES
,
max_length
=
100
)
#if S1
numerical
=
models
.
IntegerField
(
default
=
0
,
blank
=
True
)
mumerical_units
=
models
.
CharField
(
choices
=
NUMBER_UNITS_CHOICES
,
max_length
=
100
)
time_units
=
models
.
CharField
(
choices
=
TIME_UNITS_CHOICES
,
max_length
=
100
)
#if S2/S3
flow
=
models
.
CharField
(
choices
=
FLOW_CHOICES
,
max_length
=
100
)
#find suffix
suffix_choices
=
models
.
CharField
(
choices
=
SUFFIX_CHOICES
,
max_length
=
100
)
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
Suffix
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
__important_fields
=
[
'suffix_choices'
]
for
field
in
self
.
__important_fields
:
setattr
(
self
,
'__original_
%
s'
%
field
,
getattr
(
self
,
field
))
def
save
(
self
,
**
kwargs
):
prev_suffix_list
=
[]
super
(
Suffix
,
self
)
.
save
(
**
kwargs
)
for
field
in
self
.
__important_fields
:
orig
=
'__original_
%
s'
%
field
previous_suffix
=
getattr
(
self
,
orig
)
prev_suffix_list
.
append
(
previous_suffix
)
'''Create [S1 - S6]'''
create_s1
(
self
,
self
.
suffix_choices
,
prev_suffix_list
[
0
])
create_s2
(
self
,
self
.
suffix_choices
,
prev_suffix_list
[
0
])
create_s3
(
self
,
self
.
suffix_choices
,
prev_suffix_list
[
0
])
create_s4
(
self
,
self
.
suffix_choices
,
prev_suffix_list
[
0
])
create_s5
(
self
,
self
.
suffix_choices
,
prev_suffix_list
[
0
])
create_s6
(
self
,
self
.
suffix_choices
,
prev_suffix_list
[
0
])
class
Meta
:
ordering
=
[
'boilerplate_of_suffix'
]
class
Suffix_S1
(
models
.
Model
):
boilerplate_of_s1
=
models
.
ForeignKey
(
'reqtool.Boilerplate'
,
related_name
=
'suffix_boilerplate_of_S1'
,
on_delete
=
models
.
CASCADE
)
suffix_owner_of_s1
=
models
.
ForeignKey
(
Suffix
,
related_name
=
'suffix_owner_of_S1'
,
on_delete
=
models
.
CASCADE
)
numerical_affirmative_s1
=
models
.
CharField
(
choices
=
NUMERICAL_AFFIRMATIVE_CHOICES
,
max_length
=
100
)
numerical_s1
=
models
.
IntegerField
(
default
=
0
,
blank
=
True
)
mumerical_units_s1
=
models
.
CharField
(
choices
=
NUMBER_UNITS_CHOICES
,
max_length
=
100
)
time_units_s1
=
models
.
CharField
(
choices
=
TIME_UNITS_CHOICES
,
max_length
=
100
)
class
Meta
:
ordering
=
[
'boilerplate_of_s1'
]
class
Suffix_S2
(
models
.
Model
):
boilerplate_of_s2
=
models
.
ForeignKey
(
'reqtool.Boilerplate'
,
related_name
=
'suffix_boilerplate_of_S2'
,
on_delete
=
models
.
CASCADE
)
suffix_owner_of_s2
=
models
.
ForeignKey
(
Suffix
,
related_name
=
'suffix_owner_of_S2'
,
on_delete
=
models
.
CASCADE
)
s2_s2
=
models
.
CharField
(
choices
=
S2_CHOICES
,
max_length
=
100
)
flow_s2
=
models
.
CharField
(
choices
=
FLOW_CHOICES
,
max_length
=
100
)
class
Meta
:
ordering
=
[
'boilerplate_of_s2'
]
class
Suffix_S3
(
models
.
Model
):
boilerplate_of_s3
=
models
.
ForeignKey
(
'reqtool.Boilerplate'
,
related_name
=
'suffix_boilerplate_of_S3'
,
on_delete
=
models
.
CASCADE
)
suffix_owner_of_s3
=
models
.
ForeignKey
(
Suffix
,
related_name
=
'suffix_owner_of_S3'
,
on_delete
=
models
.
CASCADE
)
s3_s3
=
models
.
CharField
(
choices
=
S3_CHOICES
,
max_length
=
100
)
numerical_s3
=
models
.
IntegerField
(
default
=
0
,
blank
=
True
)
time_units_s3
=
models
.
CharField
(
choices
=
TIME_UNITS_CHOICES
,
max_length
=
100
)
flow_s3
=
models
.
CharField
(
choices
=
FLOW_CHOICES
,
max_length
=
100
)
class
Meta
:
ordering
=
[
'boilerplate_of_s3'
]
class
Suffix_S4
(
models
.
Model
):
boilerplate_of_s4
=
models
.
ForeignKey
(
'reqtool.Boilerplate'
,
related_name
=
'suffix_boilerplate_of_S4'
,
on_delete
=
models
.
CASCADE
)
suffix_owner_of_s4
=
models
.
ForeignKey
(
Suffix
,
related_name
=
'suffix_owner_of_S4'
,
on_delete
=
models
.
CASCADE
)
s4_s4
=
models
.
CharField
(
choices
=
S4_CHOICES
,
max_length
=
100
)
class
Meta
:
ordering
=
[
'boilerplate_of_s4'
]
class
Suffix_S5
(
models
.
Model
):
boilerplate_of_s5
=
models
.
ForeignKey
(
'reqtool.Boilerplate'
,
related_name
=
'suffix_boilerplate_of_S5'
,
on_delete
=
models
.
CASCADE
)
suffix_owner_of_s5
=
models
.
ForeignKey
(
Suffix
,
related_name
=
'suffix_owner_of_S5'
,
on_delete
=
models
.
CASCADE
)
s5_s5
=
models
.
CharField
(
choices
=
S5_CHOICES
,
max_length
=
100
)
class
Meta
:
ordering
=
[
'boilerplate_of_s5'
]
class
Suffix_S6
(
models
.
Model
):
boilerplate_of_s6
=
models
.
ForeignKey
(
'reqtool.Boilerplate'
,
related_name
=
'suffix_boilerplate_of_S6'
,
on_delete
=
models
.
CASCADE
)
suffix_owner_of_s6
=
models
.
ForeignKey
(
Suffix
,
related_name
=
'suffix_owner_of_S6'
,
on_delete
=
models
.
CASCADE
)
s6_s6
=
models
.
CharField
(
choices
=
S6_CHOICES
,
max_length
=
100
)
class
Meta
:
ordering
=
[
'boilerplate_of_s6'
]
\ No newline at end of file
ordering
=
[
'boilerplate_of_suffix'
]
\ No newline at end of file
reqtool/reqman/api/reqman/apps/reqtool/rest_api/serializers/main_req.py
View file @
76a7602c
from
rest_framework
import
serializers
from
reqman.apps.reqtool.models.main_req
import
Main
,
Main_M1
,
Main_M2
,
Main_M3
,
Main_M4
from
reqman.apps.reqtool.models.main_req
import
Main_M5
,
Main_M6
,
Main_M7
,
Main_M8
from
reqman.apps.reqtool.models.main_req
import
Main_M9
,
Main_M10
,
Main_M11
,
Main_M12
from
reqman.apps.reqtool.models.main_req
import
Main_M13
,
Main_M14
,
Main_M15
,
Main_M16
from
reqman.apps.reqtool.models.main_req
import
Main
class
MainSerializer
(
serializers
.
ModelSerializer
):
boilerplate_of_main
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
prefix_owner_of_main
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
main_owner
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
class
Meta
:
model
=
Main
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'
)
class
Main_M5Serializer
(
serializers
.
ModelSerializer
):
boilerplate_of_m5
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
main_owner_of_m5
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
class
Meta
:
model
=
Main_M5
fields
=
(
'id'
,
'boilerplate_of_m5'
,
'main_owner_of_m5'
,
'sys_fun_m5'
,
'shall_m5'
,
'flow_m5'
)
class
Main_M6Serializer
(
serializers
.
ModelSerializer
):
boilerplate_of_m6
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
main_owner_of_m6
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
class
Meta
:
model
=
Main_M6
fields
=
(
'id'
,
'boilerplate_of_m6'
,
'main_owner_of_m6'
,
'sys_fun_m6'
,
'shall_m6'
,
'flow_m6'
)
class
Main_M7Serializer
(
serializers
.
ModelSerializer
):
boilerplate_of_m7
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
main_owner_of_m7
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
class
Meta
:
model
=
Main_M7
fields
=
(
'id'
,
'boilerplate_of_m7'
,
'main_owner_of_m7'
,
'system_m7'
,
'shall_m7'
,
'function_m7'
)
class
Main_M8Serializer
(
serializers
.
ModelSerializer
):
boilerplate_of_m8
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
main_owner_of_m8
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
class
Meta
:
model
=
Main_M8
fields
=
(
'id'
,
'boilerplate_of_m8'
,
'main_owner_of_m8'
,
'function_1_m8'
,
'shall_m8'
,
'function_2_m8'
)
class
Main_M9Serializer
(
serializers
.
ModelSerializer
):
boilerplate_of_m9
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
main_owner_of_m9
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
class
Meta
:
model
=
Main_M9
fields
=
(
'id'
,
'boilerplate_of_m9'
,
'main_owner_of_m9'
,
'system_1_m9'
,
'shall_m9'
,
'interface_m9'
,
'system_2_m9'
)
class
Main_M10Serializer
(
serializers
.
ModelSerializer
):
boilerplate_of_m10
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
main_owner_of_m10
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
class
Meta
:
model
=
Main_M10
fields
=
(
'id'
,
'boilerplate_of_m10'
,
'main_owner_of_m10'
,
'sys_inter_m10'
,
'shall_m10'
,
'flow_item_m9'
)
class
Main_M11Serializer
(
serializers
.
ModelSerializer
):
boilerplate_of_m11
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
main_owner_of_m11
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
class
Meta
:
model
=
Main_M11
fields
=
(
'id'
,
'boilerplate_of_m11'
,
'main_owner_of_m11'
,
'system_1_m11'
,
'shall_m11'
,
'system_2_m11'
,
'connection_m11'
)
class
Main_M12Serializer
(
serializers
.
ModelSerializer
):
boilerplate_of_m12
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
main_owner_of_m12
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
class
Meta
:
model
=
Main_M12
fields
=
(
'id'
,
'boilerplate_of_m12'
,
'main_owner_of_m12'
,
'system_m12'
,
'shall_m12'
,
'state_m12'
)
class
Main_M13Serializer
(
serializers
.
ModelSerializer
):
boilerplate_of_m13
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
main_owner_of_m13
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
class
Meta
:
model
=
Main_M13
fields
=
(
'id'
,
'boilerplate_of_m13'
,
'main_owner_of_m13'
,
'system_m13'
,
'state_1_m13'
,
'statevalue_m13'
,
'shall_m13'
,
'state_2_m13'
)
class
Main_M14Serializer
(
serializers
.
ModelSerializer
):
boilerplate_of_m14
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
main_owner_of_m14
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
class
Meta
:
model
=
Main_M14
fields
=
(
'id'
,
'boilerplate_of_m14'
,
'main_owner_of_m14'
,
'system_m14'
,
'item_m14'
,
'shall_m14'
)
class
Main_M15Serializer
(
serializers
.
ModelSerializer
):
boilerplate_of_m15
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
main_owner_of_m15
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
class
Meta
:
model
=
Main_M15
fields
=
(
'id'
,
'boilerplate_of_m15'
,
'main_owner_of_m15'
,
'system_m15'
,
'item_1_m15'
,
'shall_m15'
,
'item_2_m15'
)
class
Main_M16Serializer
(
serializers
.
ModelSerializer
):
boilerplate_of_m16
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
main_owner_of_m16
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
class
Meta
:
model
=
Main_M16
fields
=
(
'id'
,
'boilerplate_of_m16'
,
'main_owner_of_m16'
,
'system_1_m16'
,
'shall_m16'
,
'system_2_m16'
)
fields
=
'__all__'
reqtool/reqman/api/reqman/apps/reqtool/rest_api/serializers/requirements.py
View file @
76a7602c
from
rest_framework
import
serializers
from
reqman.apps.reqtool.models.requirements
import
Prefix
,
Boilerplate
,
LogicalExpression
,
OccuringFunctionalityP2
,
StateValueConstraint
,
OccuringFunctionalityForLogicalExpression
,
OccuringFunctionalityP3
from
reqman.apps.reqtool.models.requirements
import
Prefix
,
Boilerplate
class
BoilerplateSerializer
(
serializers
.
ModelSerializer
):
owner
=
serializers
.
ReadOnlyField
(
source
=
'owner.username'
)
...
...
@@ -9,55 +9,8 @@ class BoilerplateSerializer(serializers.ModelSerializer):
class
PrefixSerializer
(
serializers
.
ModelSerializer
):
boilerplate
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
prefix_owner
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
class
Meta
:
model
=
Prefix
fields
=
(
'id'
,
'prefix_owner'
,
'boilerplate'
,
'simple_prefix_1'
,
'logic_connective_1'
,
'simple_prefix_2'
,
'logic_connective_2'
,
'simple_prefix_3'
)
class
LogicalExpressionSerializer
(
serializers
.
ModelSerializer
):
prefix
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
prefix_boilerplate
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
prefix_series
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
class
Meta
:
model
=
LogicalExpression
fields
=
(
'id'
,
'prefix'
,
'prefix_series'
,
'prefix_boilerplate'
,
'logical_expression_1'
,
'logic_connective_1'
,
'logical_expression_2'
,
'logic_connective_2'
,
'logical_expression_3'
)
class
OccuringFunctionalityP2Serializer
(
serializers
.
ModelSerializer
):
prefix_of_occuring_functionality_p2
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
prefix_boilerplate_of_occuring_functionality_p2
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
prefix_series_of_occuring_functionality_p2
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
class
Meta
:
model
=
OccuringFunctionalityP2
fields
=
(
'id'
,
'prefix_of_occuring_functionality_p2'
,
'prefix_boilerplate_of_occuring_functionality_p2'
,
'prefix_series_of_occuring_functionality_p2'
,
'system_for_occuring_functionality_p2'
,
'perform_for_occuring_functionality_p2'
,
'function_for_occuring_functionality_p2'
,
'item_for_occuring_functionality_p2'
,
'flow_for_occuring_functionality_p2'
)
class
OccuringFunctionalityP3Serializer
(
serializers
.
ModelSerializer
):
prefix_of_occuring_functionality_p3
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
prefix_boilerplate_of_occuring_functionality_p3
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
prefix_series_of_occuring_functionality_p3
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
class
Meta
:
model
=
OccuringFunctionalityP3
fields
=
(
'id'
,
'prefix_of_occuring_functionality_p3'
,
'prefix_boilerplate_of_occuring_functionality_p3'
,
'prefix_series_of_occuring_functionality_p3'
,
'system_for_occuring_functionality_p3'
,
'perform_for_occuring_functionality_p3'
,
'function_for_occuring_functionality_p3'
,
'item_for_occuring_functionality_p3'
,
'flow_for_occuring_functionality_p3'
)
class
StateValueConstraintSerializer
(
serializers
.
ModelSerializer
):
prefix_of_logical_expression
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
logical_expression
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
log_expr_series
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
prefixgroup
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
class
Meta
:
model
=
StateValueConstraint
fields
=
(
'id'
,
'prefix_of_logical_expression'
,
'logical_expression'
,
'log_expr_series'
,
'item'
,
'system_state'
,
'state_value'
)
class
OccuringFunctionalityForLogicalExpressionSerializer
(
serializers
.
ModelSerializer
):
prefix_of_occuring_for_logical_expression
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
logical_expression_of_occuring
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
log_expres_series
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
class
Meta
:
model
=
OccuringFunctionalityForLogicalExpression
fields
=
(
'id'
,
'prefix_of_occuring_for_logical_expression'
,
'logical_expression_of_occuring'
,
'log_expres_series'
,
'system_for_logical_expression'
,
'perform_for_logical_expression'
,
'function_for_logical_expression'
,
'item_for_logical_expression'
)
model
=
Prefix
fields
=
'__all__'
reqtool/reqman/api/reqman/apps/reqtool/rest_api/serializers/suffix_req.py
View file @
76a7602c
from
rest_framework
import
serializers
from
reqman.apps.reqtool.models.suffix_req
import
Suffix
,
Suffix_S1
,
Suffix_S2
,
Suffix_S3
,
Suffix_S4
,
Suffix_S5
,
Suffix_S6
from
reqman.apps.reqtool.models.suffix_req
import
Suffix
class
SuffixSerializer
(
serializers
.
ModelSerializer
):
...
...
@@ -7,53 +7,5 @@ class SuffixSerializer(serializers.ModelSerializer):
suffix_owner
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
class
Meta
:
model
=
Suffix
fields
=
(
'id'
,
'boilerplate_of_suffix'
,
'suffix_owner'
,
'suffix_choices'
)
class
Suffix_S1Serializer
(
serializers
.
ModelSerializer
):
boilerplate_of_s1
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
suffix_owner_of_s1
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
class
Meta
:
model
=
Suffix_S1
fields
=
(
'id'
,
'boilerplate_of_s1'
,
'suffix_owner_of_s1'
,
'numerical_affirmative_s1'
,
'numerical_s1'
,
'mumerical_units_s1'
,
'time_units_s1'
)
class
Suffix_S2Serializer
(
serializers
.
ModelSerializer
):
boilerplate_of_s2
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
suffix_owner_of_s2
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
class
Meta
:
model
=
Suffix_S2
fields
=
(
'id'
,
'boilerplate_of_s2'
,
'suffix_owner_of_s2'
,
's2_s2'
,
'flow_s2'
)
class
Suffix_S3Serializer
(
serializers
.
ModelSerializer
):
boilerplate_of_s3
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
suffix_owner_of_s3
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
class
Meta
:
model
=
Suffix_S3
fields
=
(
'id'
,
'boilerplate_of_s3'
,
'suffix_owner_of_s3'
,
's3_s3'
,
'numerical_s3'
,
'time_units_s3'
,
'flow_s3'
)
class
Suffix_S4Serializer
(
serializers
.
ModelSerializer
):
boilerplate_of_s4
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
suffix_owner_of_s4
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
class
Meta
:
model
=
Suffix_S4
fields
=
(
'id'
,
'boilerplate_of_s4'
,
'suffix_owner_of_s4'
,
's4_s4'
)
class
Suffix_S5Serializer
(
serializers
.
ModelSerializer
):
boilerplate_of_s5
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
suffix_owner_of_s5
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
class
Meta
:
model
=
Suffix_S5
fields
=
(
'id'
,
'boilerplate_of_s5'
,
'suffix_owner_of_s5'
,
's5_s5'
)
class
Suffix_S6Serializer
(
serializers
.
ModelSerializer
):
boilerplate_of_s6
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
suffix_owner_of_s6
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
class
Meta
:
model
=
Suffix_S6
fields
=
(
'id'
,
'boilerplate_of_s6'
,
'suffix_owner_of_s6'
,
's6_s6'
)
fields
=
'__all__'
reqtool/reqman/api/reqman/apps/reqtool/rest_api/urls.py
View file @
76a7602c
...
...
@@ -11,94 +11,12 @@ urlpatterns = [
#'''Prefix'''
path
(
'requirements/<int:boilerplate>/prefix/'
,
requirements_views
.
PrefixListAPIView
.
as_view
(),
name
=
'api-prefix-list'
),
path
(
'requirements/<int:boilerplate>/prefix/<int:pk>/'
,
requirements_views
.
PrefixDetailsAPIView
.
as_view
(),
name
=
'api-prefix-details'
),
#'''P1'''
path
(
'requirements/<int:boilerplate>/prefix/<int:prefixs>/p1/'
,
requirements_views
.
LogicalExpressionListAPIView
.
as_view
(),
name
=
'api-log_expr-list'
),
path
(
'requirements/<int:boilerplate>/prefix/<int:prefixs>/p1/<int:pk>/'
,
requirements_views
.
LogicalExpressionDetailsAPIView
.
as_view
(),
name
=
'api-log_expr-details'
),
#'''P2'''
path
(
'requirements/<int:boilerplate>/prefix/<int:prefixs>/p2/'
,
requirements_views
.
OccuringFunctionalityP2ListAPIView
.
as_view
(),
name
=
'api-occur_func-list'
),
path
(
'requirements/<int:boilerplate>/prefix/<int:prefixs>/p2/<int:pk>/'
,
requirements_views
.
OccuringFunctionalityP2DetailsAPIView
.
as_view
(),
name
=
'api-occur_func-details'
),
#'''P3'''
path
(
'requirements/<int:boilerplate>/prefix/<int:prefixs>/p3/'
,
requirements_views
.
OccuringFunctionalityP3ListAPIView
.
as_view
(),
name
=
'api-occur_func_p3-list'
),
path
(
'requirements/<int:boilerplate>/prefix/<int:prefixs>/p3/<int:pk>/'
,
requirements_views
.
OccuringFunctionalityP3DetailsAPIView
.
as_view
(),
name
=
'api-occur_func_p3-details'
),
#'''Logical expression of P1'''
path
(
'requirements/<int:boilerplate>/prefix/<int:prefixs>/p1/<int:log_expr>/constraint/'
,
requirements_views
.
StateValueConstraintListAPIView
.
as_view
(),
name
=
'api-constraint-list'
),
path
(
'requirements/<int:boilerplate>/prefix/<int:prefixs>/p1/<int:log_expr>/constraint/<int:pk>/'
,
requirements_views
.
StateValueConstraintDetailsAPIView
.
as_view
(),
name
=
'api-constraint-details'
),
#'''Occuring functionality of P1'''
path
(
'requirements/<int:boilerplate>/prefix/<int:prefixs>/p1/<int:log_expr>/functionality/'
,
requirements_views
.
OccuringFunctionalityForLogicalExpressionListAPIView
.
as_view
(),
name
=
'api-functionality-for-log-list'
),
path
(
'requirements/<int:boilerplate>/prefix/<int:prefixs>/p1/<int:log_expr>/functionality/<int:pk>/'
,
requirements_views
.
OccuringFunctionalityForLogicalExpressionDetailsAPIView
.
as_view
(),
name
=
'api-functionality-for-log-list'
),
#'''MAIN'''
path
(
'requirements/<int:boilerplate>/main/'
,
main_req_views
.
MainListAPIView
.
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_M1ListAPIView
.
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_M2ListAPIView
.
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_M3ListAPIView
.
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_M4ListAPIView
.
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'
),
#'''M5'''
path
(
'requirements/<int:boilerplate>/main/<int:mains>/m5/'
,
main_req_views
.
Main_M5ListAPIView
.
as_view
(),
name
=
'api-main-m5-list'
),
path
(
'requirements/<int:boilerplate>/main/<int:mains>/m5/<int:pk>/'
,
main_req_views
.
Main_M5DetailsAPIView
.
as_view
(),
name
=
'api-main-m5-details'
),
#'''M6'''
path
(
'requirements/<int:boilerplate>/main/<int:mains>/m6/'
,
main_req_views
.
Main_M6ListAPIView
.
as_view
(),
name
=
'api-main-m6-list'
),
path
(
'requirements/<int:boilerplate>/main/<int:mains>/m6/<int:pk>/'
,
main_req_views
.
Main_M6DetailsAPIView
.
as_view
(),
name
=
'api-main-m6-details'
),
#'''M7'''
path
(
'requirements/<int:boilerplate>/main/<int:mains>/m7/'
,
main_req_views
.
Main_M7ListAPIView
.
as_view
(),
name
=
'api-main-m7-list'
),
path
(
'requirements/<int:boilerplate>/main/<int:mains>/m7/<int:pk>/'
,
main_req_views
.
Main_M7DetailsAPIView
.
as_view
(),
name
=
'api-main-m7-details'
),
#'''M8'''
path
(
'requirements/<int:boilerplate>/main/<int:mains>/m8/'
,
main_req_views
.
Main_M8ListAPIView
.
as_view
(),
name
=
'api-main-m8-list'
),
path
(
'requirements/<int:boilerplate>/main/<int:mains>/m8/<int:pk>/'
,
main_req_views
.
Main_M8DetailsAPIView
.
as_view
(),
name
=
'api-main-m8-details'
),
#'''M9'''
path
(
'requirements/<int:boilerplate>/main/<int:mains>/m9/'
,
main_req_views
.
Main_M9ListAPIView
.
as_view
(),
name
=
'api-main-m9-list'
),
path
(
'requirements/<int:boilerplate>/main/<int:mains>/m9/<int:pk>/'
,
main_req_views
.
Main_M9DetailsAPIView
.
as_view
(),
name
=
'api-main-m9-details'
),
#'''M10'''
path
(
'requirements/<int:boilerplate>/main/<int:mains>/m10/'
,
main_req_views
.
Main_M10ListAPIView
.
as_view
(),
name
=
'api-main-m10-list'
),
path
(
'requirements/<int:boilerplate>/main/<int:mains>/m10/<int:pk>/'
,
main_req_views
.
Main_M10DetailsAPIView
.
as_view
(),
name
=
'api-main-m10-details'
),
#'''M11'''
path
(
'requirements/<int:boilerplate>/main/<int:mains>/m11/'
,
main_req_views
.
Main_M11ListAPIView
.
as_view
(),
name
=
'api-main-m11-list'
),
path
(
'requirements/<int:boilerplate>/main/<int:mains>/m11/<int:pk>/'
,
main_req_views
.
Main_M11DetailsAPIView
.
as_view
(),
name
=
'api-main-m11-details'
),
#'''M12'''
path
(
'requirements/<int:boilerplate>/main/<int:mains>/m12/'
,
main_req_views
.
Main_M12ListAPIView
.
as_view
(),
name
=
'api-main-m12-list'
),
path
(
'requirements/<int:boilerplate>/main/<int:mains>/m12/<int:pk>/'
,
main_req_views
.
Main_M12DetailsAPIView
.
as_view
(),
name
=
'api-main-m12-details'
),
#'''M13'''
path
(
'requirements/<int:boilerplate>/main/<int:mains>/m13/'
,
main_req_views
.
Main_M13ListAPIView
.
as_view
(),
name
=
'api-main-m13-list'
),
path
(
'requirements/<int:boilerplate>/main/<int:mains>/m13/<int:pk>/'
,
main_req_views
.
Main_M13DetailsAPIView
.
as_view
(),
name
=
'api-main-m13-details'
),
#'''M14'''
path
(
'requirements/<int:boilerplate>/main/<int:mains>/m14/'
,
main_req_views
.
Main_M14ListAPIView
.
as_view
(),
name
=
'api-main-m14-list'
),
path
(
'requirements/<int:boilerplate>/main/<int:mains>/m14/<int:pk>/'
,
main_req_views
.
Main_M14DetailsAPIView
.
as_view
(),
name
=
'api-main-m14-details'
),
#'''M15'''
path
(
'requirements/<int:boilerplate>/main/<int:mains>/m15/'
,
main_req_views
.
Main_M15ListAPIView
.
as_view
(),
name
=
'api-main-m15-list'
),
path
(
'requirements/<int:boilerplate>/main/<int:mains>/m15/<int:pk>/'
,
main_req_views
.
Main_M15DetailsAPIView
.
as_view
(),
name
=
'api-main-m15-details'
),
#'''M16'''
path
(
'requirements/<int:boilerplate>/main/<int:mains>/m16/'
,
main_req_views
.
Main_M16ListAPIView
.
as_view
(),
name
=
'api-main-m16-list'
),
path
(
'requirements/<int:boilerplate>/main/<int:mains>/m16/<int:pk>/'
,
main_req_views
.
Main_M16DetailsAPIView
.
as_view
(),
name
=
'api-main-m16-details'
),
#'''SUFFIX'''
path
(
'requirements/<int:boilerplate>/suffix/'
,
suffix_req_views
.
SuffixListAPIView
.
as_view
(),
name
=
'api-suffix-list'
),
path
(
'requirements/<int:boilerplate>/suffix/<int:pk>/'
,
suffix_req_views
.
SuffixDetailsAPIView
.
as_view
(),
name
=
'api-suffix-details'
),
#'''S1'''
path
(
'requirements/<int:boilerplate>/suffix/<int:suffixs>/s1/'
,
suffix_req_views
.
Suffix_S1ListAPIView
.
as_view
(),
name
=
'api-suffix-s1-list'
),
path
(
'requirements/<int:boilerplate>/suffix/<int:suffixs>/s1/<int:pk>/'
,
suffix_req_views
.
Suffix_S1DetailsAPIView
.
as_view
(),
name
=
'api-suffix-s1-details'
),
#'''S2'''
path
(
'requirements/<int:boilerplate>/suffix/<int:suffixs>/s2/'
,
suffix_req_views
.
Suffix_S2ListAPIView
.
as_view
(),
name
=
'api-suffix-s2-list'
),
path
(
'requirements/<int:boilerplate>/suffix/<int:suffixs>/s2/<int:pk>/'
,
suffix_req_views
.
Suffix_S2DetailsAPIView
.
as_view
(),
name
=
'api-suffix-s2-details'
),
#'''S3'''
path
(
'requirements/<int:boilerplate>/suffix/<int:suffixs>/s3/'
,
suffix_req_views
.
Suffix_S3ListAPIView
.
as_view
(),
name
=
'api-suffix-s3-list'
),
path
(
'requirements/<int:boilerplate>/suffix/<int:suffixs>/s3/<int:pk>/'
,
suffix_req_views
.
Suffix_S3DetailsAPIView
.
as_view
(),
name
=
'api-suffix-s3-details'
),
#'''S4'''
path
(
'requirements/<int:boilerplate>/suffix/<int:suffixs>/s4/'
,
suffix_req_views
.
Suffix_S4ListAPIView
.
as_view
(),
name
=
'api-suffix-s4-list'
),
path
(
'requirements/<int:boilerplate>/suffix/<int:suffixs>/s4/<int:pk>/'
,
suffix_req_views
.
Suffix_S4DetailsAPIView
.
as_view
(),
name
=
'api-suffix-s4-details'
),
#'''S5'''
path
(
'requirements/<int:boilerplate>/suffix/<int:suffixs>/s5/'
,
suffix_req_views
.
Suffix_S5ListAPIView
.
as_view
(),
name
=
'api-suffix-s5-list'
),
path
(
'requirements/<int:boilerplate>/suffix/<int:suffixs>/s5/<int:pk>/'
,
suffix_req_views
.
Suffix_S5DetailsAPIView
.
as_view
(),
name
=
'api-suffix-s5-details'
),
#'''S6'''
path
(
'requirements/<int:boilerplate>/suffix/<int:suffixs>/s6/'
,
suffix_req_views
.
Suffix_S6ListAPIView
.
as_view
(),
name
=
'api-suffix-s6-list'
),
path
(
'requirements/<int:boilerplate>/suffix/<int:suffixs>/s6/<int:pk>/'
,
suffix_req_views
.
Suffix_S6DetailsAPIView
.
as_view
(),
name
=
'api-suffix-s6-details'
),
]
\ No newline at end of file
reqtool/reqman/api/reqman/apps/reqtool/rest_api/views/main_req_views.py
View file @
76a7602c
...
...
@@ -5,15 +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
,
Main_M1
,
Main_M2
,
Main_M3
,
Main_M4
from
reqman.apps.reqtool.models.main_req
import
Main_M5
,
Main_M6
,
Main_M7
,
Main_M8
from
reqman.apps.reqtool.models.main_req
import
Main_M9
,
Main_M10
,
Main_M11
,
Main_M12
from
reqman.apps.reqtool.models.main_req
import
Main_M13
,
Main_M14
,
Main_M15
,
Main_M16
from
reqman.apps.reqtool.rest_api.serializers.main_req
import
MainSerializer
,
Main_M1Serializer
,
Main_M2Serializer
,
Main_M3Serializer
,
Main_M4Serializer
from
reqman.apps.reqtool.rest_api.serializers.main_req
import
Main_M5Serializer
,
Main_M6Serializer
,
Main_M7Serializer
,
Main_M8Serializer
from
reqman.apps.reqtool.rest_api.serializers.main_req
import
Main_M9Serializer
,
Main_M10Serializer
,
Main_M11Serializer
,
Main_M12Serializer
from
reqman.apps.reqtool.rest_api.serializers.main_req
import
Main_M13Serializer
,
Main_M14Serializer
,
Main_M15Serializer
,
Main_M16Serializer
from
reqman.apps.reqtool.models.main_req
import
Main
from
reqman.apps.reqtool.rest_api.serializers.main_req
import
MainSerializer
from
reqman.apps.permissions
import
IsOwnerOrReadOnly
from
reqman.apps.reqtool.rest_api.services
import
fuseki
...
...
@@ -68,787 +61,3 @@ class MainDetailsAPIView(RetrieveUpdateDestroyAPIView):
instance
.
delete
()
class
Main_M1ListAPIView
(
ListAPIView
):
"""
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_M2ListAPIView
(
ListAPIView
):
"""
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_M3ListAPIView
(
ListAPIView
):
"""
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_M4ListAPIView
(
ListAPIView
):
"""
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
()
class
Main_M5ListAPIView
(
ListAPIView
):
"""
API view to retrieve list of posts or create new
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Main_M5Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
mn
=
self
.
kwargs
[
'mains'
]
#print(group_pk)
queryset_main
=
Main_M5
.
objects
.
filter
(
boilerplate_of_m5
=
bp
,
main_owner_of_m5
=
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_M5DetailsAPIView
(
RetrieveUpdateDestroyAPIView
):
"""
API view to retrieve, update or delete post
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Main_M5Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
mn
=
self
.
kwargs
[
'mains'
]
#print(group_pk)
queryset_main
=
Main_M5
.
objects
.
filter
(
boilerplate_of_m5
=
bp
,
main_owner_of_m5
=
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_M6ListAPIView
(
ListAPIView
):
"""
API view to retrieve list of posts or create new
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Main_M6Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
mn
=
self
.
kwargs
[
'mains'
]
#print(group_pk)
queryset_main
=
Main_M6
.
objects
.
filter
(
boilerplate_of_m6
=
bp
,
main_owner_of_m6
=
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_M6DetailsAPIView
(
RetrieveUpdateDestroyAPIView
):
"""
API view to retrieve, update or delete post
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Main_M6Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
mn
=
self
.
kwargs
[
'mains'
]
#print(group_pk)
queryset_main
=
Main_M6
.
objects
.
filter
(
boilerplate_of_m6
=
bp
,
main_owner_of_m6
=
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_M7ListAPIView
(
ListAPIView
):
"""
API view to retrieve list of posts or create new
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Main_M7Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
mn
=
self
.
kwargs
[
'mains'
]
#print(group_pk)
queryset_main
=
Main_M7
.
objects
.
filter
(
boilerplate_of_m7
=
bp
,
main_owner_of_m7
=
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_M7DetailsAPIView
(
RetrieveUpdateDestroyAPIView
):
"""
API view to retrieve, update or delete post
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Main_M7Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
mn
=
self
.
kwargs
[
'mains'
]
#print(group_pk)
queryset_main
=
Main_M7
.
objects
.
filter
(
boilerplate_of_m7
=
bp
,
main_owner_of_m7
=
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_M8ListAPIView
(
ListAPIView
):
"""
API view to retrieve list of posts or create new
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Main_M8Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
mn
=
self
.
kwargs
[
'mains'
]
#print(group_pk)
queryset_main
=
Main_M8
.
objects
.
filter
(
boilerplate_of_m8
=
bp
,
main_owner_of_m8
=
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_M8DetailsAPIView
(
RetrieveUpdateDestroyAPIView
):
"""
API view to retrieve, update or delete post
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Main_M8Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
mn
=
self
.
kwargs
[
'mains'
]
#print(group_pk)
queryset_main
=
Main_M8
.
objects
.
filter
(
boilerplate_of_m8
=
bp
,
main_owner_of_m8
=
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_M9ListAPIView
(
ListAPIView
):
"""
API view to retrieve list of posts or create new
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Main_M9Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
mn
=
self
.
kwargs
[
'mains'
]
#print(group_pk)
queryset_main
=
Main_M9
.
objects
.
filter
(
boilerplate_of_m9
=
bp
,
main_owner_of_m9
=
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_M9DetailsAPIView
(
RetrieveUpdateDestroyAPIView
):
"""
API view to retrieve, update or delete post
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Main_M9Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
mn
=
self
.
kwargs
[
'mains'
]
#print(group_pk)
queryset_main
=
Main_M9
.
objects
.
filter
(
boilerplate_of_m9
=
bp
,
main_owner_of_m9
=
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_M10ListAPIView
(
ListAPIView
):
"""
API view to retrieve list of posts or create new
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Main_M10Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
mn
=
self
.
kwargs
[
'mains'
]
#print(group_pk)
queryset_main
=
Main_M10
.
objects
.
filter
(
boilerplate_of_m10
=
bp
,
main_owner_of_m10
=
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_M10DetailsAPIView
(
RetrieveUpdateDestroyAPIView
):
"""
API view to retrieve, update or delete post
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Main_M10Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
mn
=
self
.
kwargs
[
'mains'
]
#print(group_pk)
queryset_main
=
Main_M10
.
objects
.
filter
(
boilerplate_of_m10
=
bp
,
main_owner_of_m10
=
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_M11ListAPIView
(
ListAPIView
):
"""
API view to retrieve list of posts or create new
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Main_M11Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
mn
=
self
.
kwargs
[
'mains'
]
#print(group_pk)
queryset_main
=
Main_M11
.
objects
.
filter
(
boilerplate_of_m11
=
bp
,
main_owner_of_m11
=
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_M11DetailsAPIView
(
RetrieveUpdateDestroyAPIView
):
"""
API view to retrieve, update or delete post
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Main_M11Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
mn
=
self
.
kwargs
[
'mains'
]
#print(group_pk)
queryset_main
=
Main_M11
.
objects
.
filter
(
boilerplate_of_m11
=
bp
,
main_owner_of_m11
=
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_M12ListAPIView
(
ListAPIView
):
"""
API view to retrieve list of posts or create new
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Main_M12Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
mn
=
self
.
kwargs
[
'mains'
]
#print(group_pk)
queryset_main
=
Main_M12
.
objects
.
filter
(
boilerplate_of_m12
=
bp
,
main_owner_of_m12
=
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_M12DetailsAPIView
(
RetrieveUpdateDestroyAPIView
):
"""
API view to retrieve, update or delete post
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Main_M12Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
mn
=
self
.
kwargs
[
'mains'
]
#print(group_pk)
queryset_main
=
Main_M12
.
objects
.
filter
(
boilerplate_of_m12
=
bp
,
main_owner_of_m12
=
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_M13ListAPIView
(
ListAPIView
):
"""
API view to retrieve list of posts or create new
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Main_M13Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
mn
=
self
.
kwargs
[
'mains'
]
#print(group_pk)
queryset_main
=
Main_M13
.
objects
.
filter
(
boilerplate_of_m13
=
bp
,
main_owner_of_m13
=
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_M13DetailsAPIView
(
RetrieveUpdateDestroyAPIView
):
"""
API view to retrieve, update or delete post
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Main_M13Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
mn
=
self
.
kwargs
[
'mains'
]
#print(group_pk)
queryset_main
=
Main_M13
.
objects
.
filter
(
boilerplate_of_m13
=
bp
,
main_owner_of_m13
=
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_M14ListAPIView
(
ListAPIView
):
"""
API view to retrieve list of posts or create new
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Main_M14Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
mn
=
self
.
kwargs
[
'mains'
]
#print(group_pk)
queryset_main
=
Main_M14
.
objects
.
filter
(
boilerplate_of_m14
=
bp
,
main_owner_of_m14
=
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_M14DetailsAPIView
(
RetrieveUpdateDestroyAPIView
):
"""
API view to retrieve, update or delete post
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Main_M14Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
mn
=
self
.
kwargs
[
'mains'
]
#print(group_pk)
queryset_main
=
Main_M14
.
objects
.
filter
(
boilerplate_of_m14
=
bp
,
main_owner_of_m14
=
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_M15ListAPIView
(
ListAPIView
):
"""
API view to retrieve list of posts or create new
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Main_M15Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
mn
=
self
.
kwargs
[
'mains'
]
#print(group_pk)
queryset_main
=
Main_M15
.
objects
.
filter
(
boilerplate_of_m15
=
bp
,
main_owner_of_m15
=
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_M15DetailsAPIView
(
RetrieveUpdateDestroyAPIView
):
"""
API view to retrieve, update or delete post
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Main_M15Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
mn
=
self
.
kwargs
[
'mains'
]
#print(group_pk)
queryset_main
=
Main_M15
.
objects
.
filter
(
boilerplate_of_m15
=
bp
,
main_owner_of_m15
=
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_M16ListAPIView
(
ListAPIView
):
"""
API view to retrieve list of posts or create new
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Main_M16Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
mn
=
self
.
kwargs
[
'mains'
]
#print(group_pk)
queryset_main
=
Main_M16
.
objects
.
filter
(
boilerplate_of_m16
=
bp
,
main_owner_of_m16
=
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_M16DetailsAPIView
(
RetrieveUpdateDestroyAPIView
):
"""
API view to retrieve, update or delete post
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Main_M16Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
mn
=
self
.
kwargs
[
'mains'
]
#print(group_pk)
queryset_main
=
Main_M16
.
objects
.
filter
(
boilerplate_of_m16
=
bp
,
main_owner_of_m16
=
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
()
reqtool/reqman/api/reqman/apps/reqtool/rest_api/views/requirements_views.py
View file @
76a7602c
...
...
@@ -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.requirements
import
Prefix
,
Boilerplate
,
LogicalExpression
,
OccuringFunctionalityP2
,
OccuringFunctionalityP3
,
StateValueConstraint
,
OccuringFunctionalityForLogicalExpression
from
reqman.apps.reqtool.rest_api.serializers.requirements
import
PrefixSerializer
,
BoilerplateSerializer
,
LogicalExpressionSerializer
,
OccuringFunctionalityP2Serializer
,
OccuringFunctionalityP3Serializer
,
StateValueConstraintSerializer
,
OccuringFunctionalityForLogicalExpressionSerializer
from
reqman.apps.reqtool.models.requirements
import
Prefix
,
Boilerplate
from
reqman.apps.reqtool.rest_api.serializers.requirements
import
PrefixSerializer
,
BoilerplateSerializer
from
reqman.apps.permissions
import
IsOwnerOrReadOnly
from
reqman.apps.reqtool.rest_api.services
import
fuseki
...
...
@@ -64,7 +64,7 @@ class PrefixListAPIView(ListAPIView):
def
get_queryset
(
self
):
group_pk
=
self
.
kwargs
[
'boilerplate'
]
#print(group_pk)
queryset_prefix
=
Prefix
.
objects
.
filter
(
boilerplate
=
group_pk
)
queryset_prefix
=
Prefix
.
objects
.
filter
(
prefix_
boilerplate
=
group_pk
)
return
queryset_prefix
#Custom actions when POST
...
...
@@ -85,8 +85,7 @@ class PrefixDetailsAPIView(RetrieveUpdateDestroyAPIView):
def
get_queryset
(
self
):
group_pk
=
self
.
kwargs
[
'boilerplate'
]
#print(group_pk)
queryset_prefix
=
Prefix
.
objects
.
filter
(
boilerplate
=
group_pk
)
queryset_prefix
=
Prefix
.
objects
.
filter
(
prefix_boilerplate
=
group_pk
)
return
queryset_prefix
#Custom actions when PUT
...
...
@@ -102,215 +101,3 @@ class PrefixDetailsAPIView(RetrieveUpdateDestroyAPIView):
#print("deleted")
instance
.
delete
()
class
LogicalExpressionListAPIView
(
ListAPIView
):
"""
API view to retrieve list of posts or create new
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
LogicalExpressionSerializer
#queryset = LogicalExpression.objects.all()
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
pr
=
self
.
kwargs
[
'prefixs'
]
queryset_prefix
=
LogicalExpression
.
objects
.
filter
(
prefix_boilerplate
=
bp
,
prefix
=
pr
)
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
LogicalExpressionDetailsAPIView
(
RetrieveUpdateDestroyAPIView
):
"""
API view to retrieve, update or delete post
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
LogicalExpressionSerializer
queryset
=
LogicalExpression
.
objects
.
all
()
#Custom actions when PUT
def
perform_update
(
self
,
serializer
):
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
OccuringFunctionalityP2ListAPIView
(
ListAPIView
):
"""
API view to retrieve list of posts or create new
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
OccuringFunctionalityP2Serializer
#queryset = LogicalExpression.objects.all()
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
pr
=
self
.
kwargs
[
'prefixs'
]
queryset_prefix
=
OccuringFunctionalityP2
.
objects
.
filter
(
prefix_boilerplate_of_occuring_functionality_p2
=
bp
,
prefix_of_occuring_functionality_p2
=
pr
)
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
OccuringFunctionalityP2DetailsAPIView
(
RetrieveUpdateDestroyAPIView
):
"""
API view to retrieve, update or delete post
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
OccuringFunctionalityP2Serializer
queryset
=
OccuringFunctionalityP2
.
objects
.
all
()
#Custom actions when PUT
def
perform_update
(
self
,
serializer
):
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
OccuringFunctionalityP3ListAPIView
(
ListAPIView
):
"""
API view to retrieve list of posts or create new
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
OccuringFunctionalityP3Serializer
#queryset = LogicalExpression.objects.all()
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
pr
=
self
.
kwargs
[
'prefixs'
]
queryset_prefix
=
OccuringFunctionalityP3
.
objects
.
filter
(
prefix_boilerplate_of_occuring_functionality_p3
=
bp
,
prefix_of_occuring_functionality_p3
=
pr
)
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
OccuringFunctionalityP3DetailsAPIView
(
RetrieveUpdateDestroyAPIView
):
"""
API view to retrieve, update or delete post
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
OccuringFunctionalityP3Serializer
queryset
=
OccuringFunctionalityP3
.
objects
.
all
()
#Custom actions when PUT
def
perform_update
(
self
,
serializer
):
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
StateValueConstraintListAPIView
(
ListAPIView
):
"""
API view to retrieve list of posts or create new
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
StateValueConstraintSerializer
#queryset = StateValueConstraint.objects.all()
def
get_queryset
(
self
):
le
=
self
.
kwargs
[
'log_expr'
]
pr
=
self
.
kwargs
[
'prefixs'
]
queryset_prefix
=
StateValueConstraint
.
objects
.
filter
(
logical_expression
=
le
,
prefix_of_logical_expression
=
pr
)
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
StateValueConstraintDetailsAPIView
(
RetrieveUpdateDestroyAPIView
):
"""
API view to retrieve, update or delete post
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
StateValueConstraintSerializer
queryset
=
StateValueConstraint
.
objects
.
all
()
#Custom actions when PUT
def
perform_update
(
self
,
serializer
):
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
OccuringFunctionalityForLogicalExpressionListAPIView
(
ListAPIView
):
"""
API view to retrieve list of posts or create new
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
OccuringFunctionalityForLogicalExpressionSerializer
#queryset = StateValueConstraint.objects.all()
def
get_queryset
(
self
):
le
=
self
.
kwargs
[
'log_expr'
]
pr
=
self
.
kwargs
[
'prefixs'
]
queryset_prefix
=
OccuringFunctionalityForLogicalExpression
.
objects
.
filter
(
logical_expression_of_occuring
=
le
,
prefix_of_occuring_for_logical_expression
=
pr
)
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
OccuringFunctionalityForLogicalExpressionDetailsAPIView
(
RetrieveUpdateDestroyAPIView
):
"""
API view to retrieve, update or delete post
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
OccuringFunctionalityForLogicalExpressionSerializer
queryset
=
OccuringFunctionalityForLogicalExpression
.
objects
.
all
()
#Custom actions when PUT
def
perform_update
(
self
,
serializer
):
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
()
\ No newline at end of file
reqtool/reqman/api/reqman/apps/reqtool/rest_api/views/suffix_req_views.py
View file @
76a7602c
...
...
@@ -5,9 +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.suffix_req
import
Suffix
,
Suffix_S1
,
Suffix_S2
,
Suffix_S3
,
Suffix_S4
,
Suffix_S5
,
Suffix_S6
from
reqman.apps.reqtool.rest_api.serializers.suffix_req
import
SuffixSerializer
,
Suffix_S1Serializer
,
Suffix_S2Serializer
,
Suffix_S3Serializer
,
Suffix_S4Serializer
,
Suffix_S5Serializer
,
Suffix_S6Serializer
from
reqman.apps.reqtool.models.suffix_req
import
Suffix
from
reqman.apps.reqtool.rest_api.serializers.suffix_req
import
SuffixSerializer
from
reqman.apps.permissions
import
IsOwnerOrReadOnly
from
reqman.apps.reqtool.rest_api.services
import
fuseki
...
...
@@ -62,297 +61,4 @@ class SuffixDetailsAPIView(RetrieveUpdateDestroyAPIView):
instance
.
delete
()
class
Suffix_S1ListAPIView
(
ListAPIView
):
"""
API view to retrieve list of posts or create new
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Suffix_S1Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
sf
=
self
.
kwargs
[
'suffixs'
]
#print(group_pk)
queryset_suffix
=
Suffix_S1
.
objects
.
filter
(
boilerplate_of_s1
=
bp
,
suffix_owner_of_s1
=
sf
)
return
queryset_suffix
#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
Suffix_S1DetailsAPIView
(
RetrieveUpdateDestroyAPIView
):
"""
API view to retrieve, update or delete post
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Suffix_S1Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
sf
=
self
.
kwargs
[
'suffixs'
]
#print(group_pk)
queryset_suffix
=
Suffix_S1
.
objects
.
filter
(
boilerplate_of_s1
=
bp
,
suffix_owner_of_s1
=
sf
)
return
queryset_suffix
#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
Suffix_S2ListAPIView
(
ListAPIView
):
"""
API view to retrieve list of posts or create new
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Suffix_S2Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
sf
=
self
.
kwargs
[
'suffixs'
]
#print(group_pk)
queryset_suffix
=
Suffix_S2
.
objects
.
filter
(
boilerplate_of_s2
=
bp
,
suffix_owner_of_s2
=
sf
)
return
queryset_suffix
#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
Suffix_S2DetailsAPIView
(
RetrieveUpdateDestroyAPIView
):
"""
API view to retrieve, update or delete post
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Suffix_S2Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
sf
=
self
.
kwargs
[
'suffixs'
]
#print(group_pk)
queryset_suffix
=
Suffix_S2
.
objects
.
filter
(
boilerplate_of_s2
=
bp
,
suffix_owner_of_s2
=
sf
)
return
queryset_suffix
#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
Suffix_S3ListAPIView
(
ListAPIView
):
"""
API view to retrieve list of posts or create new
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Suffix_S3Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
sf
=
self
.
kwargs
[
'suffixs'
]
#print(group_pk)
queryset_suffix
=
Suffix_S3
.
objects
.
filter
(
boilerplate_of_s3
=
bp
,
suffix_owner_of_s3
=
sf
)
return
queryset_suffix
#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
Suffix_S3DetailsAPIView
(
RetrieveUpdateDestroyAPIView
):
"""
API view to retrieve, update or delete post
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Suffix_S3Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
sf
=
self
.
kwargs
[
'suffixs'
]
#print(group_pk)
queryset_suffix
=
Suffix_S3
.
objects
.
filter
(
boilerplate_of_s3
=
bp
,
suffix_owner_of_s3
=
sf
)
return
queryset_suffix
#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
Suffix_S4ListAPIView
(
ListAPIView
):
"""
API view to retrieve list of posts or create new
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Suffix_S4Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
sf
=
self
.
kwargs
[
'suffixs'
]
#print(group_pk)
queryset_suffix
=
Suffix_S4
.
objects
.
filter
(
boilerplate_of_s4
=
bp
,
suffix_owner_of_s4
=
sf
)
return
queryset_suffix
#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
Suffix_S4DetailsAPIView
(
RetrieveUpdateDestroyAPIView
):
"""
API view to retrieve, update or delete post
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Suffix_S4Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
sf
=
self
.
kwargs
[
'suffixs'
]
#print(group_pk)
queryset_suffix
=
Suffix_S4
.
objects
.
filter
(
boilerplate_of_s4
=
bp
,
suffix_owner_of_s4
=
sf
)
return
queryset_suffix
#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
Suffix_S5ListAPIView
(
ListAPIView
):
"""
API view to retrieve list of posts or create new
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Suffix_S5Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
sf
=
self
.
kwargs
[
'suffixs'
]
#print(group_pk)
queryset_suffix
=
Suffix_S5
.
objects
.
filter
(
boilerplate_of_s5
=
bp
,
suffix_owner_of_s5
=
sf
)
return
queryset_suffix
#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
Suffix_S5DetailsAPIView
(
RetrieveUpdateDestroyAPIView
):
"""
API view to retrieve, update or delete post
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Suffix_S5Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
sf
=
self
.
kwargs
[
'suffixs'
]
#print(group_pk)
queryset_suffix
=
Suffix_S5
.
objects
.
filter
(
boilerplate_of_s5
=
bp
,
suffix_owner_of_s5
=
sf
)
return
queryset_suffix
#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
Suffix_S6ListAPIView
(
ListAPIView
):
"""
API view to retrieve list of posts or create new
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Suffix_S6Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
sf
=
self
.
kwargs
[
'suffixs'
]
#print(group_pk)
queryset_suffix
=
Suffix_S6
.
objects
.
filter
(
boilerplate_of_s6
=
bp
,
suffix_owner_of_s6
=
sf
)
return
queryset_suffix
#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
Suffix_S6DetailsAPIView
(
RetrieveUpdateDestroyAPIView
):
"""
API view to retrieve, update or delete post
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Suffix_S6Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
sf
=
self
.
kwargs
[
'suffixs'
]
#print(group_pk)
queryset_suffix
=
Suffix_S6
.
objects
.
filter
(
boilerplate_of_s6
=
bp
,
suffix_owner_of_s6
=
sf
)
return
queryset_suffix
#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