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
2af7195a
Commit
2af7195a
authored
Jul 07, 2016
by
Rafal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add data and number to promotion
parent
e3f3ddf8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
4 deletions
+9
-4
init_promotions.py
...czek/App/loyaltyMe/management/commands/init_promotions.py
+5
-4
models.py
KawowyDzienniczek/App/loyaltyMe/models.py
+4
-0
No files found.
KawowyDzienniczek/App/loyaltyMe/management/commands/init_promotions.py
View file @
2af7195a
from
App.loyaltyMe.models
import
Promotion
from
datetime
import
datetime
__author__
=
'Rafal'
from
django.core.management.base
import
BaseCommand
,
CommandError
...
...
@@ -9,12 +10,12 @@ class Command(BaseCommand):
def
handle
(
self
,
*
args
,
**
options
):
promotions
=
[
#[name, description, code, img, status]
[
'10
%
'
,
'Zniżka 10
%
'
,
'5ac5'
,
'/static/img/photo_1.jpg'
,
'New'
],
[
'20
%
'
,
'Zniżka 20
%
'
,
'5ac6'
,
'/static/img/photo_1.jpg'
,
'New'
],
[
'50
%
'
,
'Zniżka 50
%
'
,
'5ac7'
,
'/static/img/photo_1.jpg'
,
'New'
],
[
'10
%
'
,
'Zniżka 10
%
'
,
'5ac5'
,
'/static/img/photo_1.jpg'
,
'New'
,
'200'
,
None
,
None
],
[
'20
%
'
,
'Zniżka 20
%
'
,
'5ac6'
,
'/static/img/photo_1.jpg'
,
'New'
,
None
,
None
,
None
],
[
'50
%
'
,
'Zniżka 50
%
'
,
'5ac7'
,
'/static/img/photo_1.jpg'
,
'New'
,
'0'
,
datetime
(
2016
,
5
,
22
,
11
,
30
,
59
),
datetime
(
2017
,
12
,
22
,
11
,
30
,
59
)
],
]
print
(
"Creating Promotions"
)
for
promotion
in
promotions
:
print
(
'Create {0}'
.
format
(
promotion
[
0
]))
new_promotion
=
Promotion
.
objects
.
create
(
name
=
promotion
[
0
],
description
=
promotion
[
1
],
code
=
promotion
[
2
],
img
=
promotion
[
3
],
status
=
promotion
[
4
])
new_promotion
=
Promotion
.
objects
.
create
(
name
=
promotion
[
0
],
description
=
promotion
[
1
],
code
=
promotion
[
2
],
img
=
promotion
[
3
],
status
=
promotion
[
4
]
,
left_number
=
promotion
[
5
],
start_date
=
promotion
[
6
],
end_date
=
promotion
[
7
]
)
new_promotion
.
save
()
\ No newline at end of file
KawowyDzienniczek/App/loyaltyMe/models.py
View file @
2af7195a
...
...
@@ -22,6 +22,10 @@ class Promotion(models.Model):
code
=
models
.
CharField
(
max_length
=
50
)
img
=
models
.
ImageField
()
status
=
models
.
CharField
(
max_length
=
50
)
left_number
=
models
.
IntegerField
(
null
=
True
)
start_date
=
models
.
DateField
(
null
=
True
)
end_date
=
models
.
DateField
(
null
=
True
)
class
PromotionSet
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
50
)
...
...
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