Пример #1
0
    def update_or_create_customer_from_order(self, order, mission_instance):
        buyer_name = order.get("BuyerName")
        buyer_mail = order.get("BuyerEmail")

        if buyer_mail is None or buyer_mail == "":
            return

        customer_instance = Customer.objects.filter(
            contact__first_name_last_name=buyer_name,
            contact__email=buyer_mail).first()

        if customer_instance is None:
            contact = Contact(email=buyer_mail,
                              first_name_last_name=buyer_name)
            contact.save()
            customer_instance = Customer(contact=contact)
            customer_instance.save()
        else:
            customer_instance.email = buyer_mail
            customer_instance.first_name_last_name = buyer_name
            customer_instance.save()

        if mission_instance.customer is None:
            mission_instance.customer = customer_instance
        return customer_instance
Пример #2
0
    def post(self, request):
        form = ContactForm(request.POST)

        if form.is_valid():
            name = form.cleaned_data['name']
            email = form.cleaned_data['email']
            phoneNumber = form.cleaned_data['phoneNumber']
            message = form.cleaned_data['message']

            contact = Contact(
                name=name,
                email=email,
                phoneNumber=phoneNumber,
                message=message
            )
            contact.save()

            subject = 'hassaniprojects.com - Inquiry'
            from_email = config('DEFAULT_FROM_EMAIL')
            to_email = [config('EMAIL_PERSONAL')]
            message = """
            name - {}
            email - {}
            phoneNumber - {}
            message - {}""".format(
                name,
                email,
                phoneNumber,
                message
            )

            _ = send_mail(
                subject,
                message,
                from_email,
                to_email,
                fail_silently=config('EMAIL_FAIL_SILENTLY', cast=bool)
            )

            if _ == 1:
                messages.success(
                    request,
                    "Thank you and I will get back to you as soon as possible."
                )
            elif _ == 0:
                messages.error(
                    request,
                    "A problem occured while submitting the form. Please feel "
                    "free to send me a direct email to "
                    + config('EMAIL_PERSONAL')
                )
            return redirect('index')
        else:
            messages.error(
                request,
                "A problem occured while submitting the form. Feel "
                "free to send me a direct email to "
                + config('EMAIL_PERSONAL')
            )
            return redirect('index')
Пример #3
0
    def test_get_location(self):
        factory = RequestFactory()
        request = factory.get(reverse('home'))

        # No user and no code given
        self.assertEqual(get_location(request), None)
        # No user and a code
        self.assertEqual(get_location(request, "12065"), '12065')
        # User but no code
        user = User.objects.get(email='*****@*****.**')
        location = Location(pk=1)
        location.zip_code = Zipcode(pk=12065)
        location.pk = None
        location.save()
        contact = Contact(pk=1)
        contact.pk = None
        contact.save()
        contact_info = ContactInfo(location=location, contact=contact)
        contact_info.save()
        user.profile.contact_info = contact_info
        user.profile.save()
        request.user = user
        self.assertEqual(get_location(request),
                         user.profile.contact_info.location.zip_code.code)
        # user and code
        self.assertEqual(get_location(request, "01225"), '01225')
Пример #4
0
def index(request):
  if (request.method == 'POST'):
    name = request.POST.get('name')
    email = request.POST.get('email')
    desc = request.POST.get('desc')
    contact = Contact(name=name, email=email, desc=desc, date=datetime.today())
    contact.save()
  return render(request, 'index.html')
