Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
Requirement Formalization Tool
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Thodoris Nestoridis
Requirement Formalization Tool
Commits
60f5e7fa
Commit
60f5e7fa
authored
Jan 21, 2021
by
Thodoris Nestoridis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add M1-M4
parent
f44def27
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
402 additions
and
16 deletions
+402
-16
main_req.py
reqtool/reqman/api/reqman/apps/reqtool/models/main_req.py
+151
-10
main_req.py
.../api/reqman/apps/reqtool/rest_api/serializers/main_req.py
+34
-2
urls.py
reqtool/reqman/api/reqman/apps/reqtool/rest_api/urls.py
+13
-1
main_req_views.py
.../api/reqman/apps/reqtool/rest_api/views/main_req_views.py
+204
-3
No files found.
reqtool/reqman/api/reqman/apps/reqtool/models/main_req.py
View file @
60f5e7fa
This diff is collapsed.
Click to expand it.
reqtool/reqman/api/reqman/apps/reqtool/rest_api/serializers/main_req.py
View file @
60f5e7fa
from
rest_framework
import
serializers
from
reqman.apps.reqtool.models.main_req
import
Main
from
reqman.apps.reqtool.models.main_req
import
Main
,
Main_M1
,
Main_M2
,
Main_M3
,
Main_M4
class
MainSerializer
(
serializers
.
ModelSerializer
):
boilerplate_of_main
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
prefix_owner_of_main
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
class
Meta
:
model
=
Main
fields
=
(
'id'
,
'prefix_owner_of_main'
,
'boilerplate_of_main'
,
'main_choices'
)
\ No newline at end of file
fields
=
(
'id'
,
'prefix_owner_of_main'
,
'boilerplate_of_main'
,
'main_choices'
)
class
Main_M1Serializer
(
serializers
.
ModelSerializer
):
boilerplate_of_m1
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
main_owner_of_m1
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
class
Meta
:
model
=
Main_M1
fields
=
(
'id'
,
'boilerplate_of_m1'
,
'main_owner_of_m1'
,
'sys_fun_m1'
,
'shall_m1'
,
'quantifier_m1'
,
'numerical_m1'
,
'mumerical_units_m1'
,
'item_m1'
,
'statevalue_m1'
)
class
Main_M2Serializer
(
serializers
.
ModelSerializer
):
boilerplate_of_m2
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
main_owner_of_m2
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
class
Meta
:
model
=
Main_M2
fields
=
(
'id'
,
'boilerplate_of_m2'
,
'main_owner_of_m2'
,
'sys_fun_m2'
,
'shall_m2'
,
'state_m2'
,
'statevalue_m2'
)
class
Main_M3Serializer
(
serializers
.
ModelSerializer
):
boilerplate_of_m3
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
main_owner_of_m3
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
class
Meta
:
model
=
Main_M3
fields
=
(
'id'
,
'boilerplate_of_m3'
,
'main_owner_of_m3'
,
'sys_fun_m3'
,
'shall_m3'
,
'quantifier_m3'
,
'numerical_m3'
,
'mumerical_units_m3'
,
'item_m3'
)
class
Main_M4Serializer
(
serializers
.
ModelSerializer
):
boilerplate_of_m4
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
main_owner_of_m4
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
class
Meta
:
model
=
Main_M4
fields
=
(
'id'
,
'boilerplate_of_m4'
,
'main_owner_of_m4'
,
'sys_fun_m4'
,
'shall_m4'
,
'quantifier_m4'
,
'numerical_m4'
,
'mumerical_units_m4'
,
'item_m4'
)
\ No newline at end of file
reqtool/reqman/api/reqman/apps/reqtool/rest_api/urls.py
View file @
60f5e7fa
...
...
@@ -30,5 +30,17 @@ urlpatterns = [
#'''MAIN'''
path
(
'requirements/<int:boilerplate>/main/'
,
main_req_views
.
MainListCreateAPIView
.
as_view
(),
name
=
'api-main-list'
),
path
(
'requirements/<int:boilerplate>/main/<int:pk>/'
,
main_req_views
.
MainDetailsAPIView
.
as_view
(),
name
=
'api-main-details'
),
#'''M1'''
path
(
'requirements/<int:boilerplate>/main/<int:mains>/m1'
,
main_req_views
.
Main_M1ListCreateAPIView
.
as_view
(),
name
=
'api-main-m1-list'
),
path
(
'requirements/<int:boilerplate>/main/<int:mains>/m1/<int:pk>/'
,
main_req_views
.
Main_M1DetailsAPIView
.
as_view
(),
name
=
'api-main-m1-details'
),
#'''M2'''
path
(
'requirements/<int:boilerplate>/main/<int:mains>/m2'
,
main_req_views
.
Main_M2ListCreateAPIView
.
as_view
(),
name
=
'api-main-m2-list'
),
path
(
'requirements/<int:boilerplate>/main/<int:mains>/m2/<int:pk>/'
,
main_req_views
.
Main_M2DetailsAPIView
.
as_view
(),
name
=
'api-main-m2-details'
),
#'''M3'''
path
(
'requirements/<int:boilerplate>/main/<int:mains>/m3'
,
main_req_views
.
Main_M3ListCreateAPIView
.
as_view
(),
name
=
'api-main-m3-list'
),
path
(
'requirements/<int:boilerplate>/main/<int:mains>/m3/<int:pk>/'
,
main_req_views
.
Main_M3DetailsAPIView
.
as_view
(),
name
=
'api-main-m3-details'
),
#'''M4'''
path
(
'requirements/<int:boilerplate>/main/<int:mains>/m4'
,
main_req_views
.
Main_M4ListCreateAPIView
.
as_view
(),
name
=
'api-main-m4-list'
),
path
(
'requirements/<int:boilerplate>/main/<int:mains>/m4/<int:pk>/'
,
main_req_views
.
Main_M4DetailsAPIView
.
as_view
(),
name
=
'api-main-m4-details'
),
]
\ No newline at end of file
reqtool/reqman/api/reqman/apps/reqtool/rest_api/views/main_req_views.py
View file @
60f5e7fa
...
...
@@ -5,8 +5,8 @@ from django.http import HttpResponse, JsonResponse
from
django.views.decorators.csrf
import
csrf_exempt
from
rest_framework.parsers
import
JSONParser
from
reqman.apps.reqtool.models.main_req
import
Main
from
reqman.apps.reqtool.rest_api.serializers.main_req
import
MainSerializer
from
reqman.apps.reqtool.models.main_req
import
Main
,
Main_M1
,
Main_M2
,
Main_M3
,
Main_M4
from
reqman.apps.reqtool.rest_api.serializers.main_req
import
MainSerializer
,
Main_M1Serializer
,
Main_M2Serializer
,
Main_M3Serializer
,
Main_M4Serializer
from
reqman.apps.permissions
import
IsOwnerOrReadOnly
from
reqman.apps.reqtool.rest_api.services
import
fuseki
...
...
@@ -57,4 +57,205 @@ class MainDetailsAPIView(RetrieveUpdateDestroyAPIView):
#Custom actions when DELETE
def
perform_destroy
(
self
,
instance
):
#print("deleted")
instance
.
delete
()
\ No newline at end of file
instance
.
delete
()
class
Main_M1ListCreateAPIView
(
ListCreateAPIView
):
"""
API view to retrieve list of posts or create new
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Main_M1Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
mn
=
self
.
kwargs
[
'mains'
]
#print(group_pk)
queryset_main
=
Main_M1
.
objects
.
filter
(
boilerplate_of_m1
=
bp
,
main_owner_of_m1
=
mn
)
return
queryset_main
#Custom actions when POST
def
perform_create
(
self
,
serializer
):
serializer
.
save
()
#print the data of the post
#write_fuseki = fuseki.FusekiActions()
#write_fuseki.write(serializer.data)
class
Main_M1DetailsAPIView
(
RetrieveUpdateDestroyAPIView
):
"""
API view to retrieve, update or delete post
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Main_M1Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
mn
=
self
.
kwargs
[
'mains'
]
#print(group_pk)
queryset_main
=
Main_M1
.
objects
.
filter
(
boilerplate_of_m1
=
bp
,
main_owner_of_m1
=
mn
)
return
queryset_main
#Custom actions when PUT
def
perform_update
(
self
,
serializer
):
serializer
.
save
()
#print(self.new.changed_data)
#instance = serializer.save()
#write_fuseki = fuseki.FusekiActions()
#write_fuseki.write(serializer.data)
#Custom actions when DELETE
def
perform_destroy
(
self
,
instance
):
#print("deleted")
instance
.
delete
()
class
Main_M2ListCreateAPIView
(
ListCreateAPIView
):
"""
API view to retrieve list of posts or create new
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Main_M2Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
mn
=
self
.
kwargs
[
'mains'
]
#print(group_pk)
queryset_main
=
Main_M2
.
objects
.
filter
(
boilerplate_of_m2
=
bp
,
main_owner_of_m2
=
mn
)
return
queryset_main
#Custom actions when POST
def
perform_create
(
self
,
serializer
):
serializer
.
save
()
#print the data of the post
#write_fuseki = fuseki.FusekiActions()
#write_fuseki.write(serializer.data)
class
Main_M2DetailsAPIView
(
RetrieveUpdateDestroyAPIView
):
"""
API view to retrieve, update or delete post
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Main_M2Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
mn
=
self
.
kwargs
[
'mains'
]
#print(group_pk)
queryset_main
=
Main_M2
.
objects
.
filter
(
boilerplate_of_m2
=
bp
,
main_owner_of_m2
=
mn
)
return
queryset_main
#Custom actions when PUT
def
perform_update
(
self
,
serializer
):
serializer
.
save
()
#print(self.new.changed_data)
#instance = serializer.save()
#write_fuseki = fuseki.FusekiActions()
#write_fuseki.write(serializer.data)
#Custom actions when DELETE
def
perform_destroy
(
self
,
instance
):
#print("deleted")
instance
.
delete
()
class
Main_M3ListCreateAPIView
(
ListCreateAPIView
):
"""
API view to retrieve list of posts or create new
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Main_M3Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
mn
=
self
.
kwargs
[
'mains'
]
#print(group_pk)
queryset_main
=
Main_M3
.
objects
.
filter
(
boilerplate_of_m3
=
bp
,
main_owner_of_m3
=
mn
)
return
queryset_main
#Custom actions when POST
def
perform_create
(
self
,
serializer
):
serializer
.
save
()
#print the data of the post
#write_fuseki = fuseki.FusekiActions()
#write_fuseki.write(serializer.data)
class
Main_M3DetailsAPIView
(
RetrieveUpdateDestroyAPIView
):
"""
API view to retrieve, update or delete post
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Main_M3Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
mn
=
self
.
kwargs
[
'mains'
]
#print(group_pk)
queryset_main
=
Main_M3
.
objects
.
filter
(
boilerplate_of_m3
=
bp
,
main_owner_of_m3
=
mn
)
return
queryset_main
#Custom actions when PUT
def
perform_update
(
self
,
serializer
):
serializer
.
save
()
#print(self.new.changed_data)
#instance = serializer.save()
#write_fuseki = fuseki.FusekiActions()
#write_fuseki.write(serializer.data)
#Custom actions when DELETE
def
perform_destroy
(
self
,
instance
):
#print("deleted")
instance
.
delete
()
class
Main_M4ListCreateAPIView
(
ListCreateAPIView
):
"""
API view to retrieve list of posts or create new
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Main_M4Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
mn
=
self
.
kwargs
[
'mains'
]
#print(group_pk)
queryset_main
=
Main_M4
.
objects
.
filter
(
boilerplate_of_m4
=
bp
,
main_owner_of_m4
=
mn
)
return
queryset_main
#Custom actions when POST
def
perform_create
(
self
,
serializer
):
serializer
.
save
()
#print the data of the post
#write_fuseki = fuseki.FusekiActions()
#write_fuseki.write(serializer.data)
class
Main_M4DetailsAPIView
(
RetrieveUpdateDestroyAPIView
):
"""
API view to retrieve, update or delete post
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
Main_M4Serializer
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
mn
=
self
.
kwargs
[
'mains'
]
#print(group_pk)
queryset_main
=
Main_M4
.
objects
.
filter
(
boilerplate_of_m4
=
bp
,
main_owner_of_m4
=
mn
)
return
queryset_main
#Custom actions when PUT
def
perform_update
(
self
,
serializer
):
serializer
.
save
()
#print(self.new.changed_data)
#instance = serializer.save()
#write_fuseki = fuseki.FusekiActions()
#write_fuseki.write(serializer.data)
#Custom actions when DELETE
def
perform_destroy
(
self
,
instance
):
#print("deleted")
instance
.
delete
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment