mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-12 04:49:25 +00:00
Format core
This commit is contained in:
@ -31,16 +31,19 @@ from club.models import Club
|
||||
from counter.models import Product, Counter
|
||||
from accounting.models import ClubAccount, Company
|
||||
|
||||
|
||||
def check_token(request):
|
||||
return ('counter_token' in request.session.keys() and
|
||||
request.session['counter_token'] and
|
||||
Counter.objects.filter(token=request.session['counter_token']).exists())
|
||||
request.session['counter_token'] and
|
||||
Counter.objects.filter(token=request.session['counter_token']).exists())
|
||||
|
||||
|
||||
class RightManagedLookupChannel(LookupChannel):
|
||||
def check_auth(self, request):
|
||||
if not request.user.was_subscribed and not check_token(request):
|
||||
raise PermissionDenied
|
||||
|
||||
|
||||
@register('users')
|
||||
class UsersLookup(RightManagedLookupChannel):
|
||||
model = User
|
||||
@ -54,6 +57,7 @@ class UsersLookup(RightManagedLookupChannel):
|
||||
def format_item_display(self, item):
|
||||
return item.get_display_name()
|
||||
|
||||
|
||||
@register('groups')
|
||||
class GroupsLookup(RightManagedLookupChannel):
|
||||
model = Group
|
||||
@ -67,6 +71,7 @@ class GroupsLookup(RightManagedLookupChannel):
|
||||
def format_item_display(self, item):
|
||||
return item.name
|
||||
|
||||
|
||||
@register('clubs')
|
||||
class ClubLookup(RightManagedLookupChannel):
|
||||
model = Club
|
||||
@ -80,6 +85,7 @@ class ClubLookup(RightManagedLookupChannel):
|
||||
def format_item_display(self, item):
|
||||
return item.name
|
||||
|
||||
|
||||
@register('counters')
|
||||
class CountersLookup(RightManagedLookupChannel):
|
||||
model = Counter
|
||||
@ -90,6 +96,7 @@ class CountersLookup(RightManagedLookupChannel):
|
||||
def format_item_display(self, item):
|
||||
return item.name
|
||||
|
||||
|
||||
@register('products')
|
||||
class ProductsLookup(RightManagedLookupChannel):
|
||||
model = Product
|
||||
@ -101,6 +108,7 @@ class ProductsLookup(RightManagedLookupChannel):
|
||||
def format_item_display(self, item):
|
||||
return "%s (%s)" % (item.name, item.code)
|
||||
|
||||
|
||||
@register('files')
|
||||
class SithFileLookup(RightManagedLookupChannel):
|
||||
model = SithFile
|
||||
@ -108,6 +116,7 @@ class SithFileLookup(RightManagedLookupChannel):
|
||||
def get_query(self, q, request):
|
||||
return self.model.objects.filter(name__icontains=q)[:50]
|
||||
|
||||
|
||||
@register('club_accounts')
|
||||
class ClubAccountLookup(RightManagedLookupChannel):
|
||||
model = ClubAccount
|
||||
@ -118,6 +127,7 @@ class ClubAccountLookup(RightManagedLookupChannel):
|
||||
def format_item_display(self, item):
|
||||
return item.name
|
||||
|
||||
|
||||
@register('companies')
|
||||
class CompaniesLookup(RightManagedLookupChannel):
|
||||
model = Company
|
||||
|
Reference in New Issue
Block a user