New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entrance #99

Merged
merged 6 commits into from Aug 6, 2017
Next

Init: 입장 관리 페이지 초안

Changes to be commited:
	modified:   bower.json - datatables 추가
	modified:   registration/models.py - IssueTicket 모델 추가(Registration 모델에 필드로 추가할지, 모델을 따로 빼는 것이 나을지 고민)
	print:   registration/templates/registration/issue_ticket.html - 사용자 이름 길이에 따른 예외처리(현재는 5글자 이하의 한글 이름만 꺠지지 않음)
	submit:   registration/views.py - 입장 관련 Ajax 처리를 위한 작업 필요
  • Loading branch information...
channprj authored and NohSeho committed Jul 23, 2017
commit e771d4c2af0737a1f56ba5f82a46cd66535a76f1
Copy path View file
@@ -95,4 +95,10 @@ ENV/
.idea/
# Bower
pyconkr/static/components/*
pyconkr/static/components/*
# TEST db
db.sqlite3
# macOS
.DS_Store
Copy path View file
@@ -13,6 +13,10 @@
"bootstrap-social": "~5.1.1",
"typed.js": "~1.1.1",
"bootstrap-side-navbar": "^1.0.1",
"montserrat-webfont": "^1.0.3"
"montserrat-webfont": "^1.0.3",
"datatables.net": "^1.10.15",
"datatables.net-bs": "^2.1.1",
"datatables.net-rowreorder": "^1.2.0",
"datatables.net-rowreorder-bs": "^1.2.0"
}
}
@@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2017-07-22 09:44
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('registration', '0022_manualpayment'),
]
operations = [
migrations.AddField(
model_name='registration',
name='count_reissue',
field=models.IntegerField(default=0),
),
migrations.AddField(
model_name='registration',
name='issue_date',
field=models.DateTimeField(blank=True, null=True),
),
migrations.AddField(
model_name='registration',
name='issue_ticket',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='registration',
name='reissue_date',
field=models.DateTimeField(blank=True, null=True),
),
]
@@ -0,0 +1,50 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2017-07-23 01:41
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('registration', '0023_auto_20170722_1844'),
]
operations = [
migrations.CreateModel(
name='IssueTicket',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('is_issued', models.BooleanField(default=False)),
('issue_date', models.DateTimeField(blank=True, null=True)),
('reissue_date', models.DateTimeField(blank=True, null=True)),
('reissue_count', models.IntegerField(default=0)),
('issue_manager', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.RemoveField(
model_name='registration',
name='count_reissue',
),
migrations.RemoveField(
model_name='registration',
name='issue_date',
),
migrations.RemoveField(
model_name='registration',
name='issue_ticket',
),
migrations.RemoveField(
model_name='registration',
name='reissue_date',
),
migrations.AddField(
model_name='issueticket',
name='user',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='registration.Registration'),
),
]
Copy path View file
@@ -17,7 +17,7 @@ class Option(models.Model):
class Meta:
ordering = ['price']
@property
def is_soldout(self):
return self.total <= Registration.objects.filter(option=self, payment_status__in=['paid', 'ready']).count()
@@ -113,3 +113,12 @@ class ManualPayment(models.Model):
def __str__(self):
return '({}) {} ({})원'.format(self.payment_status.upper(), self.title, self.price)
class IssueTicket(models.Model):
user = models.ForeignKey(Registration)
issue_manager = models.ForeignKey(User)
is_issued = models.BooleanField(default=False)
issue_date = models.DateTimeField(null=True, blank=True)
reissue_date = models.DateTimeField(null=True, blank=True)
reissue_count = models.IntegerField(default=0)
@@ -0,0 +1,104 @@
{% extends "base.html" %}
{% load i18n humanize %}
{% load staticfiles %}
{% load crispy_forms_tags %}
{% block content %}
<table id="issue-ticket" class="table table-hover">
<thead>
<tr>
<th>이름</th>
<th>전화번호(이메일)</th>
<th>입장코드</th>
<th>관리</th>
</tr>
</thead>
<tbody>
{% for user in registration %}
<tr>
<td>{{ user.name }}</td>
<td>{{ user.phone_number }}</td>
<td>{{ user.transaction_code }}</td>
<td>
<div class="btn-group">
<button type="button" class="btn btn-success btn-filter" onclick="printLabelPopup('{{ user.name }}', '{{ user.top_size }}')">발권</button>
<button type="button" class="btn btn-warning btn-filter">재발권</button>
<button type="button" class="btn btn-default btn-filter" onclick="location.href='/admin/registration/registration/'">관리</button>
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<script src="{% static "components/datatables.net/js/jquery.dataTables.min.js" %}" charset="utf-8"></script>
<script src="{% static "components/datatables.net-bs/js/dataTables.bootstrap.min.js" %}" charset="utf-8"></script>
<link href="{% static "components/datatables.net-bs/css/dataTables.bootstrap.min.css" %}" rel="stylesheet">
<script type="text/javascript">
$(document).ready( function () {
$('#issue-ticket').DataTable({
bInfo: true,
bLengthChange: true,
lengthMenu: [[50, 100, 200], [50, 100, 200]],
order: [[ 0, 'asc' ]],
paging: true,
searching: true,
});
} );
function issueTicketConfirm() {
// send ajax request to comfirm issue ticket...
}
function printLabelPopup(name, topSize) {
var printWindow = window.open('', '', 'width=600, height=400');
var fontSize = '1em';
HTML = '';
if (name.length < 5) {
fontSize = '5em';
} else if (name.length < 10) {
fontSize = '4em';
} else {
fontSize = '3em';
}
HTML += ' \
<div class="ui brother-label"> \
<p class="ui name">' + name + '</p> \
</div> \
<div class="ui brother-label"> \
<p class="ui name">' + topSize + '</p> \
</div> \
<style> \
.brother-label { \
margin: 0 auto; \
padding: 0 auto; \
width: 88mm; \
height: 27mm; \
} \
.name{ \
font-size: ' + fontSize + '; \
font-weight: bold; \
text-align: center; \
letter-spacing: 1rem;\
} \
@media print { \
body, html, p{ \
margin: 0mm !important; \
padding: 0mm !important;\
} \
@page{ \
margin: 0mm !important; \
padding: 0mm !important; \
} \
} \
</style>';
printWindow.document.write(HTML);
printWindow.document.close();
printWindow.focus();
printWindow.print();
printWindow.close();
}
</script>
{% endblock %}
Copy path View file
@@ -13,4 +13,7 @@
login_required(views.RegistrationReceiptDetail.as_view()), name='registration_receipt'),
url(r'^payment/manual/(\d+)/$', views.manual_registration, name='manual_registration'),
url(r'^payment/manual/payment/$', views.manual_payment_process, name='manual_payment'),
url(r'^issue/$', views.issue, name='registration_issue'),
url(r'^issue/submit/$', views.issue_submit, name='registration_issue_submit'),
]
Copy path View file
@@ -1,13 +1,16 @@
# -*- coding: utf-8 -*-
import logging
import datetime
import json
import logging
from uuid import uuid4
from django.shortcuts import render, redirect, get_object_or_404
from django.http import HttpResponse, JsonResponse
from django.utils import timezone
from django.utils.translation import ugettext as _
from django.contrib.auth.decorators import login_required
from django.contrib.auth.decorators import user_passes_test
from django.contrib.auth.models import User
from django.views.generic import DetailView
from django.views.decorators.csrf import csrf_exempt
from constance import config
@@ -337,3 +340,33 @@ def get_context_data(self, **kwargs):
context = super(RegistrationReceiptDetail, self).get_context_data(**kwargs)
context['title'] = _("Registration Receipt")
return context
def group_required(*group_names):
def in_groups(u):
if u.is_authenticated():
if bool(u.groups.filter(name__in=group_names)) or u.is_superuser:
return True
return False
return user_passes_test(in_groups)
@login_required
@group_required('admin', 'organizer', 'volunteer')
def issue(request):
registration = Registration.objects.filter(payment_status='paid')
context = {
'registration': registration,
'title': _("Issue Ticket System"),
}
return render(request, 'registration/issue_ticket.html', context)
@login_required
@group_required('admin', 'organizer', 'volunteer')
def issue_submit(request):
# Work in Progress...
return JsonResponse({
'success': True,
'message': u'발권완료',
})
ProTip! Use n and p to navigate between commits in a pull request.