Skip to content

Commit

Permalink
Merge pull request #89 from Go-In/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
monthol8th authored Sep 30, 2017
2 parents 1aae09c + 7784571 commit 97dfb22
Show file tree
Hide file tree
Showing 68 changed files with 31,428 additions and 365 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ __pycache__/
.DS_Store
node_modules

esdata/nodes
15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,18 @@ services:
depends_on:
- db
entrypoint: /code/entrypoint.sh
# es:
# image: docker.elastic.co/elasticsearch/elasticsearch:5.6.2
# environment:
# - cluster.name=docker-cluster
# - bootstrap.memory_lock=true
# - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
# ulimits:
# memlock:
# soft: -1
# hard: -1
# mem_limit: 1g
# volumes:
# - ./esdata:/usr/share/elasticsearch/data
# ports:
# - 9200:9200
5 changes: 5 additions & 0 deletions esdata/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM docker.elastic.co/elasticsearch/elasticsearch:5.6.2
ADD elasticsearch.yml /usr/share/elasticsearch/config/
USER root
RUN chown elasticsearch:elasticsearch config/elasticsearch.yml
USER elasticsearch
5 changes: 0 additions & 5 deletions index/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,5 @@
urlpatterns = [
url(r'^$', views.index, name='index'),
url(r'^detail/(?P<ticket_id>[0-9]+)/$', views.detail, name='detail'),
url(r'^profile/$', views.profile, name='profile'),
url(r'^cart/$', views.cart, name='cart'),
url(r'^login/$', views.login, name='login'),
url(r'^profile/coupon/$', views.coupon, name='coupon'),
url(r'^profile/wallet/$', views.wallet, name='wallet'),
url(r'^profile/setting/$', views.setting, name='setting')
]
18 changes: 2 additions & 16 deletions index/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.shortcuts import render
from storemanage.models import Ticket
from django.http import JsonResponse

# Create your views here.
def index(request):
Expand All @@ -14,25 +15,10 @@ def detail(request, ticket_id):
'ticket' : ticket
})

def profile(request):
return render(request, 'index/profile.html', {})

def cart(request):
data = request.GET
items = data['cart'].split(',')
items = data['cart'].split(',') if data['cart'] else []
tickets = Ticket.objects.filter(pk__in=items)
return render(request, 'index/cart.html', {
'tickets': tickets
})

def coupon(request):
return render(request, 'index/coupon.html', {})

def setting(request):
return render(request, 'index/setting.html', {})

def wallet(request):
return render(request, 'index/wallet.html', {})

def login(request):
return render(request, 'index/login.html', {})
21 changes: 11 additions & 10 deletions market/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
from customermanage.models import Wallet, Coupon
from django.contrib.auth.decorators import login_required, user_passes_test, permission_required
from django.http import HttpResponseBadRequest
import json
# Create your views here.

@transaction.atomic
def purchasable(wallet, ticket):
if ticket.price > wallet.amount:
def purchasable(wallet, ticket, count):
if ticket.price * count > wallet.amount:
return False
if ticket.is_limit:
if ticket.remain <= 0:
if ticket.remain < count:
return False
return True

Expand All @@ -26,7 +27,7 @@ def purchase(request):
ticket = get_object_or_404(Ticket, pk=ticket_id)
wallet,create = Wallet.objects.get_or_create(user=user, currency = ticket.currency)
with transaction.atomic():
if purchasable(wallet, ticket):
if purchasable(wallet, ticket, 1):
wallet.amount -= ticket.price
wallet.save()
if ticket.is_limit:
Expand All @@ -38,16 +39,16 @@ def purchase(request):

def checkout(request):
user = request.user
ticket_id = request.POST['cart']
tickets = [get_object_or_404(Ticket, pk=t) for t in ticket_id]
for ticket in tickets:
ticketData = json.loads(request.POST['cart'])
tickets = [get_object_or_404(Ticket, pk=t['id']) for t in ticketData]
for index, ticket in enumerate(tickets):
wallet,create = Wallet.objects.get_or_create(user=user, currency = ticket.currency)
with transaction.atomic():
if purchasable(wallet, ticket):
wallet.amount -= ticket.price
if purchasable(wallet, ticket, ticketData[index]['count']):
wallet.amount -= ticket.price * ticketData[index]['count']
wallet.save()
if ticket.is_limit:
ticket.remain -= 1
ticket.remain -= ticketData[index]['count']
ticket.save()
coupon = Coupon(user = user, ticket = ticket)
coupon.save()
Expand Down
16 changes: 15 additions & 1 deletion static/css/cart.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
.list {
border: 1px solid #f1457c;
margin-top: 20px;
border-radius: 4px;
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
transition: all 0.3s cubic-bezier(.25,.8,.25,1);
}
.list:hover {
box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22);
}
.list-image {
width: 40%;
Expand All @@ -11,3 +16,12 @@
padding: 10px 1%;
display: inline-block;
}
.add-btn {
padding: 4px 15px;
}
.cart-wrapper {
min-height: 500px;
}
.cart-btn-wrapper {
margin-top: 50px;
}
21 changes: 17 additions & 4 deletions static/css/detail.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
width: 150px;
margin-right: 30px;
}
.detail-content-image {
width: 100%;
}
.detail-tr {
height: 45px;
}
.detail-head {
color: #f1457c;
margin-bottom: 50px;
}
.detail-head-title {
display: inline-block;
Expand All @@ -16,7 +21,7 @@
width: 100%;
max-width: 300px;
margin: 0 auto;
color: #f1457c;
color: black;
font-size: 20px;
}
.align-right {
Expand All @@ -29,8 +34,10 @@
text-align: center;
}
.detail-discription {
margin-top: 40px;
border: 1px solid #f1457c;
border: 1px solid #dddddd;
border-radius: 4px;
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
transition: all 0.3s cubic-bezier(.25,.8,.25,1);
padding: 15px;
font-size: 20px;
margin-bottom: 40px;
Expand All @@ -42,7 +49,13 @@
color: white;
cursor: pointer;
font-size: 20px;
transition: all 0.3s cubic-bezier(.25,.8,.25,1);
}
.buy-btn:hover {
background: #f51c61;
color: white;
}
.buy-btn-form {
display: inline-block;
margin-right: 15px;
}
4 changes: 4 additions & 0 deletions static/css/flat-ui.min.css

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions static/css/login.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
margin: 0 -15px 20px -15px;
}
.login-wrapper {
margin-top: 11%;
margin-bottom: 11%;
margin-top: 0px;
margin-bottom: 0px;
}

.login-header {
Expand Down Expand Up @@ -48,4 +48,3 @@ a.button {
text-decoration: none;
color: initial;
}

Loading

0 comments on commit 97dfb22

Please sign in to comment.