Example #1
0
def LoggingInProc(path, db_messages = []):
    sproc = ClientTokenProc(path, root_key='User', result_cls=UserModel)
    def f(request, data):
        result = sproc(request, data)
        request.session[SESSION_KEY] = request.root.user = result
        return result
    return f
Example #2
0
from jsonclient import Mapping, TextField, ListField, DictField, DateTimeField
from larryslist.models import ClientTokenProc


class NewsItemModel(Mapping):
    source = TextField()
    value = TextField()
    created = DateTimeField()
class NewsFeedModel(Mapping):
    NewsFeed = ListField(DictField(NewsItemModel))

GetNewsFeedProc = ClientTokenProc("/admin/feeder/newsfeed", root_key="NewsFeeds", result_cls=NewsFeedModel)
Example #3
0
from larryslist.models.collector import CollectorModel, CollectionModel, MetaDataProc
from larryslist.models import ClientTokenProc

__author__ = 'Martin'

SetSourcesProc = ClientTokenProc("/admin/collector/sourceedit",
                                 root_key='Collector',
                                 result_cls=CollectorModel)
SetCollectorStatusProc = ClientTokenProc("/admin/collector/status")
DeactivateCollectorProc = ClientTokenProc("/admin/collector/inactive")

CreateCollectorProc = ClientTokenProc("/admin/collector/create",
                                      root_key='Collector',
                                      result_cls=CollectorModel)
GetCollectorDetailsProc = ClientTokenProc("/admin/collector",
                                          root_key='Collector',
                                          result_cls=CollectorModel)

EditCollectorBaseProc = ClientTokenProc("/admin/collector/basicedit",
                                        root_key='Collector',
                                        result_cls=CollectorModel)
EditCollectorContactsProc = ClientTokenProc("/admin/collector/contactedit",
                                            root_key='Collector',
                                            result_cls=CollectorModel)
EditCollectorBusinessProc = ClientTokenProc("/admin/collector/businessedit",
                                            root_key='Collector',
                                            result_cls=CollectorModel)
SaveCollectorDocumentsProc = ClientTokenProc("/admin/collector/document",
                                             root_key='Collector',
                                             result_cls=CollectorModel)
