##// END OF EJS Templates
Store images as regular attachments instead of separate model
Store images as regular attachments instead of separate model

File last commit:

r1419:b30b6ad2 default
r1590:0eb7ac3c default
Show More
mixins.py
40 lines | 1019 B | text/x-python | PythonLexer
import boards
PARAM_NEXT = 'next'
PARAMETER_METHOD = 'method'
class DispatcherMixin:
"""
This class contains a dispather method that can run a method specified by
'method' request parameter.
"""
def __init__(self):
self.user = None
def dispatch_method(self, *args, **kwargs):
request = args[0]
self.user = request.user
method_name = None
if PARAMETER_METHOD in request.GET:
method_name = request.GET[PARAMETER_METHOD]
elif PARAMETER_METHOD in request.POST:
method_name = request.POST[PARAMETER_METHOD]
if method_name:
return getattr(self, method_name)(*args, **kwargs)
class FileUploadMixin:
def get_max_upload_size(self):
return boards.settings.get_int('Forms', 'MaxFileSize')
class PaginatedMixin:
def set_page_urls(self, paginator, params):
params['prev_page_link'] = paginator.get_prev_page_url()
params['next_page_link'] = paginator.get_next_page_url()