Пример #1
0
 def get_template_names(self):
     if not fail_direct(self.request, organization=get_broker()):
         # XXX testing exception catcher
         if self.kwargs.get('organization') == '500':
             raise ValueError("Testing 500 exception catcher")
         return ['app_proxy_help.html']
     return super(DjaoAppPageView, self).get_template_names()
Пример #2
0
 def get(self, request, *args, **kwargs):
     provider = get_broker()
     if fail_direct(request, organization=provider):
         return super(ProviderRedirectView, self).get(
             request, *args, **kwargs)
     kwargs.update({self.slug_url_kwarg: provider})
     return RedirectView.get(self, request, *args, **kwargs)
Пример #3
0
 def get_context_data(self, **kwargs):
     context = super(DjaoAppMixin, self).get_context_data(**kwargs)
     context.update({'edit_perm':
                     self.edit_perm})  # XXX generic_navbar.html
     if self.organization:
         if not Plan.objects.filter(
                 organization=self.organization).exists():
             context.update({'next_url': reverse('saas_cart_plan_list')})
     # URLs for user
     if self.request.user.is_authenticated():
         urls = {
             'user': {
                 'logout':
                 reverse('logout'),
                 'profile':
                 reverse('users_profile', args=(self.request.user, )),
             }
         }
     else:
         urls = {
             'user': {
                 'login':
                 reverse('login'),
                 'login_github':
                 reverse('social:begin', args=('github', )),
                 'login_google':
                 reverse('social:begin', args=('google-oauth2', )),
                 'login_twitter':
                 reverse('social:begin', args=('twitter', )),
                 'password_reset':
                 reverse('password_reset'),
                 'register':
                 reverse('registration_register'),
             }
         }
     # URLs for provider
     app = get_current_app()
     # ``app.account`` is guarenteed to be in the same database as ``app``.
     # ``site.account`` is always in the *default* database, which is not
     # the expected database ``Organization`` are typically queried from.
     provider = app.account
     if not fail_direct(self.request, organization=provider):
         urls.update({
             'provider': {
                 'dashboard': reverse('saas_dashboard', args=(provider, )),
             }
         })
     if 'urls' in context:
         for key, val in six.iteritems(urls):
             if key in context['urls']:
                 context['urls'][key].update(val)
             else:
                 context['urls'].update({key: val})
     else:
         context.update({'urls': urls})
     return context
Пример #4
0
 def forward_error(self, err):
     #pylint:disable=unused-argument
     context = super(ProxyPageMixin, self).get_context_data()
     context.update({'err': str(err)})
     template_name = 'rules/forward_error.html'
     if not fail_direct(self.request, organization=get_broker()):
         template_name = 'rules/forward_error_manager_help.html'
     return TemplateResponse(request=self.request,
                             template=template_name,
                             context=context,
                             content_type='text/html',
                             status=503)
Пример #5
0
 def get_template_names(self):
     if not fail_direct(self.request, organization=get_broker()):
         return ['app_proxy_help.html']
     return super(DjaoAppPageView, self).get_template_names()
Пример #6
0
def is_direct(request, organization=None):
    if organization is None:
        organization = get_broker()
    return not fail_direct(request, organization=organization)