• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.Contact类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: getDisplayNameAndContact

 def getDisplayNameAndContact(self, number):
     displayName = toPrettyNumber(number)
     
     # Find the XMPP user to send this from
     contact = Contact.getByPhoneNumber(number)
     if contact:
         displayName = contact.name
     else:
         contact = Contact.getDefaultSender()
         
     return (displayName, contact)
开发者ID:jwalton,项目名称:xmppvoicemail,代码行数:11,代码来源:xmppvoicemail.py


示例17: auth

def auth():
	i = ctx.request.input(phoneid='')
	phoneid = i.phoneid.strip()
	contact = Contact.find_first('where tel=?',phoneid)
	contact1 = Contact.find_first('where work_tel=?',phoneid)
	if contact:
		return dict(contact)
	elif contact1:
		return dict(contact1)
	else :
		raise APIResourceNotFoundError(phoneid,'failed')
开发者ID:longfan3,项目名称:contact,代码行数:11,代码来源:urls.py


示例18: post

    def post(self, request):
        try:
            print "Here about to create an add request"
            user_id = request.data["id"]
            user = User.objects.get(pk=user_id)
            Contact.create_add_request(from_user=request.user, for_user = user)

            return JSONResponse([], status=200)
        except Exception as e:
            beam(e, request)
            return JSONResponse(ERROR_MESSAGE, status=400)
开发者ID:trolltartar,项目名称:contagbackend,代码行数:11,代码来源:views.py


示例19: contactlist

def contactlist(id):
    contact = Contact.find_first("where id=?", id)
    if contact is None:
        raise notfound()
    contactlist = Contact.find_by("where groupid=? and year=? order by headman desc", contact.groupid, contact.year)
    print("------++++++--")
    if contactlist:
        print("----------------")
        return dict(contactlist=contactlist, group=contact.groupid)
    else:
        print("+++++++++++++++++")
        raise APIResourceNotFoundError(contact.groupid, "failed")
开发者ID:longfan3,项目名称:contact,代码行数:12,代码来源:urls.py


示例20: createContact

def createContact(request):#POST
    if request.method != 'POST':
        return JsonError( 'invalid message' ) 

    json_data = request.POST['contacts']
    data = json.loads(json_data)
    newContact = Contact()
    try:
        newContact.jsonToClass(data)
        newContact.save()
        return JsonSuccess( { 'message': 'Ok' } )
    except:
        return JsonError( 'Error on saving contact' )
开发者ID:victorette,项目名称:extjs_django_mvc,代码行数:13,代码来源:views.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.Corporation类代码示例发布时间:2022-05-27
下一篇:
Python models.Config类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap