Пример #1
0
    def get_return_url(self):

        # initialise kwargs dict with from view kwargs or set to empty dict
        kwargs = self.from_view_kwargs or {}

        # delete message variable so on returning with no update, not prompted with message
        kwargs.pop('message_var', None)

        # get previous view name and kwargs
        return reverse(viewname_app(self.from_view_name), kwargs=kwargs)
Пример #2
0
    def get_return_info_url(self, success=True):

        # initialise kwargs dict with from view kwargs or set to empty dict
        kwargs = self.from_view_kwargs or {}

        # set message variable to prompt alert on loading webpage
        kwargs['message_var'] = success

        # append success to previous view name for re-direction
        return reverse(viewname_app(self.from_view_name), kwargs=kwargs)
Пример #3
0
    def inner(self: GenericEditView, request, *args, **kwargs):

        # retrieve referer from request session
        self.from_view_name = get_last_view_name(request)

        # check exists
        if self.from_view_name:

            # retrieve referer view kwargs (if exist)
            self.from_view_kwargs = get_last_view_kwargs(request) or {}

        else:

            # last view doesn't exist - use model
            viewname_app(model_viewname(self.model))

            # model views have no kwargs
            self.from_view_kwargs = {}

        # call original get function
        return get_post(self, request, *args, **kwargs)
Пример #4
0
    def get_context_data(self, **kwargs):

        context = super().get_context_data(**kwargs)

        # add transaction and bet models for forms
        context['form_data'] = [{
            'name': model_name(model),
            'form': self.forms[model],
            'url': reverse(viewname_app(model_viewname(model)))
        } for model in models]


        return context
def get_url(view_name, kwargs):
    return reverse(viewname_app(view_name), kwargs=kwargs)
def v(view_name):
    return viewname_app(view_name)
Пример #7
0
    def object_update_link(self, object):

        return reverse(viewname_app(model_update_viewname(type(object))),
                       kwargs={'pk': object.pk})
Пример #8
0
def default_view(request):
    return HttpResponseRedirect(
        reverse(viewname_app(views_site['default'].view_name)))
Пример #9
0
bet_css_rules = [
    css_good_type('betType', goodVal='Win'),
    css_bad_type('betType', badVal='Loss')
]

model_views = lambda model: {
    'default': create_common_view(model),
    'update': update_view_class(model),
}

# Site views
views_site = model_views(Site)
# override object link (by default is update) to go to sitelog, add site name as url var
views_site['default'].get_object_link = lambda self, site: reverse(
    viewname_app(sitelog_view_name),
    kwargs={
        'pk': site.pk,
        sitelog_site_var: slugify(site.name),
    })
# dont allow deleting of sites - must be done in admin
views_site['update'].allow_delete = False

# Match View
views_match = model_views(Match)

# Transaction view
views_transaction = model_views(Transaction)
views_transaction['default'].set_css_rules(transaction_css_rules)

# Bet view