本文整理汇总了Python中members.models.Member.num方法的典型用法代码示例。如果您正苦于以下问题:Python Member.num方法的具体用法?Python Member.num怎么用?Python Member.num使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类members.models.Member
的用法示例。
在下文中一共展示了Member.num方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: import_data
# 需要导入模块: from members.models import Member [as 别名]
# 或者: from members.models.Member import num [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