Пример #5
0
def ContactView(request):
    if request.method == 'POST':
        name = request.POST['name']
        from_email = request.POST['from_email']
        mobile_num = request.POST['mobile_num']
        message = request.POST['message']

        # ''' Begin reCAPTCHA validation '''

        captcha_token = request.POST.get('g-recaptcha-response')
        cap_url = 'https://www.google.com/recaptcha/api/siteverify'
        cap_secret = '6Lfnoc8aAAAAAGf3VbYh4gVBMX8nhuMmkc6TpvTs'
        cap_data = {'secret': cap_secret, 'response': captcha_token}
        cap_server_response = requests.post(url=cap_url, data=cap_data)
        cap_json = json.loads(cap_server_response.text)
        # ''' End reCAPTCHA validation '''

        if cap_json['success'] == True:
            contact = Contact(name=name,
                              mobile_num=mobile_num,
                              from_email=from_email,
                              message=message)
            contact.save()
            if name and from_email:
                try:
                    send_mail(
                        'Essbee Infotech',
                        'Thank you for getting in touch! We appreciate you contacting us. One of our colleagues will get back in touch with you soon!Have a great day!',
                        EMAIL_HOST_USER,
                        [from_email, '*****@*****.**'],
                        fail_silently=False)
                    print("mail send")
                    messages.info(request, "Thank you for contacting us.")

                except BadHeaderError:
                    return HttpResponse('Invalid header found.')
            else:
                messages.info(request, "invalid entry.")

        else:

            messages.error(request, "Invalid Captcha, Try Again")
            return redirect('/')

        work = Ourwork.objects.all()[:6]
        test = Testimonials.objects.all()
        result = Service.objects.all()[:6]
        blog = Blog.objects.all()[:3]

        return render(
            request, 'index.html', {
                'name': name,
                'results': result,
                'blog': blog,
                'test': test,
                'work': work
            })
Пример #6
0
 def form_valid(self, form):
     emergency_detail = Contact()
     emergency_detail.branch = Branch.objects.get(id=self.request.POST.get('branch'))
     emergency_detail.contact_name = self.request.POST.get('contact_name')
     emergency_detail.extension_number = self.request.POST.get('extension_number')
     emergency_detail.name = self.request.POST.get('name')
     emergency_detail.email = self.request.POST.get('email')
     emergency_detail.image = self.request.FILES.get('image')
     emergency_detail.save()
     return redirect('emergency:emergencyDetails_list')
Пример #7
0
def xmlapi(request):
    def xml_errmsg(f):
        return f"""
            There is no file. Re-upload the file.
            {f.errors}"""

    if request.method == 'POST':
        if hasattr(request, 'FILES'):
            f = UploadFileForm(request.POST, request.FILES)
            if f.is_valid():
                data = handle_uploaded_xml(request.FILES['file'])
                c = Contact()
                c.lastname = data['lastname']
                c.firstname = data['firstname']
                c.email = data['email']
                c.address = data['address']
                c.phone = data['phone']
                c.save()
                context = check_saved(c.lastname, c.firstname, c.email)
                return render(request, 'contact/contacts.html', context)
            else:
                err_msg = xml_errmsg(f)
                return HttpResponse(err_msg)
        else:
            err_msg = xml_errmsg(f)
            return HttpResponse(err_msg)
    else:
        print(f"{'#'*50} {__name__} {inspect.stack()[0][3]}\nException : {e}")
        return render(request, 'contact/errmsg.html',
                      {'message': 'Server Internal Error.'})
Пример #8
0
def add_contact(request):
	if request.method == 'POST':
		first_name = request.POST.get('firstname', '')
		last_name = request.POST.get('lastname', '')
		email = request.POST.get('email', '')
		mobile = request.POST.get('mobile', '')
		alternate_number = request.POST.get('alternate_number', '')
		contact_obj = Contact(user=request.user, first_name=first_name, last_name=last_name, email=email, mobile=mobile, alternate_number=alternate_number)
		contact_obj.save()
		return HttpResponseRedirect(reverse('contacts'))
	return render(request, 'contact/add_contact.html')
Пример #9
0
 def test_semicolon_phone(self):
     line = 'Carolyn M. Blake 817-978-4661  ; Kelly M Pippin 817-850-5774'
     contacts = extract_contacts(line)
     carolyn = Contact(
         name='Carolyn M. Blake',
         phone='8179784661',
     )
     kelly = Contact(
         name='Kelly M Pippin',
         phone='8178505774',
     )
     answer = [carolyn, kelly]
     self.assertContactsEqual(answer, contacts)
