Ejemplo n.º 1
0
def contact(request):
	current = 'contacto'
	contacto = "Contáctame"
	form = contactForm()
	title = "Contacto Madrid S.A."
	description = "Cotiza tu proyecto, contactame para desarrollar tu sistema."
	return render_to_response('contact.html', locals())
Ejemplo n.º 2
0
def edit_contact(contact_id):
    user = mongo.db.users.find_one({'username': session['username']})
    contact = mongo.db.contacts.find_one({'_id': ObjectId(contact_id)})
    question = mongo.db.questions.find_one(
        {'_id': ObjectId(contact['question_id'])})
    form = contactForm()
    if request.method == 'GET':
        form.contact_from.data = contact['from']
        form.contact_to.data = contact['to']
        form.contact_details.data = contact['summary']
    elif form.validate_on_submit():
        mongo.db.contacts.update(
            {'_id': ObjectId(contact_id)},
            {'$set': {
                'summary': form.contact_details.data
            }})
        flash("Your contact has been updated.", 'success')
        return redirect(
            url_for(f"{user['role']}_question_details",
                    question_id=question['_id']))
    return render_template('new_contact.html',
                           contact=contact,
                           question=question,
                           title='Edit Contact',
                           role=user['role'],
                           form=form,
                           user=user)
Ejemplo n.º 3
0
def new_contact(question_id):
    form = contactForm()
    question = mongo.db.questions.find_one({'_id': ObjectId(question_id)})
    contacts = mongo.db.contacts
    users = mongo.db.users
    user = users.find_one({'username': session['username']})
    member = users.find_one({'username': question['member_id']})
    staff = users.find_one({'username': question['staff_id']})
    if request.method == 'GET':
        form.contact_from.data = f"{user['first_name']} {user['last_name']}"
        if user['role'] == 'member':
            if question['staff_id'] == 'unassigned':
                form.contact_to.data = "RCN"
            else:
                form.contact_to.data = f"{staff['first_name']} {staff['last_name']}"
        elif user['role'] == 'staff':
            form.contact_to.data = f"{member['first_name']} {member['last_name']}"
    elif request.method == 'POST':
        if form.validate_on_submit():
            contact = {
                'question_id': ObjectId(question_id),
                'contact_type': 'database',
                'date': datetime.utcnow().strftime('%y/%m/%d  %H:%M'),
                'summary': form.contact_details.data,
                'from': form.contact_from.data,
                'to': form.contact_to.data,
                'recorded_by': session['username'],
                'recorded_on': datetime.utcnow().strftime('%y/%m/%d  %H:%M')
            }
            contacts.insert_one(contact)
            if user['role'] == 'member':
                mongo.db.questions.update({'_id': ObjectId(question_id)},
                                          {'$unset': {
                                              'end_date': ''
                                          }})
                flash(
                    "Thanks for getting in touch. Your RCN Lead will be in touch shortly. Check your contacts below for updates",
                    'success')
                return redirect(
                    url_for('member_question_details',
                            question_id=question['_id']))
            elif user['role'] == 'staff':
                mongo.db.questions
                flash("Contact made. Check your contacts below for updates",
                      'success')
                return redirect(
                    url_for('staff_question_details',
                            question_id=question['_id']))
            else:
                flash(
                    "Error with your account. Please contact IT on 01698428764.",
                    'danger')
    return render_template('new_contact.html',
                           title='Contact Form',
                           question=question,
                           user=user,
                           member=member,
                           role=user['role'],
                           form=form)
Ejemplo n.º 4
0
def login():
    form = contactForm()
    if form.validate_on_submit():
        if form.name.data == "Harshit" and form.password.data == "12345678":
            return render_template("success.html")
        else:
            return render_template("denied.html")
    return render_template('login.html', form=form)
