Example #1
0
def _get_client(app,library=True):
    """
    Gets a regular API client.
    """
    cfg = get_cfg()
    apikey_setting = 'library_key' if library else 'api_key'
    return HttpClient('%s/api' % cfg.get('Connection','endpoint'),app,'beta3',auth_user=cfg.get('Connection',apikey_setting))
Example #2
0
from sharrock.client import HttpClient, ResourceClient
from django.shortcuts import render_to_response
from django.template import RequestContext
from sharrock.client import HttpClient, ResourceClient
from django.conf import settings
from django.http import HttpResponseRedirect

axl = HttpClient('%s/api' % settings.AXILENT_ENDPOINT,
                 'axilent.content',
                 'beta3',
                 auth_user=settings.AXILENT_API_KEY)
content_resource = ResourceClient('%s/api/resource' %
                                  settings.AXILENT_ENDPOINT,
                                  'axilent.content',
                                  'beta3',
                                  'content',
                                  auth_user=settings.AXILENT_API_KEY)
triggers = HttpClient('%s/api' % settings.AXILENT_ENDPOINT,
                      'axilent.triggers',
                      'beta3',
                      auth_user=settings.AXILENT_API_KEY)


def home(request, whiskey_slug=None):
    """
    Mobile home page.
    """
    featured_whiskey = None
    if whiskey_slug:
        featured_whiskey = axl.getcontentbyuniquefield(
            content_type='Whiskey',
Example #3
0
from django import forms
from django.contrib.auth.models import User
from django.utils.translation import ugettext_lazy as _
import uuid
from django.contrib import auth
from whiskeyengine.models import Drinker, Review
from django.conf import settings
from sharrock.client import HttpClient

c = HttpClient(settings.SAASPIRE_API,
               'saaspire.triggers',
               '0.1dev',
               auth_user=settings.SAASPIRE_API_KEY)


class UseMobileForm(forms.Form):
    use_mobile = forms.ChoiceField(choices=(('y', 'y'), ('n', 'n')))


class UserProfileForm(forms.ModelForm):
    class Meta:
        model = Drinker
        exclude = ('user', 'shelf', 'registered', 'wishlist', 'pic',
                   'saaspire_profile')


class UserProfileWithPicForm(forms.ModelForm):
    class Meta:
        model = Drinker
        exclude = ('user', 'registered', 'shelf', 'wishlist',
                   'saaspire_profile')
Example #4
0
def client(axilent_app):
    """
    Gets a basic http client.
    """
    return HttpClient('%s%s' % (end_point,api_path),axilent_app,api_version,auth_user=api_key)
Example #5
0
"""
Saspire integration.
"""

from django.conf import settings
from whiskeyengine.models import Whiskey
from sharrock.client import HttpClient
  
c = HttpClient(settings.SAASPIRE_API,'saaspire.content','0.1dev',auth_user=settings.SAASPIRE_API_KEY)

def profile(request):
    """
    Attempts to retrieve the profile from the request.
    """
    return request.COOKIES.get('saaspire.profile',None)

def load_whiskies(policy):
    """
    Loads the whiskies from the policy result.
    """
    loaded_whiskey = []
    results = policy['default'] # only using default group
    for result in results:
        content_key = result['content']['key']
        loaded_whiskey.append(Whiskey.objects.get(saaspire_key=content_key))
    return loaded_whiskey

def get_related_whiskies(basekey,profile=None):
    """
    Gets whiskies related to the basekey whiskey.
    """
Example #6
0
 def setUp(self):
     """
     Runs before each test.
     """
     self.c = HttpClient('http://localhost:8000/api', 'sharrock_example',
                         '1.0')