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
d9cb7034
Commit
d9cb7034
authored
Jul 06, 2016
by
lizonr1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add init scripts
parent
038fd0cf
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
5 deletions
+38
-5
init_offers.py
...enniczek/App/loyaltyMe/management/commands/init_offers.py
+25
-0
init_places.py
...enniczek/App/loyaltyMe/management/commands/init_places.py
+8
-4
models.py
KawowyDzienniczek/App/loyaltyMe/models.py
+1
-1
init.py
KawowyDzienniczek/App/user/management/commands/init.py
+4
-0
No files found.
KawowyDzienniczek/App/loyaltyMe/management/commands/init_offers.py
0 → 100644
View file @
d9cb7034
from
django.contrib.auth.models
import
User
from
App.loyaltyMe.models
import
Offer
,
Product
__author__
=
'Rafal'
from
django.core.management.base
import
BaseCommand
,
CommandError
class
Command
(
BaseCommand
):
help
=
'Closes the specified poll for voting'
def
handle
(
self
,
*
args
,
**
options
):
offers
=
[
#'name',products
[
'Oferta1'
,
[
'Kawa Latte'
,
'Herbata'
]
],
[
'Oferta2'
,
[
'Ciasto'
,
'Espresso'
]
],
]
print
(
"Creating Offers"
)
for
offer
in
offers
:
print
(
'Create {0}'
.
format
(
offer
[
0
]))
new_offer
=
Offer
.
objects
.
create
(
name
=
offer
[
0
])
for
product
in
offer
[
1
]:
print
(
product
)
pro_obj
=
Product
.
objects
.
filter
(
name
=
product
)[
0
]
new_offer
.
products
.
add
(
pro_obj
)
new_offer
.
save
()
\ No newline at end of file
KawowyDzienniczek/App/loyaltyMe/management/commands/init_places.py
View file @
d9cb7034
from
App.loyaltyMe.models
import
Place
from
App.loyaltyMe.models
import
Place
,
Offer
,
Promotion
__author__
=
'Rafal'
from
django.core.management.base
import
BaseCommand
,
CommandError
...
...
@@ -9,11 +9,15 @@ class Command(BaseCommand):
def
handle
(
self
,
*
args
,
**
options
):
places
=
[
#['name', 'type', 'screen_img', 'logo_img', 'description', 'offer', 'promotions'],
[
'Kocia Kawiarnia'
,
'Cafeteria'
,
'/static/media/img/photo_1.jpg'
,
'/static/media/img/photo_1.jpg'
,
'description'
,
None
,
None
],
[
'Kafcia u Olczaka'
,
'Cafeteria'
,
'/static/media/img/photo_1.jpg'
,
'/static/media/img/photo_1.jpg'
,
'description'
,
None
,
None
],
[
'Kocia Kawiarnia'
,
'Cafeteria'
,
'/static/media/img/photo_1.jpg'
,
'/static/media/img/photo_1.jpg'
,
'description'
,
'Oferta1'
,
[
'10
%
'
,
'20
%
'
]
],
[
'Kafcia u Olczaka'
,
'Cafeteria'
,
'/static/media/img/photo_1.jpg'
,
'/static/media/img/photo_1.jpg'
,
'description'
,
'Oferta2'
,
[
'20
%
'
,
'50
%
'
]
],
]
print
(
"Creating Places"
)
for
place
in
places
:
print
(
'Create {0}'
.
format
(
place
[
0
]))
new_place
=
Place
.
objects
.
create
(
name
=
place
[
0
],
type
=
place
[
1
],
screen_img
=
place
[
2
],
logo_img
=
place
[
3
],
description
=
place
[
4
],
offer
=
place
[
5
],
promotions
=
place
[
6
])
offer
=
Offer
.
objects
.
filter
(
name
=
place
[
5
])[
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
)
for
promotion
in
place
[
6
]:
prom_obj
=
Promotion
.
objects
.
filter
(
name
=
promotion
)[
0
]
new_place
.
promotions
.
add
(
prom_obj
)
new_place
.
save
()
\ No newline at end of file
KawowyDzienniczek/App/loyaltyMe/models.py
View file @
d9cb7034
...
...
@@ -31,4 +31,4 @@ class Place(models.Model):
logo_img
=
models
.
ImageField
()
description
=
models
.
CharField
(
max_length
=
50
)
offer
=
models
.
ForeignKey
(
Offer
,
null
=
True
,
blank
=
True
)
promotions
=
models
.
ForeignKey
(
Promotion
,
null
=
True
,
blank
=
True
)
promotions
=
models
.
ManyToManyField
(
Promotion
,
null
=
True
,
blank
=
True
)
KawowyDzienniczek/App/user/management/commands/init.py
View file @
d9cb7034
...
...
@@ -8,4 +8,8 @@ class Command(BaseCommand):
def
handle
(
self
,
*
args
,
**
options
):
call_command
(
'init_users'
)
call_command
(
'init_products'
)
call_command
(
'init_offers'
)
call_command
(
'init_promotions'
)
call_command
(
'init_places'
)
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