SaveCollectorOtherFactsProc = ClientTokenProc("/admin/collector/fact",
Example #4
0
from jsonclient import Mapping, TextField, ListField, DictField
from larryslist.admin.apps.collector.models import CollectorModel
from larryslist.models import ClientTokenProc
from larryslist.models.news import NewsFeedModel

_GetProfilesProc = ClientTokenProc("/admin/feeder/collectors",
                                   root_key="Collectors")


def GetProfilesProc(request, user):
    result = _GetProfilesProc(request, {'token': user.token})
    if result:
        return map(CollectorModel.wrap, result.get("Collector", []))
    else:
        return []


_GetSubmittedProfiles = ClientTokenProc("/admin/feeder/submitted",
                                        root_key="Collectors")


def GetSubmittedProfiles(request, user):
    result = _GetSubmittedProfiles(request, {'token': user.token})
    if result:
        return map(CollectorModel.wrap, result.get("Collector", []))
    else:
        return []


SetNewsFeedProc = ClientTokenProc("/admin/feeder/newsfeedset",
                                  root_key="NewsFeeds",
Example #5
0
from jsonclient.cached import CachedLoader
from larryslist.models.collector import GetCollectionMetaProc, CollectionMetaModel, CollectorMetaModel, GetCollectorMetaProc
from larryslist.website.apps.auth.forms import LoginForm
from larryslist.website.apps.models import getUserFromSession, WebsiteCart, WebsiteConfigModel, GetCollectorProc
from larryslist.lib.baseviews import RootContext
from larryslist.models import ClientTokenProc
from pyramid.decorator import reify
from pyramid.httpexceptions import HTTPUnauthorized

GetWebConfigProc = ClientTokenProc("/web/config",
                                   root_key="Config",
                                   result_cls=WebsiteConfigModel)
config_loader = CachedLoader(GetWebConfigProc, "WEBSITE_CONFIG_CACHE")


class logged_in(object):
    def __init__(self, auth_route):
        self.auth_route = auth_route

    def __call__(self, wrapped):
        try:
            self.__doc__ = wrapped.__doc__
        except:  # pragma: no cover
            pass

        def wrapped_f(obj, context, request):
            if context.user.isAnon():
                request.fwd(self.auth_route)
            else:
                return wrapped(obj, context, request)
Example #6
0
        return self.credit + plan.credit

    @reify
    def collectorMap(self):
        return {c.id: c for c in self.Collector}
    def getCollector(self, id):
        return self.collectorMap.get(int(id))
    def hasCollector(self, collector):
        return isinstance(self.collectorMap.get(collector.id), CollectorModel)

    def getCreditValidity(self, request):
        return i18n.format_date(datetime.now() + timedelta(356), request)

SignupProc = LoggingInProc("/user/signup")
LoginProc = LoggingInProc("/user/login")
PasswordRequestProc = ClientTokenProc("/user/forgotpwd")
ResendRequestProc = ClientTokenProc("/user/resendForgotPwd")
UpdatePasswordProc = ClientTokenProc("/user/updatePwd")
PasswordTokenVerifyProc = ClientTokenProc("/user/token", root_key = "User", result_cls = UserModel)
CheckEmailExistsProc = ClientTokenProc('/user/emailavailable')
RefreshUserProfileProc = LoggingInProc("/user/profile")


CreatePurchaseCreditProc = ClientTokenProc("/web/credit/buy", result_cls=PaymentModel, root_key="Payment")
CheckPurchaseCreditProc = ClientTokenProc("/web/credit/paymentResult", result_cls=PaymentStatusModel, root_key="PaymentStatus")
SpendCreditProc = LoggingInProc("/web/credit/spend")


GetCollectorProc = ClientTokenProc("/web/user/getcollector", result_cls=FullCollectorModel, root_key="Collector")

Example #7
0
from jsonclient.cached import CachedLoader
from larryslist.lib.baseviews import RootContext
from larryslist.models import ClientTokenProc
from larryslist.models.config import ConfigModel
from pyramid.decorator import reify

GetAdminConfigProc = ClientTokenProc("/admin/config",
                                     root_key="Config",
                                     result_cls=ConfigModel)
config_loader = CachedLoader(GetAdminConfigProc, "REPORTS_CONFIG_CACHE")


class ReportsRootContext(RootContext):
    static_prefix = "/reports/static/"
    app_label = 'reports'

    @reify
    def config(self):
        return config_loader.get(self.request)

    @reify
    def client_token(self):
        return self.request.globals.reports.clientToken

    def is_allowed(self, request):
        return True
Example #8
0
        return self.token and self.type == 'REVIEWER'


    def hasCountries(self):
        return len(self.Country)
    def getCountryDisplay(self):
        return ', '.join(map(attrgetter('name'), self.Country))

def LoggingInProc(path, db_messages = []):
    sproc = ClientTokenProc(path, root_key='Feeder', result_cls=AdminUser)
    def f(request, data):
        result = sproc(request, data)
        request.session[SESSION_KEY] = request.user = result
        return result
    return f

def getUserFromSession(request):
    return request.session.get(SESSION_KEY, AdminUser(token=None, name = 'Anon'))

def logoutAdmin(request):
    if SESSION_KEY in request.session:
        del request.session[SESSION_KEY]
    request.fwd("admin_login")



AdminLoginProc = LoggingInProc("/admin/feeder/login")
PasswordRequestProc = LoggingInProc("/admin/feeder/forgotpwd")
ResendRequestProc = ClientTokenProc("/admin/feeder/resendForgotPwd")
UpdatePasswordProc = ClientTokenProc("/admin/feeder/updatePwd")
PasswordTokenVerifyProc = ClientTokenProc("/admin/feeder/token", root_key = "Feeder", result_cls = AdminUser)
Example #9
0
from jsonclient import DictField, ListField, Mapping
from larryslist.admin.apps.auth.models import AdminUser
from larryslist.models import ClientTokenProc


class FeedersModel(Mapping):
    Feeder = ListField(DictField(AdminUser))

CreateUserProc = ClientTokenProc("/admin/feeder/create")

_GetAllUsersProc = ClientTokenProc("/admin/feeder/list", root_key='Feeders', result_cls=FeedersModel)
def GetAllUsersProc(request):
    result = _GetAllUsersProc(request)
    return result.Feeder