Ejemplo n.º 5
0
def contactValid(request):
	if request.method == 'POST':
		form = contactForm(request.POST)

		if form.is_valid():

			nombre = form.cleaned_data['nombre']
			email = form.cleaned_data['email']
			telefono = form.cleaned_data['telefono']
			asunto = form.cleaned_data['asunto']
			mensaje = form.cleaned_data['mensaje']

			contacto = contactModel()
			contacto.con_name = nombre
			contacto.con_email = email
			contacto.con_number = telefono
			contacto.con_subject = asunto
			contacto.con_message = mensaje

			context_text = 'E-mail de TheMadrid.cl Nombre : ' + nombre  + ' E-mail : ' + email + ' Telefono : ' + str(telefono) + ' Asunto : ' + asunto + ' Mensaje : ' + mensaje
			html_content = 'E-mail de TheMadrid.cl <br />Nombre : ' + nombre  + '<br />E-mail : ' + email + '<br />Telefono : ' + str(telefono) + '<br />Asunto : ' + asunto + '<br />Mensaje : ' + mensaje

			if request.is_ajax():
				errores_form = {'errors' : 'errors'}
				json = simplejson.dumps(errores_form)
				
				subject, from_email, to = 'Contact From TheMadrid Service', '*****@*****.**', '*****@*****.**'
				
				msg = EmailMultiAlternatives(subject, context_text, from_email, [to])
				msg.attach_alternative(html_content, "text/html")
				msg.send()
				contacto.save()
			
				return HttpResponse(json)
				
			return render_to_response('contact.html', locals())

		else:
			errores_form = {'error' : 'error'}
			json = simplejson.dumps(errores_form)
			return render_to_response('contenido/contacto.html', locals())
			# return HttpResponse(json)
	else:
		form = contactForm()
		return render_to_response('contenido/contacto.html', locals())
Ejemplo n.º 6
0
def contactValid(request):
	current = 'contacto'
	page = 'content/contacto.html'
	if request.method == 'POST':
		form = contactForm(request.POST)
		if form.is_valid():
			nombre = form.cleaned_data['nombre']
			telefono = form.cleaned_data['telefono']
			asunto = form.cleaned_data['asunto']
			email = form.cleaned_data['email']
			mensaje = form.cleaned_data['mensaje']

			contacto = contactModel()
			contacto.con_name = nombre
			contacto.con_email = email
			contacto.con_number = telefono
			contacto.con_subject = asunto
			contacto.con_message = mensaje

			if request.is_ajax():
				data = {'ok':'ok'}
				json = simplejson.dumps(data)
				# json = serializers.serialize('json', data)
				contacto.save()

				return HttpResponse(json, mimetype="application/javascript")

			# return render_to_response('index.html', locals())

		else:
			
			q = dict((k, map(unicode, v)) for (k,v) in form.errors.iteritems())

			data = {'ok':'not', 'errors': q}
			json = simplejson.dumps(data)
			return HttpResponse(json, mimetype="application/javascript")
			

	else:
		form = contactForm()
		return render_to_response('index.html', locals())
Ejemplo n.º 7
0
def contactValid(request):
    current = 'contacto'
    page = 'content/contacto.html'
    if request.method == 'POST':
        form = contactForm(request.POST)
        if form.is_valid():
            nombre = form.cleaned_data['nombre']
            telefono = form.cleaned_data['telefono']
            asunto = form.cleaned_data['asunto']
            email = form.cleaned_data['email']
            mensaje = form.cleaned_data['mensaje']

            contacto = contactModel()
            contacto.con_name = nombre
            contacto.con_email = email
            contacto.con_number = telefono
            contacto.con_subject = asunto
            contacto.con_message = mensaje

            if request.is_ajax():
                data = {'ok': 'ok'}
                json = simplejson.dumps(data)
                # json = serializers.serialize('json', data)
                contacto.save()

                return HttpResponse(json, mimetype="application/javascript")

            # return render_to_response('index.html', locals())

        else:

            q = dict(
                (k, map(unicode, v)) for (k, v) in form.errors.iteritems())

            data = {'ok': 'not', 'errors': q}
            json = simplejson.dumps(data)
            return HttpResponse(json, mimetype="application/javascript")

    else:
        form = contactForm()
        return render_to_response('index.html', locals())
Ejemplo n.º 8
0
def index(id=None):
    contact_form = forms.contactForm()
    info = None
    cur = mysql.connection.cursor()
    cur.execute('SELECT * FROM contacts ORDER BY fullname ASC')
    data = cur.fetchall()
    if id != None:
        cur.execute('SELECT * FROM contacts WHERE id = %s', [id])
        info = cur.fetchone()
    return render_template('index.html',
                           contacts=data,
                           info=info,
                           form=contact_form)
Ejemplo n.º 9
0
def contact():
    form = contactForm(request.form)
    if request.method == "POST" and form.validate():
        msg = Message(form.subject.data,
                      sender=(form.name.data, form.email.data),
                      recipients=["*****@*****.**"])
        msg.body = form.message.data
        mail.send(msg)
        flash("Your message has been sent")
        return render_template('home.html')
    else:
        return render_template('contact.html',
                               form=form,
                               addtext='All fields are Required')
