def index(): menu = 'client' submenu = 'contact' context = 'charge' title_page = 'Client - Contact' search = False q = request.args.get('q') if q: search = True try: page = int(request.args.get('page', 1)) except ValueError: page = 1 offset = 0 limit = 10 if page > 1: offset = ((page - 1) * 10) count = Contact.objects().count() datas = Contact.objects().skip(offset).limit(count) pagination = Pagination(css_framework='bootstrap3', page=page, total=count, search=search, record_name='Contacts') return render_template('client/contacts.html', **locals())
def delete(client_id): from ..budget.models_budget import ClientBudget from ..projet.models_projet import Projet prospect = request.args.get('prospect') client = Client.objects.get(id=client_id) projet_client = Projet.objects(client_id=client.id) if len(projet_client): flash('Impossible de supprimer cette element', 'danger') else: contact_client = Contact.objects(client_id=client.id) budget_client = ClientBudget.objects(client_id=client.id) for contact in contact_client: contact.delete() for client in budget_client: client.delete() client.delete() flash('Suppression reussie', 'success') return redirect(url_for('client.index', prospect=prospect))
def contact(client_id, prospect=None): menu = 'client' if prospect: submenu = 'prospect' title_page = 'Prospect' else: submenu = 'client' title_page = 'Client' context = 'contact' client = Client.objects.get(id=client_id) search = False q = request.args.get('q') if q: search = True try: page = int(request.args.get('page', 1)) except ValueError: page = 1 offset = 0 limit = 10 if page > 1: offset = ((page - 1) * 10) count = Contact.objects(client_id=client.id).count() datas = Contact.objects(client_id=client.id).skip(offset).limit(limit) pagination = Pagination(css_framework='bootstrap3', page=page, total=count, search=search, record_name='Contact') return render_template('client/contact.html', **locals())