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


Python Contact.name方法代码示例

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


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

示例1: create

# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import name [as 别名]
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,代码行数:36,代码来源:views.py

示例2: add_contact

# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import name [as 别名]
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,代码行数:28,代码来源:functions.py

示例3: create

# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import name [as 别名]
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
        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()
            print new_contact.name.first_name, new_contact.name.last_name
            flash_string = '<a href="/{}">{} {}</a> was added to the database.'
            print flash_string
            flash_string = flash_string.format(
                new_contact.email, new_contact.name.first_name, new_contact.name.last_name
            )
            flash(Markup(flash_string))
            return redirect(url_for("index"))
        except Exception as e:
            print "Errors in the form"
            flash("There were errors in the form.  Specifically, " + e.message)

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

示例4: parse_contacts

# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import name [as 别名]
    def parse_contacts(self, contacts):
        "Break down CSV file into fields"

        for row in contacts:

            # Tidy up keys (iterkeys strip())

            try:
                type = row['type']
            except Exception:
                pass  # Set type to default type

            try:
                name = row['name']
            except Exception:
                try:
                    firstname = row['firstname']
                    surname = row['surname']
                    name = firstname + " " + surname
                except Exception:
                    continue

            contact_type = ContactType.objects.filter(name=type)
            if contact_type:
                contact_type = contact_type[0]

            # Create a new contact if it doesn't exist
            contact_exists = Contact.objects.filter(
                name=name, contact_type__name=type, trash=False)

            # TODO: If one does exist then append the data on that contact

            if not contact_exists:

                contact = Contact()
                contact.name = name
                contact.contact_type = contact_type
                contact.auto_notify = False
                contact.save()

                fields = contact_type.fields.filter(trash=False)

                for field in fields:
                    if field.name in row:
                        x = row[field.name]
                        if field.field_type == 'email':
                            x = self.verify_email(x)
                        if field.field_type == 'url':
                            x = self.verify_url(x)
                        if x:
                            contact_value = ContactValue()
                            contact_value.field = field
                            contact_value.contact = contact
                            contact_value.value = x
                            contact_value.save()
开发者ID:tovmeod,项目名称:anaf,代码行数:57,代码来源:csvapi.py

示例5: import_csv

# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import name [as 别名]
    def import_csv(self):
        data = self._data()
        contact_mgr = ContactManager(self.user.key)
        index = data["file"].find('base64,') + 7
        csv_string = data["file"][index:].decode('base64')

        f = StringIO.StringIO(csv_string)
        contacts = csv.DictReader(f)
        for contact_data in contacts:
            contact = Contact()
            contact.name = contact_data['name']
            contact.email = contact_data['email']
            contact.phone = contact_data['phone']
            contact_mgr.add_or_update_contact(contact)

        return True
开发者ID:xplot,项目名称:imeet,代码行数:18,代码来源:contacts.py

示例6: create

# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import name [as 别名]
def create(request):
    
    list = []
    success = True
    message = '' 

    if not request.POST:
        return 
    
    dataList = json.loads(request.POST.keys()[0])['data']
    if type(dataList).__name__=='dict':
        dataList = [dataList]
        
    for data in dataList: 

        if  existContact( data['name'] ):
#           message = 'El registro ya existe'
            data['_ptStatus'] =  ERR_EXIST
            list.append( data )
        else:  
    
            contact = Contact()
            contact.name = data['name']
            contact.phone = data['phone']
            contact.email = data['email'] 
            
            if not contact.email.__contains__('@'):
                contact.email += '@123.aa'
    
            try:
                contact.save()
                data = model_to_dict(contact, fields=[field.name for field in contact._meta.fields])
                list.append( data )
                
            except: 
                data['_ptStatus'] =  ERR_ADD
                list.append( data )
#               message = 'Error al crear registro'
                
        
    context = {
        'total': list.__len__(),
        'data': list,
        'success': success, 
        'message' : message 
    }
    return HttpResponse(json.dumps(context), mimetype="application/json")
开发者ID:edugasser,项目名称:misEjemplos,代码行数:49,代码来源:views.py

示例7: execute

# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import name [as 别名]
    def execute(self):
        contact = None

        if self.unique_id:
            contact = Contact.get_by_unique_id(self.unique_id)
        else:
            contact = Contact(
                unique_id=guid()
            )

        contact.user = self.user
        contact.name = self.name
        contact.phone = self.phone
        contact.email = self.email

        contact.put()
        return contact.unique_id
开发者ID:xplot,项目名称:imeet,代码行数:19,代码来源:UpdateOrCreateContactCommand.py

示例8: execute

# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import name [as 别名]
    def execute(self):
        invite_attendee = None
        if self.invite_attendee_id:
            invite_attendee = InviteAttendee.get_by_unique_id(self.invite_attendee_id)
        else:
            invite_attendee = InviteAttendee(
                unique_id=guid()
            )

        invite_attendee.name = self.name
        invite_attendee.email = self.email
        invite_attendee.phone = self.phone

        contact = None

        if self.user and self.unique_id:
            contact = Contact.get_by_unique_id(
                self.unique_id
            )

        elif self.user:
            contact = Contact(
                unique_id=guid(),
                user=self.user
            )

        # Here we update the contact with the appropiate Data
        if contact:
            invite_attendee.contact = contact.key
            contact.name = self.name
            contact.email = self.email
            contact.phone = self.phone
            contact.put()

        invite = Invite.get_by_unique_id(self.invite_id)
        invite_attendee.invite = invite.key

        invite_attendee.put()
        return invite_attendee.unique_id
开发者ID:xplot,项目名称:imeet,代码行数:41,代码来源:UpdateAttendeeAttachToContactCommand.py

