def searchContact(self):
        search_tag = self.view.tagBox.currentText()
        search_name = self.view.search_text.text()
        contact_model = contactModel()
        for i in reversed(range(self.view.buttonListLayout.count())):
            self.view.buttonListLayout.itemAt(i).widget().setParent(None)

        if search_tag == "" and search_name == "":
            self.showContacts()

        if search_tag == "" and search_name != "":
            contacts_get_by_name = contact_model.getContactFromText(
                search_name)

            for contact in contacts_get_by_name:
                if (contact[0] != None or contact[0] != ""):
                    contact_object = contactModel()
                    contact_object.setfield(contact[0], contact[1], contact[2],
                                            contact[3], contact[4], contact[5],
                                            contact[6])
                    button = widgetwithmodel.ButtonListModel(
                        contact_object, self.view.mw)
                    self.view.buttonListLayout.addWidget(button)

        if search_tag != "" and search_name == "":
            tagcontactmodel = TagContactModel()
            tagcontactmodel.setTag(search_tag)
            ids = tagcontactmodel.searchContactsFromTag()

            for id in ids:
                if (id[0] != None or id[0] != ""):
                    contact_model.setId(id[0])
                    contacts = contact_model.getContactFromId()
                    for contact in contacts:
                        contact_object = contactModel()
                        contact_object.setfield(id[0], contact[0], contact[1],
                                                contact[2], contact[3],
                                                contact[4], contact[5])
                        button = widgetwithmodel.ButtonListModel(
                            contact_object, self.view.mw)
                        self.view.buttonListLayout.addWidget(button)

        if search_tag != "" and search_name != "":
            tagcontactmodel = TagContactModel()
            tagcontactmodel.setTag(search_tag)

            contacts = tagcontactmodel.getContactFromTagAndText(search_name)
            for contact in contacts:
                contact_object = contactModel()
                contact_object.setfield(contact[0], contact[1], contact[2],
                                        contact[3], contact[4], contact[5],
                                        contact[6])
                button = widgetwithmodel.ButtonListModel(
                    contact_object, self.view.mw)
                self.view.buttonListLayout.addWidget(button)
 def showContacts(self):
     contacts = contactModel().showContacts()
     if contacts != None:
         for contact in contacts:
             contactobject = contactModel()
             contactobject.setfield(contact[0], contact[1], contact[2],
                                    contact[3], contact[4], contact[5],
                                    contact[6])
             button = widgetwithmodel.ButtonListModel(
                 contactobject, self.view.mw)
             self.view.buttonListLayout.addWidget(button)
Example #3
0
    def saveContact(self):
        first_name = self.view.first_name.text()
        last_name = self.view.last_name.text()
        telephone = self.view.telephone.text()
        email = self.view.email.text()
        url = self.view.url.text()
        notes = self.view.notes.toPlainText()

        if (first_name != None and first_name != "" and last_name != None
                and last_name != ""):
            id = self.contact.getId()
            newContact = contactModel()
            newContact.setfield(id, first_name, last_name, telephone, email,
                                url, notes)
            newContact.updateContact()

            tag_contact_model = TagContactModel()
            tag_contact_model.setId(id)
            tag_contact_model.deleteContactTagsFromId()

            items = (self.view.buttonListLayout.itemAt(i).widget()
                     for i in range(self.view.buttonListLayout.count()))
            for i in items:
                if i.isChecked() == True:
                    tag_contact_model.setId(id)
                    tag_contact_model.setTag(i.text())
                    tag_contact_model.saveContactTag()

        self.goToContactList()
    def saveContact(self):
        first_name = self.view.first_name.text()
        last_name = self.view.last_name.text()
        telephone = self.view.telephone.text()
        email = self.view.email.text()
        url = self.view.url.text()
        notes = self.view.notes.toPlainText()

        if (first_name != None and first_name != "" and last_name != None
                and last_name != ""):
            newContact = contactModel()
            id = ''.join(
                random.choice("abcdefghilmnopqrtstuvz0123456789")
                for _ in range(10))
            newContact.setfield(id, first_name, last_name, telephone, email,
                                url, notes)
            newContact.saveContact()
            items = (self.view.buttonListLayout.itemAt(i).widget()
                     for i in range(self.view.buttonListLayout.count()))
            for i in items:
                if i.isChecked() == True:
                    tag_contact_model = TagContactModel()
                    tag_contact_model.setId(id)
                    tag_contact_model.setTag(i.text())
                    tag_contact_model.saveContactTag()
        self.goToContactList()
Example #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())
Example #6
0
    def deleteContact(self):
        first_name = self.view.first_name.text()
        last_name = self.view.last_name.text()
        telephone = self.view.telephone.text()
        email = self.view.email.text()
        url = self.view.url.text()
        notes = self.view.notes.toPlainText()

        contactToDelete = contactModel()
        id = self.contact.getId()
        contactToDelete.setfield(id, first_name, last_name, telephone, email,
                                 url, notes)
        contactToDelete.deleteContact()

        tag_contact = TagContactModel()
        tag_contact.setId(id)
        tag_contact.deleteContactTagsFromId()

        self.goToContactList()
Example #7
0
def contact_mantenimiento(request):
	
	contacto = contactModel()
	nombre = request.POST['nombre']
	email = request.POST['email']
	asunto = request.POST['asunto']
	mensaje = request.POST['mensaje']
	contacto.con_name = nombre
	contacto.con_email = email
	contacto.con_subject = asunto
	contacto.con_message = mensaje
	
	if contacto.save():
		errores_form = {'contacto' : 'ok'}
	else:
		errores_form = {'contacto' : 'not'}

	json = simplejson.dumps(errores_form)

	return HttpResponse(json)
Example #8
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())
Example #9
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())