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


Python Member.location方法代码示例

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


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

示例1: import_data

# 需要导入模块: from members.models import Member [as 别名]
# 或者: from members.models.Member import location [as 别名]
def import_data(ty,data):

#TODO

  error = False
#  for line in csv.DictReader(data,delimiter='\t',quoting=csv.QUOTE_NONE):
  for l in csv.DictReader(data.read().splitlines(),delimiter=';',quoting=csv.QUOTE_NONE):
#  for line in c_data:
#    l = findall(r'\"(.+?)\"',str(line))
#  for line in c_data:
#    l = findall(r'\"(.+?)\"',str(line))

    Model = None
    try:
      if ty == "members":
#       Model = Member.objects.get(first_name=l[1],last_name=l[0],email=l[6])
        Model = Member.objects.get(first_name=unicode(l['VIRNUMM']),last_name=unicode(l['NUMM']),email=unicode(l['EMAIL']))
      if ty == "calendar": Model = Meeting.objects.get(title=unicode(l[0]),when=unicode(l[1]),time=unicode(l[2]))
    except:
      if ty == "members":
        A = Address (
                address         = unicode(l['ADRESS']),
                postal_code     = unicode(l['CP']),
                location        = unicode(l['DUERF']),
                country         = unicode(l['LAND'])
        )
        Model = Member (
                        first_name      = unicode(l['VIRNUMM']),
                        last_name       = unicode(l['NUMM']),
                        address         = A,
                        email           = unicode(l['EMAIL'])
                )
        # create user
        user = User.objects.create_user(gen_username(Model.first_name,Model.last_name), Model.email, make_password(gen_random_password()))
        Model.user = user
      if ty == "calendar":
        Model = Meeting (
                        title           = unicode(l[0]),
                        when            = unicode(l[1]),
                        time            = unicode(l[2])
                )

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

        Model.location = location

      Model.save()

  return error
开发者ID:psteichen,项目名称:clusil-intranet,代码行数:56,代码来源:functions.py

示例2: import_data

# 需要导入模块: from members.models import Member [as 别名]
# 或者: from members.models.Member import location [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.location方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。