Ejemplo n.º 10
0
def contact(request):
    form = contactForm(request.POST or None)
    title = 'Contact form'
    confirm_message = None
    if form.is_valid():
        name = form.cleaned_data['name']
        subject = form.cleaned_data['subject']
        emailFrom = form.cleaned_data['email']
        emailTo = [settings.EMAIL_HOST_USER]
        send_mail(name, subject, emailFrom, emailTo, fail_silently=True)
        title = 'Thanks!'
        confirm_message = 'Thanks for sending message!'
        form = None
    context = {'title':title, 'confirm_message':confirm_message, 'form':form}
    template = 'contact.html'
    return render(request, template, context)
Ejemplo n.º 11
0
def companyView():

    kwargs = {'title': 'Company information', 'formWidth': '350'}
    compForm = companyForm()

    if g.sijax.is_sijax_request:
        g.sijax.register_object(SijaxHandler)
        return g.sijax.process_request()

    tenant = getCurrentTenant()
    kwargs['tenant'] = tenant
    contact = getContactPerson()
    if 'error' in contact:
        contact = {
            'uuid': '',
            'contactName': None,
            'email': None,
            'phone': None
        }
        errorMessage('Please assign contact person')
    else:
        contact = contact['success']
    kwargs['contact'] = contact

    compForm = companyForm(regNo=tenant[u'regNo'],
                           companyName=tenant[u'name'],
                           addr=tenant[u'addr'],
                           addr2=tenant[u'addr2'],
                           postcode=tenant[u'postcode'],
                           city=tenant[u'city'])

    contForm = contactForm(contactName=contact['uuid'],
                           email=contact['email'],
                           phone=contact['phone'])

    users = [(str(r['uuid']), str(r['name'] + ' - ' + r['email']))
             for r in getUsers()['users']]
    users.insert(0, ('', ''))
    contForm.contactName.choices = users
    return render_template('settings/newCompanyView.html',
                           contactForm=contForm,
                           companyForm=compForm,
                           **kwargs)
def contact(request):
    title = 'Context Contact'
    form = contactForm(request.POST or None)
    confirm_message = None

    if form.is_valid():
        comment = form.cleaned_data['comment']
        name = form.cleaned_data['name']
        subject = 'Message from MYSITE.com'
        message = '%s %s' %(comment, name)
        emailFrom = form.cleaned_data['email']
        emailTo = [settings.EMAIL_HOST_USER]
        send_mail(subject,message,emailFrom,emailTo,fail_silently=True)
        title = "Thanks for sending Email"
        confirm_message = "Thank for coming Daniel's Shop!"
        form = None

    context = {'title':title,'form':form,'confirm_message':confirm_message}
    template = 'contact.html'
    return render(request,template,context)
Ejemplo n.º 13
0
def contacto():
    form = contactForm()
    if form.validate_on_submit():
        flash('Mensaje enviado exitosamente', 'success')
        email_address = form.correo.data
        texto_del_mensaje = form.message.data

        # message = texto_del_mensaje
        # subject = email_address
        # server = smtplib.SMTP('smtp.gmail.com', 465)      para usar con smtplib
        # server_ssl.ehlo()
        # server.login('*****@*****.**','21509329')
        # server.sendmail('*****@*****.**')

        msg = Message(email_address,
                      sender='*****@*****.**',
                      recipients=['*****@*****.**'],
                      body=texto_del_mensaje)
        correo.send(msg)
        return redirect(url_for('home'))

    return render_template('contacto.html', form=form)
Ejemplo n.º 14
0
def contact(request):
    title = 'Contact'
    form = contactForm(request.POST or None)
    confirm_message = None

    if form.is_valid():
        comment = form.cleaned_data['comment']
        name = form.cleaned_data['name']
        subject = 'Message from MYSITE.com'
        message = '%s %s' % (comment, name)
        emailFrom = form.cleaned_data['email']
        emailTo = [settings.EMAIL_HOST_USER]
        send_mail(subject, message, emailFrom, emailTo, fail_silently=True)
        title = "Tanks"
        confirm_message = "Tanks for the message!"
        form = None

    context = {
        'title': title,
        'form': form,
        'confirm_message': confirm_message
    }
    template = 'contact.html'
    return render(request, template, context)
Ejemplo n.º 15
0
def contact():
    form = contactForm()
    return render_template('contact.html', title="contact", form=form)
Ejemplo n.º 16
0
def contactoView(request):
    current = 'contacto'
    page = 'content/contacto.html'
    form = contactForm()
    return render_to_response('index.html', locals())
Ejemplo n.º 17
0
def contactoView(request):
	current = 'contacto'
	page = 'content/contacto.html'
	form = contactForm()
	return render_to_response('index.html', locals())