Пример #10
0
def contact(request):
    a = request.POST.get("name", "")
    b = request.POST.get("mail", "")
    c = request.POST.get("text", "")
    o = Offer.objects.all()
    t = Category.objects.all()

    if a != "" and b != "" and c != "":
        c = Contact(name=a, email=b, messege=c)
        c.save()
    context = {"offer": o, "catagory": t}

    return render(request, 'contact/contact.html', context)
Пример #11
0
    def post(self, request):
        _from = ContactRegisterForm(request.POST)
        if _from.is_valid():
            name = request.POST.get('name')
            phone = request.POST.get('phone')
            password = request.POST.get('password')
            area = int(request.POST.get('area'))

            contact = Contact.objects.filter(phone=phone)
            if contact.count() > 0:
                return ResponseResult(-1, 'fail', "该号码已经注册")
            else:
                area_object = Area.objects.get(id=int(area))

                contact = Contact()
                contact.name = name
                contact.phone = phone
                contact.password = password
                contact.area = area_object
                contact.save()
                request.session['contact_id'] = contact.id
                return ResponseResult()

        else:
            return ResponseResult(-1, 'fail', "请求失败")
Пример #12
0
    def form_valid(self, form):
        data = form.cleaned_data
        client = Client(name=data.get("name"), qr_code=data.get("qr_code"))
        bank = Bank(bank=data.get("bank"), bic=data.get("bic"), iban=data.get("iban"))
        contact = Contact(company_image=data.get("company_image"), telefon=data.get("phone"), fax=data.get("fax"),
                          email=data.get("email"), website=data.get("website"),
                          website_conditions_link=data.get("website_conditions_link"),
                          commercial_register=data.get("commercial_register"), tax_number=data.get("tax_number"),
                          sales_tax_identification_number=data.get("sales_tax_identification_number"))
        billing_address = Adress(firma=data.get("billing_company"), strasse=data.get("billing_street"),
                                 hausnummer=data.get("billing_house_number"),
                                 place=data.get("billing_place"), zip=data.get("billing_zip"),
                                 vorname=data.get("billing_first_name"), nachname=data.get("billing_last_name"))

        delivery_address = Adress(firma=data.get("delivery_company"), strasse=data.get("delivery_street"),
                                  hausnummer=data.get("delivery_house_number"),
                                  place=data.get("delivery_place"), zip=data.get("delivery_zip"),
                                  vorname=data.get("delivery_first_name"), nachname=data.get("delivery_last_name"))

        try:
            billing_address.save()
            delivery_address.save()
            bank.save()
            contact.billing_address = billing_address
            contact.delivery_address = delivery_address
            contact.save()
            contact.bank.add(bank)
            contact.save()
            client.contact = contact
            client.save()
        except ValidationError as e:
            return render(self.request, self.template_name, self.get_context_data())
        return super().form_valid(form)
Пример #13
0
def contact(request):
    if request.method == "POST":
        message = request.POST.get('message', '')
        name = request.POST.get('name', '')
        email = request.POST.get('email', '')
        phone = request.POST.get('phone', '')
        subject = request.POST.get('subject', '')
        print(message, name, email, phone, subject)
        contact = Contact(message=message,
                          name=name,
                          email=email,
                          phone=phone,
                          subject=subject)
        contact.save()
    return render(request, 'pages/contact.html')
Пример #14
0
def msg(request):
    if request.method == "POST":
        name = request.POST.get('name')
        email = request.POST.get('email')
        phone = request.POST.get('phone')
        desc = request.POST.get('desc')
        contact = Contact(name=name,
                          email=email,
                          phone=phone,
                          desc=desc,
                          date=datetime.today())
        contact.save()
    return render(request, 'contact/contact.html', {
        "BASE_URL": settings.Base_url,
        'msg': 'We will Contact you as soon....'
    })
