コード例 #1
0
ファイル: pipeline.py プロジェクト: TimBest/ComposersCouch
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
コード例 #2
0
ファイル: test_contacts.py プロジェクト: kashenfelter/emerald
 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)
コード例 #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
ファイル: amazon.py プロジェクト: memobijou/erpghost
    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
コード例 #5
0
ファイル: views.py プロジェクト: HKSenior/portfolio
    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')
コード例 #6
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', "请求失败")
コード例 #7
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)
コード例 #8
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.save()
     return redirect('emergency:emergencyDetails_list')
コード例 #9
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
                })
コード例 #10
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.'})
コード例 #11
0
ファイル: views.py プロジェクト: ThePratikSah/django-contact
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')
コード例 #12
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)
コード例 #13
0
ファイル: app.py プロジェクト: pavlikus/govinda_farm
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)
コード例 #14
0
ファイル: test_contacts.py プロジェクト: kashenfelter/emerald
 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)
コード例 #15
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
            })
コード例 #16
0
ファイル: test_models.py プロジェクト: iDemandLiberty/site
 def test_changed_name_after_clean(self):
     c = Contact(**self.fields)
     c.full_clean()
     c.first_name = ''
     with self.assertRaises(ValidationError):
         c.full_clean()
     c.first_name = 'Baz'
     c.full_clean()
     c.save()
コード例 #17
0
ファイル: test_contacts.py プロジェクト: kashenfelter/emerald
    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)
コード例 #18
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
コード例 #19
0
 def save_new_supplier(self, billing_form, delivery_form):
     contact = Contact()
     billing_address = billing_form.save()
     delivery_address = delivery_form.save()
     contact.billing_address = billing_address
     contact.delivery_address = delivery_address
     contact.save()
     supplier = Supplier()
     supplier.contact = contact
     supplier.save()
コード例 #20
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')
コード例 #21
0
ファイル: views.py プロジェクト: memobijou/erpghost
 def save_new_customer(self, billing_form, delivery_form):
     contact = Contact()
     billing_address = billing_form.save()
     delivery_address = delivery_form.save()
     contact.billing_address = billing_address
     contact.delivery_address = delivery_address
     contact.save()
     customer = Customer()
     customer.contact = contact
     customer.save()
コード例 #22
0
def home(request):
    if request.method == 'POST':
        name = request.POST.get('name')
        email = request.POST.get('email')
        message = request.POST.get('message')

        contact = Contact()
        contact.name = name
        contact.email = email
        contact.message = message
        contact.save()
        return render(request, template_name='index.html')
    return render(request, template_name='index.html')
コード例 #23
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)
コード例 #24
0
ファイル: test_contacts.py プロジェクト: kashenfelter/emerald
    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)
コード例 #25
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})
コード例 #26
0
ファイル: views.py プロジェクト: suzan123634/ct_project
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')
コード例 #27
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....'
    })
コード例 #28
0
def showformdata(request):
   if request.method=="POST":
      fm = Registration(request.POST)

      name=request.POST["name"]
      email=request.POST["email"]
      password=request.POST["password"]
      note=request.POST["note"]

      obj=Contact(name="name",email="email",password="******",note="note")
      obj.save
      

   else:
      fm=Registration()

   return render(request,"contact.html",{'form':fm})
コード例 #29
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')
コード例 #30
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))