示例#1
0
文件: company.py 项目: D015/callqr
 def create_company(self):
     company = Company(creator_user_id=current_user.id,
                       name=self.name,
                       about=self.about,
                       corporation_id=self.corporation_id)
     add_commit(company)
     return company
示例#2
0
    def create_group_client_places(self):
        group_client_places = GroupClientPlaces(creator_user_id=current_user.id,
                                                name=self.name,
                                                about=self.about,
                                                company_id=self.company_id)

        add_commit(group_client_places)
        return group_client_places
示例#3
0
文件: base.py 项目: D015/callqr
 def edit_model_object(self, **kwargs):
     for key, value in kwargs.items():
         if value != '' or value is not None:
             setattr(self._obj, key, value)
         else:
             setattr(self._obj, key, None)
     add_commit(self._obj)
     return self._obj
示例#4
0
文件: admin.py 项目: D015/callqr
 def create_admin(self):
     admin = Admin(creator_user_id=current_user.id,
                   about=self.about,
                   email=self.email,
                   phone=self.phone,
                   role_id=self.role_id,
                   corporation_id=self.corporation_id,
                   active=False)
     add_commit(admin)
     return admin
示例#5
0
    def create_client_place(self):

        if self.group_client_places_id.isdigit():
            client_place = ClientPlace(
                group_client_places_id=self.group_client_places_id,
                name=self.name, creator_user_id=current_user.id,
                company_id=self.company_id)
        else:
            client_place = ClientPlace(name=self.name,
                                       creator_user_id=current_user.id,
                                       company_id=self.company_id)

        add_commit(client_place)
        return client_place
示例#6
0
文件: employee.py 项目: D015/callqr
    def create_relationship_employee_to_user(self):
        employee = Employee.query.filter_by(slug=self.slug,
                                            active=False,
                                            archived=False,
                                            user_id=None,
                                            email=current_user.email).first()

        if employee and current_user.archived is False and current_user.active:
            current_user_employee_corporation = current_user.employees. \
                filter_by(corporation_id=employee.corporation_id).first()

            if current_user_employee_corporation is None:
                employee.user_id = current_user.id
                employee.active = True
                add_commit(employee)
                return employee
        return None
示例#7
0
文件: employee.py 项目: D015/callqr
    def create_employee(self):
        corporation_id = self.corporation_id \
            if self.corporation_id is not None \
            else CompanyAccess(id=self.id).object_by_id().corporation_id

        employee = Employee(creator_user_id=current_user.id,
                            active=False,
                            first_name=self.first_name,
                            last_name=self.last_name,
                            about=self.about,
                            email=self.email,
                            phone=self.phone,
                            role_id=self.role_id,
                            corporation_id=corporation_id,
                            company_id=self.company_id)
        add_commit(employee)
        return employee
示例#8
0
文件: admin.py 项目: D015/callqr
    def create_relationship_admin_to_user(self):

        admin = Admin.query.filter_by(slug=self.slug,
                                      active=False,
                                      archived=False,
                                      user_id=None,
                                      email=current_user.email).first()

        if admin and current_user.archived is False and current_user.active:
            current_user_admin_corporation = current_user.admins.filter_by(
                corporation_id=admin.corporation_id).first()

            if current_user_admin_corporation is None:
                admin.user_id = current_user.id
                admin.active = True
                add_commit(admin)
                return admin
        return None
示例#9
0
    def remove_relationship_obj_to_another_obj(self):
        relationship_info = self.is_relationship_obj_to_another_obj()

        is_relationship = relationship_info['is_relationship']

        is_iter = relationship_info['is_iter']

        _obj_attr_another_obj = relationship_info['_obj_attr_another_obj']

        if is_relationship:
            if is_iter:
                getattr(self._obj, _obj_attr_another_obj). \
                    remove(self.another_obj)
            else:
                setattr(self._obj, _obj_attr_another_obj, None)

            add_commit(self._obj)
            return True, 'The relationship successfully removed'
        elif is_relationship:
            return False, 'There was no relationship before'
        else:
            return None, 'error'
示例#10
0
    def create_relationship_in_company_obj_to_another_obj(self):

        relationship_info = self.is_relationship_obj_to_another_obj()

        is_relationship = relationship_info['is_relationship']

        is_iter = relationship_info['is_iter']

        _obj_attr_another_obj = relationship_info['_obj_attr_another_obj']

        if is_relationship is False:
            if is_iter:
                getattr(self._obj, _obj_attr_another_obj). \
                    append(self.another_obj)
            else:
                setattr(self._obj, _obj_attr_another_obj, self.another_obj)

            add_commit(self._obj)
            return True, 'The relationship successfully created'
        elif is_relationship:
            return False, 'The relationship already existed'
        else:
            return None, 'error'
示例#11
0
 def create_user(self):
     user = User(username=self.username, email=self.email)
     user.set_password(self.password)
     add_commit(user)
     return user
示例#12
0
文件: employee.py 项目: D015/callqr
 def add_telegram_chat_id(self):
     employee = Employee.query.filter_by(slug=self.slug).first()
     employee.telegram_chat_id = self.telegram_chat_id
     add_commit(employee)
     return True