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
2aefa448
Commit
2aefa448
authored
Jul 05, 2016
by
lizonr1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add sample places
parent
c3c56659
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
3 deletions
+24
-3
init_places.py
...enniczek/App/loyaltyMe/management/commands/init_places.py
+20
-0
models.py
KawowyDzienniczek/App/loyaltyMe/models.py
+4
-3
No files found.
KawowyDzienniczek/App/loyaltyMe/management/commands/init_places.py
0 → 100644
View file @
2aefa448
from
App.loyaltyMe.models
import
Place
__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
):
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
],
[
'Kocia Kawiarnia2'
,
'Cafeteria'
,
'/static/media/img/photo_1.jpg'
,
'/static/media/img/photo_1.jpg'
,
'description'
,
None
,
None
],
]
print
(
"Creating Places"
)
for
place
in
places
:
print
(
'Create {0}'
.
format
(
place
[
0
]))
print
(
place
)
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
])
new_place
.
save
()
\ No newline at end of file
KawowyDzienniczek/App/loyaltyMe/models.py
View file @
2aefa448
...
...
@@ -12,6 +12,7 @@ class Product(models.Model):
class
Offer
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
50
)
products
=
models
.
ManyToManyField
(
Product
)
...
...
@@ -25,9 +26,9 @@ class Promotion(models.Model):
class
Place
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
50
,
unique
=
True
)
type
=
models
.
CharField
(
max_length
=
50
,
unique
=
True
)
type
=
models
.
CharField
(
max_length
=
50
,)
screen_img
=
models
.
ImageField
()
logo_img
=
models
.
ImageField
()
description
=
models
.
CharField
(
max_length
=
50
)
offer
=
models
.
ForeignKey
(
Offer
)
promotions
=
models
.
ForeignKey
(
Promotion
)
offer
=
models
.
ForeignKey
(
Offer
,
null
=
True
,
blank
=
True
)
promotions
=
models
.
ForeignKey
(
Promotion
,
null
=
True
,
blank
=
True
)
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