Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
K
KawowyDzienniczek
Project
Project
Details
Activity
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
Rafal
KawowyDzienniczek
Commits
7e74eba8
Commit
7e74eba8
authored
Jul 07, 2016
by
Rafal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add beacon to place
parent
bce19eaa
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
15 deletions
+23
-15
init_places.py
...enniczek/App/loyaltyMe/management/commands/init_places.py
+12
-8
models.py
KawowyDzienniczek/App/loyaltyMe/models.py
+10
-7
serializers.py
KawowyDzienniczek/App/loyaltyMe/serializers.py
+1
-0
No files found.
KawowyDzienniczek/App/loyaltyMe/management/commands/init_places.py
View file @
7e74eba8
from
App.loyaltyMe.models
import
Place
,
Offer
,
Promotion
,
PromotionSet
,
Localization
from
App.loyaltyMe.models
import
Place
,
Offer
,
Promotion
,
PromotionSet
,
Localization
,
Beacon
__author__
=
'Rafal'
from
django.core.management.base
import
BaseCommand
,
CommandError
...
...
@@ -9,12 +9,12 @@ class Command(BaseCommand):
def
handle
(
self
,
*
args
,
**
options
):
places
=
[
#['name', 'type', 'screen_img', 'logo_img', 'description', 'offer', 'promotions'],
[
'Kocia Kawiarnia'
,
'Cafeteria'
,
'/static/img/photo_1.jpg'
,
'/static/img/photo_1.jpg'
,
'description'
,
'Oferta1'
,
'Promocja1'
,
'Makowicka'
],
[
'Kafcia u Olczaka'
,
'Cafeteria'
,
'/static/img/photo_1.jpg'
,
'/static/img/photo_1.jpg'
,
'description'
,
'Oferta2'
,
'Promocja2'
,
'Makowicka'
],
[
'Psia Kawiarnia'
,
'Cafeteria'
,
'/static/img/photo_1.jpg'
,
'/static/img/photo_1.jpg'
,
'description'
,
'Oferta1'
,
'Promocja1'
,
'Rynek'
],
[
'Kafcia u Iwczaka'
,
'Cafeteria'
,
'/static/img/photo_1.jpg'
,
'/static/img/photo_1.jpg'
,
'description'
,
'Oferta2'
,
'Promocja2'
,
'Rynek'
],
[
'Lemingowa Kawiarnia'
,
'Cafeteria'
,
'/static/img/photo_1.jpg'
,
'/static/img/photo_1.jpg'
,
'description'
,
'Oferta1'
,
'Promocja1'
,
'Makowicka'
],
[
'Kafcia u Ewelinczaka'
,
'Cafeteria'
,
'/static/img/photo_1.jpg'
,
'/static/img/photo_1.jpg'
,
'description'
,
'Oferta2'
,
'Promocja2'
,
'Rynek'
],
[
'Kocia Kawiarnia'
,
'Cafeteria'
,
'/static/img/photo_1.jpg'
,
'/static/img/photo_1.jpg'
,
'description'
,
'Oferta1'
,
'Promocja1'
,
'Makowicka'
,
'hPUL'
],
[
'Kafcia u Olczaka'
,
'Cafeteria'
,
'/static/img/photo_1.jpg'
,
'/static/img/photo_1.jpg'
,
'description'
,
'Oferta2'
,
'Promocja2'
,
'Makowicka'
,
'CeH3'
],
[
'Psia Kawiarnia'
,
'Cafeteria'
,
'/static/img/photo_1.jpg'
,
'/static/img/photo_1.jpg'
,
'description'
,
'Oferta1'
,
'Promocja1'
,
'Rynek'
,
None
],
[
'Kafcia u Iwczaka'
,
'Cafeteria'
,
'/static/img/photo_1.jpg'
,
'/static/img/photo_1.jpg'
,
'description'
,
'Oferta2'
,
'Promocja2'
,
'Rynek'
,
None
],
[
'Lemingowa Kawiarnia'
,
'Cafeteria'
,
'/static/img/photo_1.jpg'
,
'/static/img/photo_1.jpg'
,
'description'
,
'Oferta1'
,
'Promocja1'
,
'Makowicka'
,
None
],
[
'Kafcia u Ewelinczaka'
,
'Cafeteria'
,
'/static/img/photo_1.jpg'
,
'/static/img/photo_1.jpg'
,
'description'
,
'Oferta2'
,
'Promocja2'
,
'Rynek'
,
None
],
]
print
(
"Creating Places"
)
for
place
in
places
:
...
...
@@ -22,5 +22,9 @@ class Command(BaseCommand):
offer
=
Offer
.
objects
.
filter
(
name
=
place
[
5
])[
0
]
promotion_set
=
PromotionSet
.
objects
.
filter
(
name
=
place
[
6
])[
0
]
localization
=
Localization
.
objects
.
filter
(
road
=
place
[
7
])[
0
]
new_place
=
Place
.
objects
.
create
(
name
=
place
[
0
],
type
=
place
[
1
],
screen_img
=
place
[
2
],
logo_img
=
place
[
3
],
description
=
place
[
4
],
offer
=
offer
,
promotion
=
promotion_set
,
localization
=
localization
)
if
place
[
8
]:
beacon
=
Beacon
.
objects
.
filter
(
name
=
place
[
8
])[
0
]
else
:
beacon
=
None
new_place
=
Place
.
objects
.
create
(
name
=
place
[
0
],
type
=
place
[
1
],
screen_img
=
place
[
2
],
logo_img
=
place
[
3
],
description
=
place
[
4
],
offer
=
offer
,
promotion
=
promotion_set
,
localization
=
localization
,
beacon
=
beacon
)
new_place
.
save
()
\ No newline at end of file
KawowyDzienniczek/App/loyaltyMe/models.py
View file @
7e74eba8
...
...
@@ -39,6 +39,15 @@ class Localization(models.Model):
road_number
=
models
.
CharField
(
max_length
=
50
,)
class
Beacon
(
models
.
Model
):
uuid
=
models
.
CharField
(
max_length
=
300
,
unique
=
True
)
major
=
models
.
CharField
(
max_length
=
300
,
unique
=
True
)
minor
=
models
.
CharField
(
max_length
=
300
,
unique
=
True
)
name
=
models
.
CharField
(
max_length
=
300
)
description
=
models
.
CharField
(
max_length
=
300
,
null
=
True
)
class
Place
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
50
,
unique
=
True
)
type
=
models
.
CharField
(
max_length
=
50
,)
...
...
@@ -48,11 +57,5 @@ class Place(models.Model):
offer
=
models
.
ForeignKey
(
Offer
,
null
=
True
,
blank
=
True
)
promotion
=
models
.
ForeignKey
(
PromotionSet
,
null
=
True
,
blank
=
True
)
localization
=
models
.
ForeignKey
(
Localization
,
null
=
True
,
blank
=
True
)
beacon
=
models
.
ForeignKey
(
Beacon
,
null
=
True
,
blank
=
True
)
class
Beacon
(
models
.
Model
):
uuid
=
models
.
CharField
(
max_length
=
300
,
unique
=
True
)
major
=
models
.
CharField
(
max_length
=
300
,
unique
=
True
)
minor
=
models
.
CharField
(
max_length
=
300
,
unique
=
True
)
name
=
models
.
CharField
(
max_length
=
300
)
description
=
models
.
CharField
(
max_length
=
300
,
null
=
True
)
KawowyDzienniczek/App/loyaltyMe/serializers.py
View file @
7e74eba8
...
...
@@ -41,6 +41,7 @@ class PlaceSerializer(serializers.HyperlinkedModelSerializer):
offer
=
OfferSerializer
()
promotion
=
PromotionSetSerializer
()
localization
=
LocalizationSerializer
()
beacon
=
BeaconSerializer
()
class
Meta
:
model
=
Place
...
...
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