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


Python Member.title方法代码示例

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


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

示例1: import_data

# 需要导入模块: from members.models import Member [as 别名]
# 或者: from members.models.Member import title [as 别名]
def import_data(ty,data):
 
  nb=0
  ok = True
  errors = False
  for l in UnicodeDictReader(data,delimiter=';',quoting=csv.QUOTE_NONE):
    debug('upload',u'Line : '+str(l))

    Model = None
    if ty == 'members':  #import members
      try:
        Model = Member.objects.get(first_name=str(l['PRENOM']),last_name=str(l['NOM']),email=str(l['EMAIL']))
      except Member.DoesNotExist:
        Model = Member(
		first_name    = str(l['PRENOM']),
		last_name	= str(l['NOM']),
		address	= str(l['ADRESSE']),
		phone		= str(l['TEL']),
		mobile	= str(l['MOBILE']),
		email		= str(l['EMAIL'])
	)
        # create user
        U = create_user(Model.first_name,Model.last_name, Model.email)
        Model.user = U
        Model.save()
        nb+=1

    if ty == 'calendar': #import calendar
      deadline = timezone.make_aware(datetime.strptime(l['DATE'] + ' ' + l['HEURE'],"%Y-%m-%d %H:%M")-timedelta(hours=24),None)
      if l['TYPE'] == '0': #meeting
        debug('upload',u"it's a meeting")
        try:
          Model = Meeting.objects.get(when=str(l['DATE']),title=str(l['TITRE']))
        except Meeting.DoesNotExist:
          Model = Meeting(
		title  		= str(l['TITRE']),
		when		= str(l['DATE']),
		time		= str(l['HEURE']),
		deadline	= deadline,
	  )

      if l['TYPE'] == '1': #event
        debug('upload',u"it's an event")
        try:
          Model = Event.objects.get(when=str(l['DATE']),title=str(l['TITRE']))
        except Event.DoesNotExist:
          Model = Event (
		title  		= str(l['TITRE']),
		when		= str(l['DATE']),
		time		= str(l['HEURE']),
		deadline	= deadline,
	  )

      # check/create location
      location = None
      try:
        location = Location.objects.get(name=str(l['LIEU']))
      except Location.DoesNotExist:
        location = Location(name=str(l['LIEU']))
        location.save()

      Model.location = location
      if l['TYPE'] == '0':  #add num to meeting title
        latest = Meeting.objects.values().latest('num')
        next_num = latest['num'] + 1
        Model.num = next_num
        Model.title = str(next_num) + u'. ' + str(Model.title)
      Model.save()
      nb+=1

  if not ok: return errors
  else: return nb
开发者ID:psteichen,项目名称:aperta-cms,代码行数:74,代码来源:functions.py


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