当前位置: 首页>>代码示例>>Python>>正文


Python models.Contact类代码示例

本文整理汇总了Python中models.Contact的典型用法代码示例。如果您正苦于以下问题:Python Contact类的具体用法?Python Contact怎么用?Python Contact使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Contact类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: upload_contacts

def upload_contacts(request):
  if not request.user.is_authenticated():
    return HttpResponse('You are not logged in')
  if request.FILES.__contains__('csv'):
    rows = csv.reader(request.FILES['csv'])
    count = 0
    for row in rows:
      if count > 0 and len(row) == 11:
        contactExists = Contact.objects.filter(email=row[4]).count()
        if not contactExists:
          contact = Contact(
            first_name = row[0],
            last_name = row[1],
            phone = row[2],
            mobile = row[3],
            email = row[4],
            address = row[5],
            colony = row[6],
            city = row[7],
            zip_code = row[8],
            birth_date = row[10] if row[10] != '' else '1988-11-16',
            amount = '',
            period = '',
            payment = '',
            tax_info = ''
          )
          contact.save()
          if len(row[9]) > 0:
            for group in Group.objects.filter(id__in=row[9].split(' ')):
              contact.group.add(group)
          contact.save()
      count+=1
    return HttpResponseRedirect('/admin/impulso/contact/')
  return render('admin/upload.html', {}, context_instance = RequestContext(request))
开发者ID:jcebXD,项目名称:impulso,代码行数:34,代码来源:views.py

示例2: test_encoding_is_proper

 def test_encoding_is_proper(self):
     # test_str = unicode("✄", "utf-8")
     test_str = u"✄"
     name = Contact(first_name=test_str)
     name.save()
     name2 = Contact.objects.get(first_name=test_str)
     self.assertEqual(name.first_name, name2.first_name)
开发者ID:whorst,项目名称:Capstone,代码行数:7,代码来源:tests.py

示例3: test_contact_attributes

    def test_contact_attributes(self):
        source = Source.objects.get(slug="test")

        attributes = {
                'procedure' : 'test',
                'procedures_long' : 'long',
                'contact_by' : 'June 12',
                'best_call_time' : '12am',
                'hear_about_us' : 'magazine',
                'date_contacted' : 'july 1',
                'call_message' : 'hey there',
                'location' : 'none'
            }

        contact_params = {
                'name' : 'test',
                'address' : '123 fake st.',
                'city' : 'test city',
                'state' : 'state',
                'zip_code' : 'zip_code',
                'phone' : 'phone',
                'email' : 'email',
                'message' : 'test',
                'source' : source,
                'attributes' : simplejson.dumps(attributes)
                }

        contact = Contact(**contact_params)
        contact.save()


        assert contact.json_attributes == attributes, True

        assert contact.get_attribute("procedure") == "test", True
        assert contact.get_attribute("procedures_long") == "long", True
开发者ID:capacitr,项目名称:cap-contact-form,代码行数:35,代码来源:tests.py

示例4: setUp

    def setUp(self):
        # Set up Google App Engine testbed
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()
        self.testbed.init_app_identity_stub()

        self.contactNumber = "+16135551234"

        # Set up some handy constants
        self._APP_ID = app_identity.get_application_id()
        self.MAIL_SUFFIX = "@" + self._APP_ID + ".appspotmail.com"
        self.XMPP_SUFFIX = "@" + self._APP_ID + ".appspotchat.com"

        self.ownerPhoneNumber = "+16135554444"
        self.ownerJid = "[email protected]"
        self.ownerEmailAddress = "[email protected]"
        self.owner = Owner(self.ownerPhoneNumber, self.ownerJid, self.ownerEmailAddress)
        self.xmppvoicemail = XmppVoiceMail(self.owner)
        self.communications = self.xmppvoicemail._communications = CommunicationsFixture()

        # Subscribe the default sender.
        defaultSender = Contact.getDefaultSender()
        defaultSender.subscribed = True
        Contact.update(defaultSender)
开发者ID:jwalton,项目名称:xmppvoicemail,代码行数:26,代码来源:xmppvoicemail_test.py

示例5: send_invitation

def send_invitation(invitation):
  """
  """
  try:
    user = User.objects.get(email=invitation.email)
    message = "{0} added you to his contacts".format(
        invitation.sender.username)
    contact = Contact(owner=invitation.sender, user=user)
    contact.save()
    invitation.delete()
    return HttpResponseRedirect(contact.get_absolute_url())
  except User.DoesNotExist:
    message = """
{0} Invites you to join his contacts.
You can register on http://{1}/user/create_account/ \
if you want to accept his invitation""".format(
        invitation.sender.username,
        Site.objects.get_current().domain
        )
  send_mail('An invitation sent to you',
             message,
             invitation.sender,
             [invitation.email],
             fail_silently=False
             )
  return HttpResponseRedirect(invitation.get_absolute_url())
开发者ID:bilougit,项目名称:agenda,代码行数:26,代码来源:views.py

示例6: new

 def new(self, name, phone=None, fax=None):
     contact = Contact(
         name=name,
         phone=phone,
         fax=fax
     )
     contact.save()
     return serialize(contact, excludes=[re.compile(r'^datetime_'),])
