예제 #1
0
    def create(user):
        email = user.email
        existing_user = index_api.get_one(User, 'email', email)
        if existing_user:
            raise DuplicateDataError("User with email '%s' already exists!" %
                                     (email))

        return data_api.add(user)
예제 #2
0
    def create(article):
        link = article.link
        existing_article = index_api.get_one(Article, 'link', link)
        if existing_article:
            raise DuplicateDataError("Article with link '%s' already exists!" %
                                     (link))

        return data_api.add(article)
예제 #3
0
    def create(company):
        name = company.name
        existing_company = index_api.get_one(Company, 'name', name)
        if existing_company:
            raise DuplicateDataError("Company with name '%s' already exists!" %
                                     (name))

        return data_api.add(company)
예제 #4
0
    def create(user_subscription):
        user_id = user_subscription.user_id
        existing_user_subscription = index_api.get_one(UserSubscription,
                                                       'user_id',
                                                       user_id,
                                                       is_list=False)
        if existing_user_subscription:
            raise DuplicateDataError(
                "User subscription for user '%s' already exists!" % (user_id))

        return data_api.add(user_subscription)
예제 #5
0
    def create(user_bucket):
        user_id = user_bucket.user_id
        existing_user_bucket = index_api.get_one(UserBucket,
                                                 'user_id',
                                                 user_id,
                                                 is_list=False)
        if existing_user_bucket:
            raise DuplicateDataError(
                "User bucket for user '%s' already exists!" % (user_id))

        return data_api.add(user_bucket)