def get_snippet_request_url(self):
            unp = self.output_method.split(' ')
            (method_type, args, params) = unp[:3]
            example = unp[3:]
            if params is None or params == 'None':
                params = ''

            if args is None:
                args = ''

            kwargs = {}

            for arg in args.split(';'):
                if arg == 'None':
                    continue
                key, value = arg.split('=')
                kwargs[key] = value

            example = example[0] if example else None
            if example is not None and example != 'None':
                source, idx = example.split(':')
                for k in kwargs:
                    kwargs[k] = get_source(source, idx)[k]

            url = reverse_full('api', self.url_name, view_kwargs=kwargs)
            url = self.schema + ':' + url + ('?' + params if params != '' else '')
            return url
Exemple #2
0
 def get_invoice_url(self):
     return reverse_full(
         "invoice",
         args=[self.reference],
         scheme=settings.DEFAULT_SCHEME,
         host=settings.DEFAULT_HOST,
     )
Exemple #3
0
 def get_payment_url(self):
     return reverse_full(
         "payment",
         args=[self.reference],
         scheme=settings.DEFAULT_SCHEME,
         host=settings.DEFAULT_HOST,
     )
    def esi_url(context, host, view, *args, **kwargs):
        from django.test import RequestFactory

        request_factory = RequestFactory()
        for_resolver_link = reverse(view, args=args, kwargs=kwargs)
        link = reverse_full(host, view, view_args=args, view_kwargs=kwargs)
        request = request_factory.get(link, data={'name': u'test'})
        func, _args, _kwargs = resolve(for_resolver_link)
        response = func(request, *args, **kwargs)

        return response.content
Exemple #5
0
    def handle_order(self, order, **kwargs):
        stripe_session = order.stripe_session

        if not stripe_session:
            cancel_url = reverse_full(
                "home", scheme=settings.DEFAULT_SCHEME, host=settings.DEFAULT_HOST,
            )

            success_url = order.get_payment_url()

            session = stripe.checkout.Session.create(
                line_items=[
                    {
                        "name": item["product"].name,
                        "description": item["product"].format_description(
                            item["reference"]
                        ),
                        "quantity": item["quantity"],
                        "currency": order.currency,
                        "amount": item["total"],
                    }
                    for item in order.get_items()
                ],
                locale=settings.STRIPE_LANGUAGE_CODE,
                customer_email=order.shipping_address.email,
                payment_method_types=["card"],
                mode="payment",
                success_url=success_url,
                cancel_url=cancel_url,
            )

            order.stripe_session = session
            order.save(update_fields=("stripe_session",))

        stripe_session = order.stripe_session
        if stripe_session.payment_intent:
            payment_intent = stripe.PaymentIntent.retrieve(
                stripe_session.payment_intent
            )
            if payment_intent.status == "succeeded" and not order.is_status_succeeded():
                order.mark_as_succeeded()

        return order
Exemple #6
0
 def doc_view(self):
     return reverse_full('data', 'doc-generic')
Exemple #7
0
 def desc_view(self):
     return reverse_full('data', 'desc')
Exemple #8
0
 def render(self, context):
     url = self.url.resolve(context)
     return escape('{0}?{1}'.format(django_hosts.reverse_full(*THUMBNAIL_URL),
                             encode_parameters(url, self.width, self.height)))
Exemple #9
0
 def render(self, context):
     url = self.url.resolve(context)
     return escape('{0}?{1}'.format(
         django_hosts.reverse_full(*THUMBNAIL_URL),
         encode_parameters(url, self.width, self.height)))
Exemple #10
0
 def link_edit(self):
     return reverse_full('base',
                         'users_frontend:group_edit',
                         view_kwargs={'pk': self.pk})
def make_external_login_uri(scheme, provider):
    return '%s:%s' % (
            scheme, reverse_full('user', 'auth.views.epo_external_login', view_kwargs={'provider': provider}))
 def stream_fetch_url(self):
     return reverse_full('www', 'editres_stream_provider', view_kwargs={ 'stream_key': self.stream_key })
Exemple #13
0
 def doc_view(self):
     return reverse_full('data', 'doc-generic')
Exemple #14
0
 def desc_view(self):
     return reverse_full('data', 'desc')
Exemple #15
0
http://infodev.oucs.ox.ac.uk/analytics/.
"""

import json

from django_hosts import reverse_full

# hostname will be used with the _setDomainName Google Analytics option; see:
# <https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiDomainDirectory#_gat.GA_Tracker_._setDomainName>
# login_possible determines whether users will be told that the policy will
# become opt-out if they log in.
analytics_meta = [{'analytics_id': 'UA-32168758-1',
                   'hosts': ('equipment',),
                   'hostname': 'www.research-facilities.ox.ac.uk',
                   'login_possible': True,
                   'privacy_policy_url': reverse_full('equipment', 'legal') + '#analytics'},
                  {'analytics_id': 'UA-35258720-1',
                   'hosts': ('data', 'course', 'empty'),
                   'hostname': '.data.ox.ac.uk',
                   'login_possible': False,
                   'privacy_policy_url': reverse_full('data', 'legal') + '#analytics'}]

analytics_meta_by_host = dict((host, meta) for meta in analytics_meta
                                           for host in meta['hosts'])

def do_not_track(request):
    meta = analytics_meta_by_host.get(request.host.name)
    if meta:
        request.using_analytics = True
        analytics = {'do_not_track': request.META.get('HTTP_DNT') == '1',
                     'id': meta['analytics_id'],