Toggle navigation
Toggle navigation
This project
Loading...
Sign in
cse437_e
/
smartdoorlock-backend
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
dahee kim
2020-11-16 22:33:55 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
032f53b2d03893db38ecbdb7c4538623f8d5639a
032f53b2
1 parent
ff6a6a54
Change model configuration
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
9 deletions
api/admin.py
api/migrations/0001_initial.py
api/models.py
api/serializers.py
api/admin.py
View file @
032f53b
from
django.contrib
import
admin
from
.models
import
Video
,
Device
,
History
,
Lock
,
Record
,
Door
from
.models
import
Video
,
Device
,
Remote
History
,
Lock
,
Record
,
Door
# Register your models here.
admin
.
site
.
register
(
Door
)
admin
.
site
.
register
(
Video
)
admin
.
site
.
register
(
Device
)
admin
.
site
.
register
(
History
)
admin
.
site
.
register
(
Remote
History
)
admin
.
site
.
register
(
Lock
)
admin
.
site
.
register
(
Record
)
\ No newline at end of file
...
...
api/migrations/0001_initial.py
View file @
032f53b
...
...
@@ -15,7 +15,8 @@ class Migration(migrations.Migration):
migrations
.
CreateModel
(
name
=
'Device'
,
fields
=
[
(
'rfid_id'
,
models
.
CharField
(
max_length
=
255
,
primary_key
=
True
,
serialize
=
False
)),
(
'device_id'
,
models
.
AutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
))
(
'rfid_id'
,
models
.
CharField
(
max_length
=
255
)),
(
'created'
,
models
.
DateTimeField
(
default
=
django
.
utils
.
timezone
.
now
)),
],
),
...
...
@@ -26,7 +27,7 @@ class Migration(migrations.Migration):
],
),
migrations
.
CreateModel
(
name
=
'History'
,
name
=
'
Remote
History'
,
fields
=
[
(
'id'
,
models
.
AutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'device_name'
,
models
.
CharField
(
max_length
=
255
)),
...
...
api/models.py
View file @
032f53b
...
...
@@ -7,7 +7,8 @@ class Door(models.Model) :
door_id
=
models
.
CharField
(
max_length
=
255
,
primary_key
=
True
)
class
Device
(
models
.
Model
)
:
device_id
=
models
.
CharField
(
max_length
=
255
,
primary_key
=
True
)
device_id
=
models
.
AutoField
(
primary_key
=
True
)
rfid_id
=
models
.
CharField
(
max_length
=
255
)
created
=
models
.
DateTimeField
(
default
=
timezone
.
now
)
class
Video
(
models
.
Model
)
:
...
...
@@ -18,7 +19,7 @@ class Lock(models.Model) :
id
=
models
.
IntegerField
(
primary_key
=
True
)
state
=
models
.
BooleanField
(
default
=
True
)
class
History
(
models
.
Model
)
:
class
Remote
History
(
models
.
Model
)
:
device_name
=
models
.
CharField
(
max_length
=
255
)
ctrtime
=
models
.
DateTimeField
(
default
=
timezone
.
now
)
...
...
api/serializers.py
View file @
032f53b
from
api.models
import
Device
,
Video
,
Lock
,
History
,
Record
,
Door
from
api.models
import
Device
,
Video
,
Lock
,
Remote
History
,
Record
,
Door
from
rest_framework
import
serializers
...
...
@@ -12,9 +12,9 @@ class VideoSerializer(serializers.ModelSerializer) :
model
=
Video
fields
=
'__all__'
class
HistorySerializer
(
serializers
.
ModelSerializer
)
:
class
Remote
HistorySerializer
(
serializers
.
ModelSerializer
)
:
class
Meta
:
model
=
History
model
=
Remote
History
fields
=
'__all__'
class
RecordSerializer
(
serializers
.
ModelSerializer
)
:
...
...
Please
register
or
login
to post a comment