mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-10 03:49:24 +00:00
Migrate accounting
This commit is contained in:
@ -4,6 +4,7 @@ from core.views.site import search_user
|
||||
from core.models import User, Group
|
||||
from club.models import Club
|
||||
from counter.models import Product, Counter
|
||||
from accounting.models import ClubAccount, Company
|
||||
|
||||
@register('users')
|
||||
class UsersLookup(LookupChannel):
|
||||
@ -63,3 +64,23 @@ class ProductsLookup(LookupChannel):
|
||||
|
||||
def format_item_display(self, item):
|
||||
return item.name
|
||||
|
||||
@register('club_accounts')
|
||||
class ClubAccountLookup(LookupChannel):
|
||||
model = ClubAccount
|
||||
|
||||
def get_query(self, q, request):
|
||||
return self.model.objects.filter(name__icontains=q)[:50]
|
||||
|
||||
def format_item_display(self, item):
|
||||
return item.name
|
||||
|
||||
@register('companies')
|
||||
class CompaniesLookup(LookupChannel):
|
||||
model = Company
|
||||
|
||||
def get_query(self, q, request):
|
||||
return self.model.objects.filter(name__icontains=q)[:50]
|
||||
|
||||
def format_item_display(self, item):
|
||||
return item.name
|
||||
|
@ -36,6 +36,11 @@ header form {
|
||||
margin: 0px auto;
|
||||
padding: 0.3em 1%;
|
||||
}
|
||||
#language_chooser {
|
||||
position: absolute;
|
||||
left: 5px;
|
||||
top: 5px;
|
||||
}
|
||||
|
||||
/*---------------------------------NAV---------------------------------*/
|
||||
nav {
|
||||
|
@ -41,16 +41,17 @@
|
||||
{% if user.is_in_group(settings.SITH_GROUPS['accounting-admin']['name']) or user.is_root %}
|
||||
<li><a href="{{ url('accounting:bank_list') }}">{% trans %}General accounting{% endtrans %}</a></li>
|
||||
{% endif %}
|
||||
{% for m in user.membership.filter(end_date=None).filter(role__gte=7).all() %}
|
||||
{% for b in m.club.bank_accounts.all() %}
|
||||
{% for m in user.membership.filter(end_date=None).filter(role__gte=7).all() -%}
|
||||
{%- for b in m.club.bank_accounts.all() %}
|
||||
<li><strong>{% trans %}Bank account: {% endtrans %}</strong>
|
||||
<a href="{{ url('accounting:bank_details', b_account_id=b.id) }}">{{ b.club }}</a></li>
|
||||
{% endfor %}
|
||||
{% if m.club.club_account %}
|
||||
<li><strong>{% trans %}Club account: {% endtrans %}</strong>
|
||||
<a href="{{ url('accounting:club_details', c_account_id=m.club.club_account.id) }}">{{ m.club.club_account }}</a></li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<a href="{{ url('accounting:bank_details', b_account_id=b.id) }}">{{ b }}</a></li>
|
||||
{%- endfor %}
|
||||
{% if m.club.club_account.exists() -%}
|
||||
{% for ca in m.club.club_account.all() %}
|
||||
<li><strong>{% trans %}Club account: {% endtrans %}</strong> <a href="{{ url('accounting:club_details', c_account_id=ca.id) }}">{{ ca }}</a></li>
|
||||
{%- endfor %}
|
||||
{%- endif -%}
|
||||
{%- endfor %}
|
||||
</ul>
|
||||
|
||||
<hr>
|
||||
|
@ -4,6 +4,8 @@ from core.views import *
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$', index, name='index'),
|
||||
|
||||
# Search
|
||||
url(r'^search/$', search_view, name='search'),
|
||||
url(r'^search_json/$', search_json, name='search_json'),
|
||||
url(r'^search_user/$', search_user_json, name='search_user'),
|
||||
|
@ -99,6 +99,17 @@ class CanViewMixin(View):
|
||||
except: pass
|
||||
raise PermissionDenied
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(CanViewMixin, self).get_context_data(**kwargs)
|
||||
if hasattr(self, 'object_list'):
|
||||
ba_list = list(self.object_list)
|
||||
l = []
|
||||
for ba in ba_list:
|
||||
if self.request.user.can_view(ba):
|
||||
l.append(ba)
|
||||
context['object_list'] = l
|
||||
return context
|
||||
|
||||
from .user import *
|
||||
from .page import *
|
||||
from .files import *
|
||||
|
Reference in New Issue
Block a user