Пример #15
0
def contact(request):
    if (request.method == "POST"):

        name = request.POST.get("name", "")
        subject = request.POST.get("subject", "")
        email = request.POST.get("email", "")
        phone = request.POST.get("phone", "")
        message = request.POST.get("message", "")
        contact = Contact(name=name,
                          subject=subject,
                          email=email,
                          phone=phone,
                          message=message)
        contact.save()

        return render(request, 'pages/contact.html', {})
    return render(request, 'pages/contact.html')
Пример #16
0
def contact(request):
    form = ContactForm(request.GET or None)
    if request.method == 'POST':
        form = ContactForm(request.POST)
        name = form.data.get('name')
        email = form.data.get('email')
        subject = form.data.get('subject')
        message = form.data.get('message')

        try:
            contact = Contact(name=name, email=email, suject=subject, message=message)
            #saving in DB
            contact.save()
        except Exception as e:
            msg_error = e

    return render_to_response('contact.html', locals(), context_instance=RequestContext(request))
Пример #17
0
 def test_query_get_count(self):
     query = '''
         query {
             profile(uuid: "%(uuid)s") {
                 count
             }
         }
     '''
     contact = Contact(
         start=datetime(2001, 1, 1, 0, 0, 0, tzinfo=pytz.UTC),
         end=datetime(2001, 1, 1, 0, 30, 0, tzinfo=pytz.UTC),
     )
     contact.save()
     contact.profiles.add(self.profile)
     query = query % {'uuid': self.profile.uuid}
     result = schema.execute(query)
     self.assertFalse(result.invalid, str(result.errors))
Пример #18
0
def contact(request):
    if request.method == 'POST':
        contact_data = Contact()
        contact_data.name = request.POST.get('name')
        contact_data.email = request.POST.get('email')
        contact_data.subject = request.POST.get('subject')
        contact_data.message = request.POST.get('message')
        contact_data.save()

    return render(request, 'contact.html')
Пример #19
0
    def post(self, request):
        form = ContactForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            name = data["name"]

            email = data["email"]
            message = data["message"]
            contact = Contact()
            contact.name = name
            contact.email = email
            contact.message = message
            contact.save()
            return HttpResponseRedirect('/merci/')
        else:

            block_script = BlockText.objects.all().filter(
                location="script").order_by("-id")
            script_site = None
            if block_script.count() > 0:
                script_site = block_script[0]

            return render(
                request, self.template_name, {
                    "form": form,
                    "message": "merci de corriger les erreurs suivants",
                    "script_site": script_site
                })
Пример #20
0
 def test_name_phone_with_space(self):
     line = 'Test Person (123)-456-7890'
     contacts = extract_contacts(line)
     person = Contact(
         name='Test Person',
         phone='1234567890',
     )
     answer = [person]
     self.assertContactsEqual(answer, contacts)
Пример #21
0
def contact_page():
    form = ContactForm()
    if request.method == 'POST' and form.validate_on_submit():
        contact = Contact()
        form.populate_obj(contact)
        db_session.add(contact)
        db_session.commit()
        return redirect(url_for('contact_page', success=True))
    return render_template('contact.html', name='contact', form=form)
Пример #22
0
def contact(request):
	if request.method == 'POST':
		form = ContactForm(request.POST)
		if form.is_valid():
			name = form.cleaned_data['name']
			company = form.cleaned_data['company']
			email = form.cleaned_data['email']
			contact_no = form.cleaned_data['contact_no']
			project_name = form.cleaned_data['project_name']
			project_info = form.cleaned_data['project_info']

			new_contact = Contact(name = name,company =company,email=email,contact_no=contact_no,project_name=project_name,project_info=project_info)
			new_contact.save()
			return HttpResponseRedirect('/thanks')
	else:
		form = ContactForm()

	return render(request,'contact.html',{'form':form})
