Esempio n. 1
0
def payments(request):
    # TODO:GETでtransactIDしか取得できない
    print(request)
    if request.POST['is_multiple'] == "True":
        form_name = "証明書(複数)"
    else:
        form_name = request.POST['form_name0']
    fee = int(request.POST['total'])
    (order_id, response) = pay.request_payments(
        product_name=form_name,
        amount=fee,
        currency="JPY",
        product_image_url=
        "https://3.bp.blogspot.com/-5o2cwzzEJWI/Vz_w2t2PtXI/AAAAAAAA6uU/IOsMq7K2zjgOcldRuPmf09xXeQ2CnZTVACLcB/s800/document_syorui_pen.png"
    )
    print(response["returnCode"])
    print(response["returnMessage"])

    transaction_id = response["info"]["transactionId"]
    print(order_id, transaction_id, form_name, fee, "JPY")
    # obj = Transactions(transaction_id=transaction_id, order_id=order_id,
    #                    product_name=product_name, amount=amount, currency=currency)
    obj = dc().Transactions(str(transaction_id))
    obj.order_id = order_id
    obj.product_name = form_name
    obj.amount = fee
    obj.currency = "JPY"
    obj.save()

    import datetime
    date = datetime.datetime.now()
    student_id = request.POST['student_id']

    # TODO:学籍番号から取得するように
    school_name = "麻生情報ビジネス"
    course_name = "情報工学科"
    form_list = []

    for i in range(int(request.POST['countFormTypes'])):
        form_item = {
            'form_id': request.POST[f'form_id{i}'],
            'form_name': request.POST[f'form_name{i}'],
            'fee': request.POST[f'fee{i}'],
            'quantity': request.POST[f'form_count{i}']
        }
        form_list.append(form_item)
    paylog = am().PayLog(time_stamp=date,
                         form_list=form_list,
                         student_id=int(student_id))
    print("---")
    print(paylog)
    print("---")
    db().save_pay_log(paylog)

    redirect_url = response["info"]["paymentUrl"]["web"]
    return redirect(redirect_url)
Esempio n. 2
0
def login(request):
    context = {}
    if request.method == 'GET':
        return render(request, 'armageddon_system/user/login.html')

    elif request.method == 'POST':
        is_login_success = False
        dbm = db()

        if 'user_id' in request.POST and 'user_pass' in request.POST:
            user_id = request.POST['user_id']
            user_pass = request.POST['user_pass']

            if dbm.check_login_id(user_id, user_pass):
                request.session['user_id'] = user_id
                request.session['user_pass'] = user_pass
                is_login_success = True
                # session_saveメソッドを作る

            else:
                context['error'] = "IDまたはパスワードが違います"

        if is_login_success:
            return pay.display_pay_logs(request)

        else:
            return render(request, 'armageddon_system/user/login.html',
                          context)
Esempio n. 3
0
def display_messages(request):
    context = {}
    if 'user_id' not in request.session:
        context['error'] = "ログインしてください"
        return render(request, 'armageddon_system/user/login.html', context)
    dbm = db()
    all_message_list = dbm.get_message_list()
    message_list = []
    for i in reversed(range(len(all_message_list))):
        message = {}
        t_with_tz = all_message_list[i]['Message']['Timestamp']['S']
        t_str, tz = t_with_tz[:-5], t_with_tz[-5:]
        t = datetime.datetime.strptime(t_str, "%Y-%m-%dT%H:%M:%S.%f")
        message['message_id'] = (all_message_list[i]['MessageId'])
        message['timestamp'] = t.strftime("%Y-%m-%d")
        message['message_content'] = all_message_list[i]['Message'][
            'MessageContent']['S']
        try:
            message['image_path'] = all_message_list[i]['Message'][
                'ImagePath']['S']
        except Exception:
            message['image_path'] = ""
        message_list.append(message)
    message_list.sort(key=lambda x: x['message_id'])
    context['message'] = message_list
    return render(request, 'armageddon_system/linebot/msg/list.html', context)
Esempio n. 4
0
def register_confirm(request):
    dbm = db()
    context = {}
    if request.POST.get('hasNotStudentId', False):
        context['student_id'] = request.POST['userName']
    else:
        context['student_id'] = request.POST['studentId']
    form_list = []
    total = 0
    for i in range(int(request.POST['countFormTypes'])):
        id = int(request.POST[f'form_id{i}'])
        name = request.POST[f'form_name{i}']
        count = int(request.POST[f'count{i}'])
        fee = int(request.POST[f'fee{i}'])
        subtotal = fee * count
        total += subtotal
        form_list.append({
            'id': id,
            'name': name,
            'count': count,
            'fee': fee,
            'subtotal': subtotal
        })
    context['is_multiple'] = [False,
                              True][int(request.POST['countFormTypes']) > 1]
    context['countFormTypes'] = int(request.POST['countFormTypes'])
    context['form_list'] = form_list
    context['total'] = total

    return render(request, 'armageddon_system/register/confirm.html', context)
Esempio n. 5
0
def display_pay_logs(request):
    context = {}
    if 'user_id' not in request.session:
        context['error'] = "ログインしてください"
        return render(request, 'armageddon_system/user/login.html', context)
    dbm = db()
    context['pay_logs'], context['total'] = dbm.get_pay_log_all()

    return render(request, 'armageddon_system/pay/log.html', context)