示例9: import_contacts

# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import name [as 别名]
    def import_contacts(self):
        form = ContactImportForm()
        if request.method == 'GET':
            return self.render('contact_import.html', form=form)

        else:
            form = ContactImportForm()
            if form.validate_on_submit():
                data = form.filename.data.readlines()
                imported = 0
                for line in data:
                    line = line.split(',')
                    c = Contact()
                    c.phone = line[0]
                    c.name = line[1].decode('utf-8')
                    db.session.add(c)
                    imported += 1
                db.session.commit()
                flash(gettext('Imported %(num)s contacts.', num=imported))
                return redirect(url_for('.index_view'))

            else:
                return self.render('contact_import.html', form=form)
开发者ID:jdevel,项目名称:astconfman,代码行数:25,代码来源:views.py

示例10: save

# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import name [as 别名]
    def save(self, request, contact_type=None):
        "Process form and create DB objects as required"
        if self.instance:
            contact = self.instance
        else:
            contact = Contact()
            contact.contact_type = contact_type

        contact.name = unicode(self.cleaned_data['name'])

        if 'parent' in self.cleaned_data:
            contact.parent = self.cleaned_data['parent']

        if 'related_user' in self.cleaned_data:
            contact.related_user = self.cleaned_data['related_user']

        contact.save()

        if self.instance:
            contact.contactvalue_set.all().delete()
        for field in contact.contact_type.fields.all():
            for form_name in self.cleaned_data:
                if re.match(str("^" + field.name + "___\d+$"), form_name):
                    if isinstance(self.fields[form_name], forms.FileField):
                        value = ContactValue(field=field, contact=contact,
                                             value=self._handle_uploaded_file(form_name))
                        if isinstance(self.fields[form_name], forms.ImageField):
                            self._image_resize(value.value)
                    else:
                        if field.field_type == 'picture' and isinstance(self.fields[form_name], forms.ChoiceField) and \
                                        self.cleaned_data[form_name] != 'delete':
                            value = ContactValue(field=field, contact=contact, value=self.cleaned_data[form_name])
                        else:
                            value = ContactValue(field=field, contact=contact, value=self.cleaned_data[form_name])
                    value.save()
        return contact
开发者ID:tovmeod,项目名称:anaf,代码行数:38,代码来源:forms.py

示例11: _do_sync

# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import name [as 别名]
def _do_sync(data, user):
    "Run updates"

    resource_id = data.info.application.id.raw

    contact_type = _get_contact_type(user)

    for item in data.result:
        item_id = None
        if 'id' in item.raw:
            item_id = item.id.raw
        dups = _find_duplicates(resource_id, item, user)
        if dups:
            for contact in dups:
                transaction.commit()
                try:
                    fields = contact.contact_type.fields
                    contact.add_nuvius_resource(resource_id, item_id)
                    if item.name.raw:
                        contact.name = item.name.raw
                    if item.email:
                        fs = fields.filter(field_type='email')
                        if fs:
                            for iemail in item.email:
                                values = contact.contactvalue_set.filter(
                                    field__in=fs, value=iemail.raw)
                                if not values:
                                    value = ContactValue(
                                        contact=contact, field=fs[0], value=iemail.raw)
                                    value.save()
                    if item.phone:
                        fs = fields.filter(field_type='phone')
                        if fs:
                            for iphone in item.phone:
                                values = contact.contactvalue_set.filter(
                                    field__in=fs, value=iphone.raw)
                                if not values:
                                    value = ContactValue(
                                        contact=contact, field=fs[0], value=iphone.raw)
                                    value.save()

                    if item.address:
                        fs = fields.filter(name='address')
                        if fs:
                            for iaddress in item.address:
                                values = contact.contactvalue_set.filter(
                                    field__in=fs, value__icontains=iaddress.raw)
                                if not values:
                                    value = ContactValue(
                                        contact=contact, field=fs[0], value=iaddress.raw)
                                    value.save()
                    if item.website:
                        fs = fields.filter(name='website')
                        if fs:
                            for iwebsite in item.website:
                                values = contact.contactvalue_set.filter(
                                    field__in=fs, value__icontains=iwebsite.raw)
                                if not values:
                                    value = ContactValue(
                                        contact=contact, field=fs[0], value=iwebsite.raw)
                                    value.save()
                    contact.auto_notify = False
                    contact.save()
                    transaction.commit()
                except KeyboardInterrupt:
                    transaction.rollback()
                    break
                except:
                    transaction.rollback()
        else:
            if contact_type and item.name.raw:
                transaction.commit()
                try:
                    contact = Contact(contact_type=contact_type)
                    contact.add_nuvius_resource(resource_id, item_id)
                    contact.name = item.name.raw
                    contact.auto_notify = False
                    contact.set_user(user)
                    contact.save()
                    fields = contact_type.fields
                    if item.email:
                        fs = fields.filter(field_type='email')
                        if fs:
                            for iemail in item.email:
                                value = ContactValue(
                                    contact=contact, field=fs[0], value=iemail.raw)
                                value.save()
                    if item.phone:
                        fs = fields.filter(field_type='phone')
                        if fs:
                            for iphone in item.phone:
                                value = ContactValue(
                                    contact=contact, field=fs[0], value=iphone.raw)
                                value.save()
                    if item.address:
                        fs = fields.filter(name='address')
                        if fs:
                            for iaddress in item.address:
                                value = ContactValue(
                                    contact=contact, field=fs[0], value=iaddress.raw)
#.........这里部分代码省略.........
开发者ID:tovmeod,项目名称:anaf,代码行数:103,代码来源:integration.py


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