Пример #23
0
    def test_serializer(self):
        # Stuff to serialize
        Contact(first_name='soma').save()
        Contact(first_name='Rahman').save()
        Contact(first_name='Ivey').save()

        # Expected output
        expect_yaml = \
            'contact.Contact:\n' \
            '  1: {first_name: soma, last_name: Arif}\n' \
            '  2: {first_name: Rahman, last_name: Mini}\n' \
            '  3: {first_name: Ivey, last_name: Jakir}\n'

        # Do the serialization
        actual_yaml = serializers.serialize('yaml', Contact.objects.all())

        # Did it work?
        self.assertEqual(actual_yaml, expect_yaml)
Пример #24
0
    def post(self, request, *args, **kwargs):
        form_class = self.get_form_class()
        form = self.get_form(form_class)

        contact = Contact()
        if form.is_valid():
            contact.email = form.cleaned_data['email']
            contact.first_name = form.cleaned_data['first_name']
            contact.last_name = form.cleaned_data['last_name']
            contact.profil_picture = form.cleaned_data['profil_picture']
            contact.added_by = self.request.user
            contact.save()
            return HttpResponseRedirect('/contact/')
        else:
            return render(request, self.template_name, {'form': form})
def create_contact(fake, orgs, deps, pos, subdiv):
    instance = Contact(
        first_name=fake.first_name(),
        last_name=fake.last_name(),
        patronymic=fake.middle_name(),
        is_favorite=False,
        photo='https://via.placeholder.com/150',
        organisation=random.choice(orgs),
        department=random.choice(deps),
        position=random.choice(pos),
        subdivision=random.choice(subdiv),
        email=fake.email(),
        birthday=fake.date_between(start_date="-30y", end_date="today"),
        address=fake.address(),
        office=random.randint(1, 1000),
        building=random.randint(1, 1000),
    )
    instance.save()
    return instance
Пример #26
0
def create_profile(user,
                   profile_type,
                   location,
                   first_name=None,
                   last_name=None,
                   band_name=None,
                   venue_name=None):

    profile_type = profile_type
    if profile_type == 'f':
        # Create Fan Profile
        fan = FanProfile(profile=user.profile, user=user)
        fan.save()

        # must be after fan.save()
        user.first_name = first_name
        user.last_name = last_name
        user.username = get_username(user.first_name + user.last_name)
        user.save()

        user.profile.profile_type = 'f'
        contact = Contact(name=user.first_name + " " + user.last_name)

    elif profile_type == 'm':
        # Create Musician Profile
        artist = ArtistProfile(profile=user.profile, user=user)
        artist.name = band_name
        artist.save()
        user.username = get_username(artist.name)
        user.save()
        # must be after artist.save()
        user.profile.profile_type = 'm'
        contact = Contact(name=artist.name)

    elif profile_type == 'v':
        # Create Fan Profile
        venue = VenueProfile(profile=user.profile, user=user)
        venue.name = venue_name
        venue.save()
        user.username = get_username(venue.name)
        user.save()
        # must be after venue.save()
        user.profile.profile_type = 'v'
        contact = Contact(name=venue.name)

    location.save()
    contact.save()
    Contact_info = ContactInfo(contact=contact, location=location)
    Contact_info.save()
    user.profile.contact_info = Contact_info
    user.profile.save()
    Calendar.objects.get_or_create_calendar(user, name=user.username)
    return user
Пример #27
0
    def test_normal(self):

        line = 'Tina L. Watsontarver, Contract Specialist, Email [email protected], Phone (123)456-7890 - Jaclyn G. Rodriguez, Contracting Officer, Email [email protected]'
        contacts = extract_contacts(line)

        tina = Contact(
            name='Tina L. Watsontarver',
            title='Contract Specialist',
            email='*****@*****.**',
            phone='1234567890',
        )

        jaclyn = Contact(name='Jaclyn G. Rodriguez',
                         title='Contracting Officer',
                         email='*****@*****.**')

        answer = [tina, jaclyn]

        self.assertContactsEqual(answer, contacts)
Пример #28
0
def process_fields(fields):
    # Give the names the correct title case
    contact = Contact()
    for field in fields:
        key, value = [x.strip() for x in field.split(':')]
        if key in ['Name', 'Title']:
            value = value.title()
        setattr(contact, field_names[key], value)

    return contact
