Exemplo n.º 1
0
    def create_user(self, user, numeric_id=None):
        '''Creates a user. user is a User instance.
        Params:
            user: user Object
            numeric_id: if specified, the numeric_id will be setted. Otherwise
                        it will be calculated due the user counter'''

        if not numeric_id:
            numeric_id = self.generate_user_id()

        user.numeric_id = numeric_id

        id_or_error = self.create(user, GenericServerStore.USER_ST, enable_update_if_current=True)
        if user.ID != id_or_error:
            raise BiiStoreException('Error (%s) creating user %s' % (id_or_error, user.ID))

        # Create user subscription
        user_subscription = UserSubscription(user.ID)
        user_subscription.plan_id = FREE_PLAN_ID
        self.create(user_subscription, GenericServerStore.USER_SUBSCRIPTION_ST)
    def create_user(self, user, numeric_id=None):
        '''Creates a user. user is a User instance.
        Params:
            user: user Object
            numeric_id: if specified, the numeric_id will be setted. Otherwise
                        it will be calculated due the user counter'''

        if not numeric_id:
            numeric_id = self.generate_user_id()

        user.numeric_id = numeric_id

        id_or_error = self.create(user,
                                  GenericServerStore.USER_ST,
                                  enable_update_if_current=True)
        if user.ID != id_or_error:
            raise BiiStoreException('Error (%s) creating user %s' %
                                    (id_or_error, user.ID))

        # Create user subscription
        user_subscription = UserSubscription(user.ID)
        user_subscription.plan_id = FREE_PLAN_ID
        self.create(user_subscription, GenericServerStore.USER_SUBSCRIPTION_ST)
Exemplo n.º 3
0
 def read_user_subscription_by_customer_id(self, customer_id):
     dbcol = self.db[GenericServerStore.USER_SUBSCRIPTION_ST]
     doc = dbcol.find_one({UserSubscription.SERIAL_CUSTOMER_ID_KEY: customer_id})
     return UserSubscription.deserialize(doc) if doc else None
Exemplo n.º 4
0
 def read_user_subscription_by_customer_id(self, customer_id):
     dbcol = self.db[GenericServerStore.USER_SUBSCRIPTION_ST]
     doc = dbcol.find_one(
         {UserSubscription.SERIAL_CUSTOMER_ID_KEY: customer_id})
     return UserSubscription.deserialize(doc) if doc else None