Skip to content
This repository has been archived by the owner on Jun 10, 2019. It is now read-only.

WIP - PoC regsys-admin #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion regsys/admin.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
from django.contrib import admin

from .models import DetailRegistration
from .models import DetailRegistration, Payment


@admin.register(DetailRegistration)
class DetailRegistrationAdmin(admin.ModelAdmin):
pass


@admin.register(Payment)
class PaymentAdmin(admin.ModelAdmin):
pass
13 changes: 8 additions & 5 deletions regsys/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ def maxLen(self):


class RegStatus:
WAITING_PAYMENT = 'Ceka na zaplaceni'
PAID = 'Zaplaceno'
EXPIRED = 'Platba vyprsela'
CANCELLED = 'Zruseno'
WAITING_PAYMENT = 'WAITING_PAYMENT'
PAID = 'PAID'
EXPIRED = 'EXPIRED'
CANCELLED = 'CANCELLED'

choices = (
(WAITING_PAYMENT, 'Ceka na zaplaceni'),
Expand Down Expand Up @@ -73,14 +73,17 @@ class DetailRegistration(models.Model):
fri_night = models.CharField(max_length=10, choices=Sleeping.choices, default=Sleeping.BED)
sat_night = models.CharField(max_length=10, choices=Sleeping.choices, default=Sleeping.BED)

status = models.CharField(max_length=10, choices=RegStatus.choices, default=RegStatus.WAITING_PAYMENT)
status = models.CharField(max_length=30, choices=RegStatus.choices, default=RegStatus.WAITING_PAYMENT)

internal_message = models.TextField(default='Nothing specific')
price = models.IntegerField(default=200)
date_created = models.DateField(auto_now=True, editable=False)
var_symbol = models.IntegerField(primary_key=True)
reg_type = models.CharField(max_length=10, choices=RegType.choices, default=RegType.ATTANDEE)

def __str__(self):
return "DetailRegistration, {} {}, status {}".format(self.first_name, self.last_name, self.status)


class Payment(models.Model):
pay_date = models.DateField(auto_now=False, editable=False)
Expand Down
112 changes: 112 additions & 0 deletions regsys/templates/regsys/table_of_users.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
{% extends 'materialize/materialize_base_dev.html' %}
{% load static %}
<link type="text/css" rel="stylesheet" href="{% static 'static/main.css' %}"/>

{% block content %}
<style>

.PAID {
color: #4caf50;
}

.WAITING_PAYMENT {
color: #ffa000;
}

.EXPIRED {
color: #f44336;
}


</style>
<div class="row green accent-2" style="margin-bottom: 0">
<div class="container">
<div class="col s12">
<h1 class="green-text text-darken-4">Všichni přihlášení</h1>
</div>
</div>
</div>
<div class="row green accent-1">
<div class="container">
<div class="col s12">
<h2 class="green-text text-darken-4">Viditelné jen pro přihlášené.</h2>
</div>
</div>
</div>


<div class="container">
<div class="card horizontal">
<div class="card-stacked">
<div class="card-content">
<table class="striped highlight">
<thead>
<tr>
<th>Status</th>
<th>RegisterDate</th>
<th>Name</th>
<th>Spaní</th>
<th>Intern message</th>
</tr>
</thead>

<tbody>
{% for detail in details %}
<tr>
<td style="width: 20px" class="{{ detail.status }} center"><i class="material-icons">
{% if detail.status == 'PAID' %}
done
{% elif detail.status == 'WAITING_PAYMENT' %}
av_timer
{% elif detail.status == 'EXPIRED' %}
error
{% elif detail.status == 'CANCELLED' %}
clear
{% endif %}
</i></td>
<td>{{ detail.date_created }}</td>
<td><a class="modal-trigger" onclick="updateDetailModal({ 'first_name': '{{detail.first_name }}','last_name': '{{detail.last_name}}' })" href="#demo-modal">{{ detail.first_name }} {{ detail.last_name }}</a></td>
<td>{{ detail.fri_night }}, {{ detail.sat_night }}</td>
<td>{{ detail.internal_message }}</td>
</tr>
{% endfor %}


</tbody>
</table>
</div>
</div>
</div>
</div>


<div id="demo-modal" class="modal">
<div class="modal-content">
<p id="detail_name"></p>
</div>
<div class="modal-footer">
<a href="#!" class="modal-action modal-close waves-effect waves-red btn red lighten-1">Close</a>
</div>
</div>
</div>

{% endblock %}


{% block extra_javascripts %}

<script type="text/javascript">
$(document).ready(function(){
$('.collapsible').collapsible();
$('.modal').modal();
});

var updateDetailModal = function(detail){

$('#detail_name').text(detail.first_name + ' ' + detail.last_name )
}

</script>
{% endblock %}


25 changes: 19 additions & 6 deletions regsys/views.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
from django.shortcuts import render
from django.http import HttpResponse

from datetime import timedelta


from .models import DetailRegistration, Sleeping
from .forms import RegistrationForm

import .payment as p

# from .payment import *

def reg_test(request):
# if this is a POST request we need to process the form data
Expand All @@ -28,9 +33,17 @@ def reg_test(request):
form = RegistrationForm()
return render(request, 'regsys/registrationForm.html', {'form': form, 'regtype': Sleeping.choices})

def pair_payments(request):
# TODO parametrize by time period (eg last day)
statement_json = p.download_statement_json()
for pay in p.json_to_payments(statement_json):
p.process_payment(pay)

# def pair_payments(request):
# # TODO parametrize by time period (eg last day)
# statement_json = p.download_statement_json()
# for pay in p.json_to_payments(statement_json):
# p.process_payment(pay)


def regsys_admin(request):
if request.user.is_authenticated:
objects = DetailRegistration.objects.all()
return render(request, 'regsys/table_of_users.html', {'details': objects})
else:
return HttpResponse('No access buddy.')
1 change: 1 addition & 0 deletions urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
path('', views.reg_test),
path('admin/', admin.site.urls),
path('test/', views.reg_test),
path('regsys', views.regsys_admin)
]