Пример #29
0
def submit_query(request):
    contact = Contact()
    contact.name = request.POST.get('name')
    contact.email = request.POST.get('email')
    contact.subject = request.POST.get('subject')
    contact.query = request.POST.get('message')
    contact.resolved = False
    contact.save()
    message = """Subject:  """ + contact.subject \
              + """ Dear """ + contact.name + """
    
        Thank you for letting us know about your issue and sorry for inconvenience. We will surely get back to you as soon as possible and also thank you for
        using our services.
         
        Yours sincerely 
        D's Blog Team
    """
    return redirect('/')
Пример #30
0
def __get_customer_contact(request):
    try:
        customer = Customer.objects.get(email=request.POST['email'])
    except Customer.DoesNotExist:
        customer = Customer(email=request.POST['email'])
        customer.save()
    if request.POST.get('contact_id', False):
        contact = Contact.objects.get(id=request.POST['contact_id'])
    else:
        contact = Contact(
            customer=customer,
            name=request.POST['name'],
            country='USA',  # hardcoded
            state=request.POST.get('state', ''),
            city=request.POST['city'],
            address=request.POST['address'],
            phone=request.POST.get('phone', ''),
            zip=request.POST.get('zip', ''),
            primary=True,
        )
        contact.save()
    return customer, contact
Пример #31
0
def index(request):
    if request.method == 'POST':
        form = ContactForm(request.POST)
        if form.is_valid():
            topic = form.cleaned_data['topic']
            message = form.cleaned_data['message']
            sender = form.cleaned_data.get('sender', '*****@*****.**')

            # Save to DB are explict field names requied/good practice?
            c = Contact(topic=topic, message=message, sender=sender)
            c.save()

            send_mail(
                'Feedback from your site, topic: %s' % topic,
                message, sender,
                ['*****@*****.**']
            )
            #TODO: could we set a message on the original form (or send ajax and not page reload?
            return HttpResponseRedirect(reverse('contact.views.thanks'))
    else:
        form = ContactForm(initial={'sender': '*****@*****.**'})
    return render_to_response('contact/index.html', {'form': form}, context_instance=RequestContext(request))
Пример #32
0
def contactUs(request):
    if request.method == 'POST':
        first_name = request.POST['first_name']
        last_name = request.POST['last_name']
        email = request.POST['email']
        message = request.POST['message']
        user_id = request.user.id
        phone = request.POST['phone']

        cont = Contact(
            first_name=first_name, last_name=last_name, email=email, phone=phone, message=message, user_id=user_id)
        cont.save()
        messages.info(
            request, "Thanks for Contacting Us! We'll get back to you soon. . .")

        URL = 'https://www.sms4india.com/api/v1/sendCampaign'

# get request

        def sendPostRequest(reqUrl, apiKey, secretKey, useType, phoneNo, senderId, textMessage):
            req_params = {
                'apikey': apiKey,
                'secret': secretKey,
                'usetype': useType,
                'phone': phoneNo,
                'message': textMessage,
                'senderid': senderId
            }
            return requests.post(reqUrl, req_params)

        # get response
        response = sendPostRequest(URL, '5MS0GYT0UVVIO57SV2ME5Y59E8T2B9X1', '8I2ZFK3VCEE348PP',
                                   'stage', phone, '*****@*****.**', 'From UBike, Thanks for Contacting us, we will get back to you soon')

        return redirect('contact')

    else:
        return render(request, 'contact.html')
Пример #33
0
    def test_double_name(self):
        line = 'Hal Hayes 619-532-1251 Hal Hayes, Contract Specialist, [email protected],<a href="mailto:[email protected]">[email protected]</a>'

        contacts = extract_contacts(line)
        answer = [
            Contact(
                name='Hal Hayes',
                phone='6195321251',
                title='Contract Specialist',
                email='*****@*****.**',
            )
        ]

        self.assertContactsEqual(answer, contacts)