开发者ID:Digitalxero,项目名称:simpleapi,代码行数:8,代码来源:handlers.py

示例7: setUp

 def setUp(self):
     u = User(username='phil',email_address='[email protected]')
     u.save()
     ct = Contact(first_name='tom',last_name='salfield',organisation='the-hub',email_address='[email protected]',location='islington',apply_msg='about me', find_out='through the grapevine',invited_by=u)
     ct.save()
     self.u = u
     self.ct = ct
     return
开发者ID:GunioRobot,项目名称:hubplus,代码行数:8,代码来源:tests.py

示例8: contactlist

def contactlist(id):
	contact = Contact.find_first('where id=?',id)
	if contact is None:
		raise notfound()
	contactlist = Contact.find_by('where groupid=?',contact.groupid)
	if contactlist:
		return dict(contactlist=contactlist,group=contact.groupid)
	else:
		raise APIResourceNotFoundError(contact.groupid,'failed')
开发者ID:longfan3,项目名称:contact,代码行数:9,代码来源:urls.py

示例9: create_task

def create_task():
    contact = Contact(
        firstName = request.json['firstName'],
        lastName = request.json['lastName'],
        bday = request.json['bday'],
        zodiac = request.json['zodiac']
    )
    contact.put()
    return redirect(url_for('index'))
开发者ID:levimoore,项目名称:Flask-Ember-GAE,代码行数:9,代码来源:main.py

示例10: createContact

 def createContact(self, subscribed):
     # Create a known contact
     c = Contact(
         name="mrtest",
         phoneNumber=self.contactNumber,
         normalizedPhoneNumber=phonenumberutils.toNormalizedNumber(self.contactNumber),
         subscribed=subscribed,
     )
     Contact.update(c)
开发者ID:jwalton,项目名称:xmppvoicemail,代码行数:9,代码来源:xmppvoicemail_test.py

示例11: test_model_contact

 def test_model_contact(self):
     """Test Contact model"""
     type = ContactType(name='Test', slug='test')
     type.save()
     obj = Contact(name='Test', contact_type=type)
     obj.save()
     self.assertEquals('Test', obj.name)
     self.assertNotEquals(obj.id, None)
     obj.delete()
开发者ID:tovmeod,项目名称:anaf,代码行数:9,代码来源:tests.py

示例12: contacts

def contacts(request):
	if request.method == "GET":
		contacts = Contact.objects.all()
		return HttpResponse(format_contacts(contacts), mimetype="application/json")
	elif request.method == "POST":
		contact = Contact()
		data = json.loads(request.raw_post_data)
		contact.fromRaw(data)
		contact.save()
		return HttpResponse(format_contacts([contact]), mimetype="application/json")
开发者ID:Lovestruck,项目名称:Contacts,代码行数:10,代码来源:views-django.py

示例13: done

    def done(self, form_list, **kwargs):

        new = Contact()
        #new.user = self.request.user
        for form in form_list:
            for k, v in form.cleaned_data.iteritems():
                setattr(new, k, v)
        new.save()

        return redirect('/users/')
开发者ID:liushu2000,项目名称:django-crispy-formwizard,代码行数:10,代码来源:views.py

示例14: create

def create():
    form = ContactForm()
    if form.validate_on_submit():
        new_contact = Contact()
        new_name = Name()
        new_contact.email = form.email.data
        new_name.first_name = form.first_name.data
        new_name.last_name = form.last_name.data
        new_contact.name = new_name
        new_contact.group = form.group.data
        new_contact.known_from = form.known_from.data
        new_contact.general_comment = form.general_note.data
        new_contact.current_status = form.status.data
        for language in form.languages.data:
            if language:
                new_contact.tags.append(language)
        other_tags = form.other_tags.data.replace(', ', ',').split(',')
        for tag in other_tags:
            new_contact.tags.append(tag)
        try:
            new_contact.save()
            flash_string = '<a href=\"/{}\">{} {}</a> was added to the database.'
            flash_string = flash_string.format(new_contact.email, new_contact.name.first_name,
                                               new_contact.name.last_name)
            flash(Markup(flash_string))
            update_p_dict()
            return redirect(url_for('index'))
        except NotUniqueError:
            msg = "That email address is already in use.  <a href=\"/" + form.email.data + "\">View Entry.</a>"
            form.email.errors.append(Markup(msg))
        except Exception as e:
            flash("There were database-raised errors in the form.  Specifically, " + e.message)

    return render_template('create_contact.html', form=form)
开发者ID:deecewan,项目名称:based,代码行数:34,代码来源:views.py

示例15: add_contact

def add_contact(data, instance_id=""):
    if instance_id:
        contact = Contact.get_by_id(int(instance_id))
    else:
        contact = Contact()

    if data["name"]:
        contact.name = data["name"]

    if data["contacts"]:
        if contact.contacts:
            contact.contacts.append(data["contacts"])
        else:
            contact.contacts = data["contacts"]

    if data["email"]:
        contact.email = data["email"]

    if data["facebook"]:
        contact.facebook = data["facebook"]

    if data["twitter"]:
        contact.twitter = data["twitter"]

    contact.put()
    return contact
开发者ID:albertpadin,项目名称:bangonph,代码行数:26,代码来源:functions.py


注:本文中的models.Contact类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。