def validate_name(self, name): if name.data.strip().lower() != self.original_name_company.lower(): company = CompanyAccess(corporation_id=self.corporation_id, name=name.data.strip()). \ company_in_corporation_by_name() if company is not None: raise ValidationError('Please use a different Company name.')
def employee(employee_slug_to_id, **kwargs): company_id = kwargs['company_id'] employee = kwargs['employee'] valid_myself = kwargs.get('valid_myself') company = CompanyAccess(id=company_id).object_by_id() # Groups client places gcp = another_objs_for_obj(company_id, obj=employee, another_obj_class_name='GroupClientPlaces') # Client places cp = another_objs_for_obj(company_id, obj=employee, another_obj_class_name='ClientPlace') return render_template( 'employee.html', the_employee_id=employee_slug_to_id, the_employee_slug=employee.slug, the_employee=employee, company=company, valid_myself=valid_myself, groups_client_places_for_admin=gcp['other_objs_in_company'], groups_client_places_with_this_employee=gcp[ 'other_objs_with_relationship_to_obj'], groups_client_places_without=gcp[ 'other_objs_without_relationship_to_obj'], client_places_with_this_employee=cp[ 'other_objs_with_relationship_to_obj'], client_places_without=cp['other_objs_without_relationship_to_obj'], client_places_for_admin=cp['other_objs_in_company'])
def remove_employee(employee_slug_to_id, **kwargs): company_slug = CompanyAccess(id=kwargs['company_id']).slug_by_id() return remove_object( obj=kwargs['employee'], func_name_for_redirected_url='company', kwargs_for_redirected_url={'company_slug_to_id': company_slug})
def remove_group_client_places(group_client_places_slug_to_id, **kwargs): company_slug = CompanyAccess(id=kwargs['company_id']).slug_by_id() return remove_object( obj=kwargs['group_client_places'], func_name_for_redirected_url='company', kwargs_for_redirected_url={'company_slug_to_id': company_slug})
def corporation(corporation_slug_to_id, **kwargs): companies = None if kwargs['valid_role_id']: companies = CompanyAccess(corporation_id=corporation_slug_to_id ).companies_by_corporation_id() admins = AdminAccess( corporation_id=corporation_slug_to_id).admins_by_corporation_id() return render_template('corporation.html', companies=companies, admins=admins, corporation=kwargs['corporation'])
def edit_company(company_slug_to_id, **kwargs): company = kwargs['company'] form = EditCompanyForm(company.name, company.corporation_id) if request.method == 'POST' and form.validate_on_submit(): CompanyAccess(_obj=company).edit_model_object( name=form.name.data.strip(), about=form.about.data.strip()) flash('Your changes have been saved.') return redirect(url_for('company', company_slug_to_id=company.slug)) elif request.method == 'GET': form.name.data = company.name form.about.data = company.about return render_template('edit_company.html', title='Edit company{}'.format(company.name), form=form)
def create_company_view(corporation_slug_to_id, **kwargs): form = CompanyForm(corporation_slug_to_id) next_page = request.args.get('next') if request.method == 'POST': if form.submit_company.data and form.validate_on_submit(): CompanyAccess(corporation_id=corporation_slug_to_id, name=form.name_company.data.strip()). \ create_company() flash('Your company is now live!') if next_page: return redirect(next_page) form.name_company.data = '' elif form.cancel_company.data: if next_page: return redirect(next_page) form.name_company.data = '' return render_template('create_company.html', form=form)