Пример #34
0
 def test_create_user_profile(self):
     creator = User.objects.get(pk=1)
     location = Location(zip_code=Zipcode(pk=12065))
     contact = Contact(name=creator.username)
     location.save()
     contact.save()
     contact_info = ContactInfo(contact=contact, location=location)
     contact_info.save()
     creator.profile.contact_info = contact_info
     # test artist creation
     user = create_user_profile("Mouse Rat", "*****@*****.**", "m",
                                creator)
     self.failIf(user.profile.has_owner)
     self.assertIsNotNone(user.profile.artist_profile)
     self.assertIsNotNone(user.profile.contact_info)
     self.assertIsNotNone(user.calendar)
     # test venue creation
     user = create_user_profile("gasworks", "*****@*****.**", "v",
                                creator)
     self.failIf(user.profile.has_owner)
     self.assertIsNotNone(user.profile.venueProfile)
     self.assertIsNotNone(user.profile.contact_info)
     self.assertIsNotNone(user.calendar)
Пример #35
0
	def __init__(self, contactId = None, request = None):
		"""
		contactId - numeric representation of contact id
		"""
		contact = None
		if contactId is not None:
			contact = Contact.get(id=contactId)
		#get formsets for every possible form
		self.formsets = []
		for s, formClass in self.FormClassObjects:
			initial = []
			if contact is None:
				initial = getattr(formClass, 'formsetInitial', None)
			classFormSet = self.getFormSet(formClass, contact=contact, initial=initial, request=request)	
			classFormSet.formsetTitle = formClass.formsetTitle
			#self.formsets[formClass.__name__[0].lower() + formClass.__name__[1:] + 'Set'] = classFormSet
			self.formsets.append(classFormSet)
Пример #36
0
def submitcontact(request):
    try:
        profiles = Profile.objects.get(user=request.user)
        internalmails_short = InternalMail.objects.filter(user=request.user)[0:3]
    except:
        return  HttpResponseRedirect('/accounts/login/')

    iid = id_generator() + id_generator()
    contacts = Contact()
    contacts.full_name = request.POST['full_name']
    contacts.organization = request.POST['organization']
    contacts.email = request.POST['email']
    contacts.message = request.POST['message']
    contacts.iid = iid
    contacts.save()

    message = "Your message has been submitted !"
    request.session['message'] = message

    return  HttpResponseRedirect('/accounts/profile/')
Пример #37
0
def add_contact():
    c = Contact()
    c.name = 'me'
    c.address  = 'here'
    c.phone = '42'
    c.save()
Пример #38
0
def send(request):
    name = request.POST['name']
    email = request.POST['email']
    phone = request.POST['phone']
    message = request.POST['message']
    ip = request.META.get('REMOTE_ADDR')
    country = ""
    city = ""
    os = ""

    if not name or name == "Name":
        return HttpResponse("no_name")

    if not email or email == "E-mail":
        return HttpResponse("no_email")

    try:
        validate_email(email)
    except:
        return HttpResponse("no_valid_email")

    if not phone or phone == "Phone":
        return HttpResponse("no_phone")

    if not message or message == "Message":
        return HttpResponse("no_message")

    try:
        my_email = '*****@*****.**'
        subject = 'New contact!'
        html = "Name: " + name
        html = html + "<br>E-mail: " + email
        html = html + "<br>Phone: " + phone
        html = html + "<br><br>" + message
        _send_email(my_email, subject, html)
        email_feedback = "sent"

    except: 
        email_feedback = "error"

    try:
        contact = Contact()
        contact.name = name
        contact.email = email
        contact.phone = phone
        contact.message = message
        contact.ip = ip
        contact.country = country
        contact.city = city
        contact.os = os
        contact.email_feedback = email_feedback
        contact.date = datetime.now()
        contact.save()

        return HttpResponse("saved")

    except:
        return HttpResponse("error")
Пример #39
0
def pretty_print(value):
    return Contact.pretty_print(value)