Esempio n. 6
0
def display_qa_list(request):
    context = {}
    if 'user_id' not in request.session:
        context['error'] = "ログインしてください"
        return render(request, 'armageddon_system/user/login.html', context)
    dbm = db()
    context['qa_list'] = dbm.get_qa_all()
    context['max_id'] = dbm.get_next_qa_id()

    return render(request, 'armageddon_system/linebot/qa/list.html', context)
Esempio n. 7
0
def delete_message(request):
    context = {}
    if 'user_id' not in request.session:
        context['error'] = "ログインしてください"
        return render(request, 'armageddon_system/user/login.html', context)
    dbm = db()
    try:
        dbm.del_message_list(request.GET['message_id'])
    except KeyError:
        pass
    return HttpResponse("削除成功")
Esempio n. 8
0
def display_form(request):
    context = {}
    if 'user_id' not in request.session:
        context['error'] = "ログインしてください"
        return render(request, 'armageddon_system/user/login.html', context)
    dbm = db()
    context['forms'] = dbm.get_form_all()
    context['max_id'] = dbm.get_next_form_id()
    # context['count'] = 1
    # {{forms.0.form_id}}でjs取得可能

    return render(request, 'armageddon_system/pay/item/list.html', context)
Esempio n. 9
0
    def __init__(self,
                 time_stamp,
                 form_list,
                 isStudent=True,
                 student_id=None,
                 school_id=None,
                 school_name=None,
                 course_id=None,
                 course_name=None,
                 buyer_name=None,
                 buyer_birth=None):
        self.time_stamp = time_stamp
        if isStudent:
            self.student_id = student_id
            self.school_id = school_id
            self.school_name = school_name
            self.course_id = course_id
            self.course_name = course_name
        else:
            self.buyer_name = buyer_name
            self.buyer_birth = buyer_birth

        self.form_list = []
        dbm = db()
        all_form = dbm.get_form_all()
        for l in form_list:
            if 'form' in l:
                f = l['form']
                form = Form(form_id=int(f.form_id),
                            form_name=f.form_name,
                            fee=f.fee,
                            issuance_days=None,
                            qr=None)
                self.form_list.append({
                    'form': all_form[int(f.form_id)],
                    'quantity': l['quantity'],
                    'subtotal': l['subtotal']
                })

            else:
                form = Form(form_id=int(l['form_id']),
                            form_name=l['form_name'],
                            fee=l['fee'],
                            issuance_days=None,
                            qr=None)
                self.form_list.append({
                    'form':
                    all_form[int(l['form_id'])],
                    'quantity':
                    int(l['quantity']),
                    'subtotal': (int(l['fee']) * int(l['quantity']))
                })
Esempio n. 10
0
def edit_message(request):
    context = {}
    if 'user_id' not in request.session:
        context['error'] = "ログインしてください"
        return render(request, 'armageddon_system/user/login.html', context)
    dbm = db()
    if 'message_id' in request.POST:
        context['message_id'] = request.POST['message_id']
        context['message'] = dbm.get_message(int(context['message_id']))
    else:
        context['message_id'] = dbm.get_next_message_id()
        context['message'] = {}
    return render(request, 'armageddon_system/linebot/msg/edit.html', context)
Esempio n. 11
0
def save_qa(request):
    context = {}
    if 'user_id' not in request.session:
        context['error'] = "ログインしてください"
        return render(request, 'armageddon_system/user/login.html', context)
    dbm = db()
    try:
        context['qa_id'] = request.GET['qa_id']
        context['questions'] = request.GET['questions'].split(",")
        context['answer'] = request.GET['answer']
        dbm.save_qa(context)
    except KeyError:
        pass
    return HttpResponse("保存成功")
Esempio n. 12
0
def register_form(request):
    context = {}
    form_list = db().get_form_all()
    context['forms'] = form_list
    form_dict = {}
    for i in form_list:
        form_map = {
            "form_id": i.form_id,
            "form_name": i.form_name,
            "fee": i.fee
        }
        form_dict[f"{i.qr}"] = form_map
    context['formDict'] = form_dict
    return render(request, 'armageddon_system/register/form.html', context)
Esempio n. 13
0
def save_form(request):
    context = {}
    if 'user_id' not in request.session:
        context['error'] = "ログインしてください"
        return render(request, 'armageddon_system/user/login.html', context)
    dbm = db()
    try:
        context['form_id'] = request.GET['form_id']
        context['form_name'] = request.GET['form_name']
        context['fee'] = request.GET['fee']
        context['issuance_days'] = request.GET['issuance_days']
        dbm.save_form(context)
    except KeyError:
        pass
    return HttpResponse("保存成功")
Esempio n. 14
0
def save_message(request):
    context = {}
    if 'user_id' not in request.session:
        context['error'] = "ログインしてください"
        return render(request, 'armageddon_system/user/login.html', context)
    dbm = db()
    context['message_id'] = request.POST['message_id']
    context['message'] = request.POST['message']
    if 'file' in request.FILES:
        context['image'] = str(request.FILES['file'])
        image = request.FILES['file']
        default_storage.save(
            'armageddon_system/static/armageddon_system/' +
            str(request.FILES['file']), ContentFile(image.read()))
    else:
        context['image'] = None
    context['time_stamp'] = str(datetime.datetime.today()).split(" ")[0]
    dbm.save_message_list(context)

    return display_messages(request)