implementation trésorie
This commit is contained in:
parent
0e2af4db82
commit
b1cb14405c
@ -21,6 +21,7 @@ from brie.controllers.edit import EditController
|
||||
from brie.controllers.administration import AdministrationController
|
||||
from brie.controllers.error import ErrorController
|
||||
from brie.controllers.registration import RegistrationController
|
||||
from brie.controllers.treasury import TreasuryController
|
||||
|
||||
|
||||
__all__ = ['RootController']
|
||||
@ -51,6 +52,7 @@ class RootController(BaseController):
|
||||
error = ErrorController()
|
||||
search = SearchController()
|
||||
registration = RegistrationController(edit)
|
||||
treasury = TreasuryController()
|
||||
|
||||
@expose('brie.templates.index')
|
||||
def index(self):
|
||||
|
97
Brie/brie/controllers/treasury.py
Normal file
97
Brie/brie/controllers/treasury.py
Normal file
@ -0,0 +1,97 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from tg import session
|
||||
from tg.controllers import redirect
|
||||
from tg.decorators import expose, validate
|
||||
from brie.config import ldap_config
|
||||
from brie.config import groups_enum
|
||||
from brie.lib.ldap_helper import *
|
||||
from brie.lib.aurore_helper import *
|
||||
from brie.lib.plugins import *
|
||||
from brie.model.ldap import *
|
||||
|
||||
from brie.controllers import auth
|
||||
from brie.controllers.auth import AuthenticatedBaseController, AuthenticatedRestController
|
||||
from brie.controllers.members import MembersController
|
||||
|
||||
from operator import itemgetter
|
||||
|
||||
""" Controller de recherche """
|
||||
class TreasuryController(AuthenticatedBaseController):
|
||||
require_group = groups_enum.tresorier
|
||||
|
||||
validate = None
|
||||
|
||||
def __init__(self):
|
||||
self.validate = ValidatePaymentController()
|
||||
#end if
|
||||
|
||||
""" Affiche les résultats """
|
||||
@expose("brie.templates.treasury.index")
|
||||
def index(self):
|
||||
residence_dn = self.user.residence_dn
|
||||
residence = Residences.get_name_by_dn(self.user, self.user.residence_dn)
|
||||
|
||||
year = CotisationComputes.current_year()
|
||||
pending_payments = Cotisation.get_all_pending_payments(self.user, residence_dn, year)
|
||||
|
||||
admin_totals = dict()
|
||||
admin_payments_received = dict()
|
||||
for pending_payment in pending_payments:
|
||||
admin_member = Member.get_by_dn(self.user, pending_payment.get("x-action-user").first())
|
||||
admin_name = pending_payment.get("x-action-user-info").first()
|
||||
if admin_member is not None:
|
||||
admin_name = admin_member.cn.first()
|
||||
|
||||
|
||||
dn_prefix = "cn=" + pending_payment.cn.first() + ",cn=" + str(year) + ",cn=cotisations,"
|
||||
|
||||
print dn_prefix
|
||||
member_dn = pending_payment.dn[len(dn_prefix):]
|
||||
print member_dn
|
||||
member = Member.get_by_dn(self.user, member_dn)
|
||||
|
||||
amount_paid = int(pending_payment.get("x-amountPaid").first())
|
||||
|
||||
if admin_name in admin_totals:
|
||||
admin_totals[admin_name] += amount_paid
|
||||
else:
|
||||
admin_totals[admin_name] = amount_paid
|
||||
#end if
|
||||
|
||||
if admin_name in admin_payments_received:
|
||||
admin_payments_received[admin_name].append((member, pending_payment))
|
||||
else:
|
||||
admin_payments_received[admin_name] = [(member, pending_payment)]
|
||||
#end if
|
||||
#end for
|
||||
|
||||
admin_payments_received_ordered = sorted(admin_payments_received.iteritems(), key=lambda t:t[0])
|
||||
|
||||
return {
|
||||
"residence" : residence,
|
||||
"user" : self.user,
|
||||
"admin_totals" : admin_totals,
|
||||
"admin_payments_received" : admin_payments_received_ordered
|
||||
}
|
||||
#end def
|
||||
|
||||
#end class
|
||||
|
||||
|
||||
class ValidatePaymentController(AuthenticatedRestController):
|
||||
|
||||
@expose()
|
||||
def post(self, residence, member_uid, payment_cn, year):
|
||||
residence_dn = Residences.get_dn_by_name(self.user, residence)
|
||||
member = Member.get_by_uid(self.user, residence_dn, member_uid)
|
||||
|
||||
cotisation_dn = "cn=" + payment_cn + ",cn=" + str(year) + ",cn=cotisations," + member.dn
|
||||
cashed_attr = Cotisation.cashed_payment_attr()
|
||||
cotisation = self.user.ldap_bind.search_dn(cotisation_dn)
|
||||
cotisation.add("x-paymentCashed", "TRUE")
|
||||
self.user.ldap_bind.save(cotisation)
|
||||
|
||||
redirect("/treasury/")
|
||||
#end def
|
||||
#end class
|
@ -347,6 +347,13 @@ class Cotisation:
|
||||
}
|
||||
#end def
|
||||
|
||||
@staticmethod
|
||||
def cashed_payment_attr():
|
||||
return {
|
||||
"x-paymentCashed" : "TRUE"
|
||||
}
|
||||
#end def
|
||||
|
||||
@staticmethod
|
||||
def prix_annee(user_session, residence_dn):
|
||||
dn = ldap_config.cotisation_annee_base_dn + residence_dn
|
||||
@ -390,13 +397,13 @@ class Cotisation:
|
||||
@staticmethod
|
||||
def get_all_pending_payments(user_session, residence_dn, year):
|
||||
dn = ldap_config.username_base_dn + residence_dn
|
||||
return user_session.ldap_bind.search(dn, "(&(&(objectClass=aurorePayment)(x-year=" + str(year) + "))(!(x-paymentCashed=True)))")
|
||||
return user_session.ldap_bind.search(dn, "(&(&(objectClass=aurorePayment)(x-year=" + str(year) + "))(!(x-paymentCashed=TRUE)))")
|
||||
#end def
|
||||
|
||||
@staticmethod
|
||||
def get_pending_payments_of_admin(user_session, residence_dn, user_dn, year):
|
||||
dn = ldap_config.username_base_dn + residence_dn
|
||||
return user_session.ldap_bind.search(dn, "(&(&(&(objectClass=aurorePayment)(x-year=" + str(year) + "))(!(x-paymentCashed=True)))(x-action-user=" + user_dn + "))")
|
||||
return user_session.ldap_bind.search(dn, "(&(&(&(objectClass=aurorePayment)(x-year=" + str(year) + "))(!(x-paymentCashed=TRUE)))(x-action-user=" + user_dn + "))")
|
||||
#end def
|
||||
|
||||
|
||||
|
@ -18,8 +18,12 @@
|
||||
.form-signin input[type="text"],
|
||||
.form-signin input[type="password"] {
|
||||
font-size: 16px;
|
||||
height: auto;
|
||||
margin-bottom: 15px;
|
||||
padding: 7px 9px;
|
||||
}
|
||||
|
||||
|
||||
input[type="text"],input[type="password"]
|
||||
{
|
||||
height: 28px;
|
||||
}
|
||||
|
@ -13,7 +13,9 @@
|
||||
<li py:if="user.groups.admin"><a href="/rooms/index/${residence}">CHAMBRES</a></li>
|
||||
<li py:if="user.groups.admin"><a href="/members/index/${residence}">MEMBRES</a></li>
|
||||
<li py:if="user.groups.admin"><a href="/registration/">INSCRIPTION</a></li>
|
||||
<li py:if="user.groups.tresorier"><a href="/treasury/">TRESORIE</a></li>
|
||||
<li py:if="user.groups.responsablereseau"><a href="/administration/">ADMINISTRATION</a></li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
0
Brie/brie/templates/treasury/__init__.py
Normal file
0
Brie/brie/templates/treasury/__init__.py
Normal file
30
Brie/brie/templates/treasury/index.html
Normal file
30
Brie/brie/templates/treasury/index.html
Normal file
@ -0,0 +1,30 @@
|
||||
<html
|
||||
xmlns:py="http://genshi.edgewall.org/"
|
||||
xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
<head>
|
||||
<link type="text/css" rel="Stylesheet" href="/css/common.css" />
|
||||
<link type="text/css" rel="Stylesheet" href="/css/show.css" />
|
||||
<link type="text/css" rel="Stylesheet" href="/css/rooms.css" />
|
||||
<xi:include href="common-css-header.html" />
|
||||
</head>
|
||||
<body>
|
||||
<xi:include href="navbar.html" />
|
||||
<div class="section">
|
||||
<span class="section_name">PAIEMENTS EN ATTENTE</span><br />
|
||||
</div>
|
||||
<div py:for="admin_name, payments in admin_payments_received" class="section">
|
||||
<span class="section_name show_section_name">${admin_name} ${admin_totals[admin_name]} €</span>
|
||||
<div py:for="member, payment in payments">
|
||||
<span class="item_name">${payment.description.first()}</span>
|
||||
<span><a href="/show/member/${residence}/${member.uid.first()}">${member.cn.first()}</a> - ${payment.get("x-amountPaid").first()} € - ${payment.get("x-time").first()}</span>
|
||||
<form action="/treasury/validate" method="post" class="inline_block">
|
||||
<input type="hidden" name="residence" value="${residence}"/>
|
||||
<input type="hidden" name="member_uid" value="${member.uid.first()}"/>
|
||||
<input type="hidden" name="payment_cn" value="${payment.cn.first()}" />
|
||||
<input type="hidden" name="year" value="${payment.get('x-year').first()}" />
|
||||
<input type="submit" value="valider" class="button"/>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user