Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2020-101
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2020-101
2020-101
Commits
1f4bcb59
Commit
1f4bcb59
authored
Jul 12, 2020
by
LiniEisha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
API
parent
735cd214
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
80 additions
and
5 deletions
+80
-5
LectureSummarizingBackend/ApiBasic/models.py
LectureSummarizingBackend/ApiBasic/models.py
+3
-4
LectureSummarizingBackend/ApiBasic/serializers.py
LectureSummarizingBackend/ApiBasic/serializers.py
+23
-0
LectureSummarizingBackend/ApiBasic/urls.py
LectureSummarizingBackend/ApiBasic/urls.py
+8
-0
LectureSummarizingBackend/ApiBasic/views.py
LectureSummarizingBackend/ApiBasic/views.py
+44
-0
LectureSummarizingBackend/LectureSummarizingBackend/urls.py
LectureSummarizingBackend/LectureSummarizingBackend/urls.py
+2
-1
LectureSummarizingBackend/db.sqlite3
LectureSummarizingBackend/db.sqlite3
+0
-0
No files found.
LectureSummarizingBackend/ApiBasic/models.py
View file @
1f4bcb59
...
@@ -5,11 +5,10 @@ from django.db import models
...
@@ -5,11 +5,10 @@ from django.db import models
class
Lecture
(
models
.
Model
):
class
Lecture
(
models
.
Model
):
lectureid
=
models
.
CharField
(
max_length
=
50
)
lectureid
=
models
.
CharField
(
max_length
=
50
)
topic
=
models
.
CharField
(
max_length
=
100
)
topic
=
models
.
CharField
(
max_length
=
100
)
date
=
models
.
DateTime
Field
(
max_length
=
50
)
date
=
models
.
Char
Field
(
max_length
=
50
)
duration
=
models
.
CharField
(
max_length
=
100
)
duration
=
models
.
CharField
(
max_length
=
100
)
lecture
=
models
.
CharField
(
max_length
=
1000
)
recording
=
models
.
CharField
(
max_length
=
10000
)
recording
=
models
.
CharField
(
max_length
=
100
)
summary
=
models
.
CharField
(
max_length
=
10000
)
summary
=
models
.
CharField
(
max_length
=
1000
)
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
lectureid
return
self
.
lectureid
\ No newline at end of file
LectureSummarizingBackend/ApiBasic/serializers.py
0 → 100644
View file @
1f4bcb59
from
rest_framework
import
serializers
from
.models
import
Lecture
class
LectureSerializer
(
serializers
.
Serializer
):
lectureid
=
serializers
.
CharField
(
max_length
=
50
)
topic
=
serializers
.
CharField
(
max_length
=
100
)
date
=
serializers
.
CharField
(
max_length
=
50
)
duration
=
serializers
.
CharField
(
max_length
=
100
)
recording
=
serializers
.
CharField
(
max_length
=
10000
)
summary
=
serializers
.
CharField
(
max_length
=
10000
)
def
create
(
self
,
validated_data
):
return
Lecture
.
objects
.
create
(
validated_data
)
def
update
(
self
,
instance
,
validated_data
):
instance
.
lectureid
=
validated_data
.
get
(
'lectureid'
,
instance
.
lectureid
)
instance
.
topic
=
validated_data
.
get
(
'topic'
,
instance
.
topic
)
instance
.
date
=
validated_data
.
get
(
'date'
,
instance
.
date
)
instance
.
duration
=
validated_data
.
get
(
'duration'
,
instance
.
duration
)
instance
.
recording
=
validated_data
.
get
(
'recording'
,
instance
.
recording
)
instance
.
summary
=
validated_data
.
get
(
'summary'
,
instance
.
summary
)
instance
.
save
()
return
instance
\ No newline at end of file
LectureSummarizingBackend/ApiBasic/urls.py
0 → 100644
View file @
1f4bcb59
from
django.urls
import
path
from
.views
import
lecture_list
,
lecture_details
urlpatterns
=
[
path
(
'lecture/'
,
lecture_list
),
path
(
'details/<int:pk>'
,
lecture_details
),
]
LectureSummarizingBackend/ApiBasic/views.py
View file @
1f4bcb59
from
django.shortcuts
import
render
from
django.shortcuts
import
render
from
django.http
import
HttpResponse
,
JsonResponse
from
rest_framework.parsers
import
JSONParser
from
.
models
import
Lecture
from
.serializers
import
LectureSerializer
from
django.views.decorators.csrf
import
csrf_exempt
# Create your views here.
# Create your views here.
@
csrf_exempt
def
lecture_list
(
request
):
if
request
.
method
==
"GET"
:
lectures
=
Lecture
.
objects
.
all
()
serializers
=
LectureSerializer
(
lectures
,
many
=
True
)
return
JsonResponse
(
serializers
.
data
,
safe
=
False
)
elif
request
.
method
==
"POST"
:
data
=
JSONParser
()
.
parse
(
request
)
serializer
=
LectureSerializer
(
data
=
data
)
if
serializer
.
is_valid
():
serializer
.
save
()
return
JsonResponse
(
serializer
.
data
,
status
=
201
)
return
JsonResponse
(
serializer
.
data
,
status
=
200
)
@
csrf_exempt
def
lecture_details
(
request
,
pk
):
try
:
lecture
=
Lecture
.
objects
.
get
(
pk
=
pk
)
except
Lecture
.
DoesNotExist
:
return
HttpResponse
(
status
=
404
)
if
request
.
method
==
'GET'
:
serializer
=
LectureSerializer
(
lecture
)
return
JsonResponse
(
serializer
.
data
,
status
=
200
)
elif
request
.
method
==
'PUT'
:
data
=
JSONParser
()
.
parse
(
request
)
serializer
=
LectureSerializer
(
data
=
data
)
if
serializer
.
is_valid
():
serializer
.
save
()
return
JsonResponse
(
serializer
.
data
)
return
JsonResponse
(
serializer
.
data
,
status
=
200
)
elif
request
.
method
==
'DELETE'
:
lecture
.
delete
()
return
HttpResponse
(
atatus
=
204
)
LectureSummarizingBackend/LectureSummarizingBackend/urls.py
View file @
1f4bcb59
...
@@ -14,8 +14,9 @@ Including another URLconf
...
@@ -14,8 +14,9 @@ Including another URLconf
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
"""
from
django.contrib
import
admin
from
django.contrib
import
admin
from
django.urls
import
path
from
django.urls
import
path
,
include
urlpatterns
=
[
urlpatterns
=
[
path
(
'admin/'
,
admin
.
site
.
urls
),
path
(
'admin/'
,
admin
.
site
.
urls
),
path
(
''
,
include
(
'ApiBasic.urls'
))
]
]
LectureSummarizingBackend/db.sqlite3
View file @
1f4bcb59
No preview for this file type
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