本文整理汇总了Python中tablib.Dataset.append_col方法的典型用法代码示例。如果您正苦于以下问题:Python Dataset.append_col方法的具体用法?Python Dataset.append_col怎么用?Python Dataset.append_col使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tablib.Dataset
的用法示例。
在下文中一共展示了Dataset.append_col方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_dataset
# 需要导入模块: from tablib import Dataset [as 别名]
# 或者: from tablib.Dataset import append_col [as 别名]
def get_dataset(self):
dataset = Dataset()
# Prépare le fichier
dataset.append_col([
u('Date'),
u('Canton'),
u('Établissement'),
u('Emplacement'),
u('Heures'),
u('Nombre de qualifs'),
# Logistique
u('Moniteur +'),
u('Mauvais temps'),
u('Pommes'),
u('Total vélos'),
u('Total casques'),
u('Remarques'),
# Qualif
u('Classe'),
u('Enseignant'),
u('Moniteur 2'),
u('Moniteur 1'),
u('Moniteur 1'),
u('Nombre d\'élèves'),
u('Nombre de vélos'),
u('Nombre de casques'),
CATEGORY_CHOICE_A,
CATEGORY_CHOICE_B,
CATEGORY_CHOICE_C,
u('Intervenant'),
u('Remarques'),
])
session = self.object
session_place = session.place
if not session_place:
session_place = (
session.address_city if session.address_city
else session.organization.address_city
)
col = [
date(session.day),
session.organization.address_canton,
session.organization.name,
session_place,
'%s - %s' % (time(session.begin), time(session.end)),
session.n_qualifications,
EXPORT_NAMETEL.format(
name=session.superleader.get_full_name(),
tel=session.superleader.profile.natel
) if session.superleader else '',
str(session.fallback),
session.apples,
session.n_bikes,
session.n_helmets,
session.comments,
]
if session.n_qualifications:
for quali in session.qualifications.all():
if not len(col):
col = [''] * 12
col.append(quali.name)
col.append(
EXPORT_NAMETEL.format(
name=quali.class_teacher_fullname,
tel=quali.class_teacher_natel
) if quali.class_teacher_fullname else ''
)
col.append(
EXPORT_NAMETEL.format(
name=quali.leader.get_full_name(),
tel=quali.leader.profile.natel
) if quali.leader else ''
)
for i in range(2):
try:
helper = quali.helpers.all()[i]
col.append(
EXPORT_NAMETEL.format(
name=helper.get_full_name(),
tel=helper.profile.natel
) if helper else ''
)
except IndexError:
col.append('')
col.append(quali.n_participants)
col.append(quali.n_bikes)
col.append(quali.n_helmets)
col.append(
str(quali.activity_A) if quali.activity_A else '')
col.append(
str(quali.activity_B) if quali.activity_B else '')
col.append(
str(quali.activity_C) if quali.activity_C else '')
col.append(
EXPORT_NAMETEL.format(
name=quali.actor.get_full_name(),
tel=quali.actor.profile.natel
) if quali.actor else ''
)
col.append(quali.comments)
#.........这里部分代码省略.........
示例2: get_dataset
# 需要导入模块: from tablib import Dataset [as 别名]
# 或者: from tablib.Dataset import append_col [as 别名]
def get_dataset(self):
dataset = Dataset()
firstcol = [
u('Date'),
u('Canton'),
u('Établissement'),
u('Emplacement'),
u('Heures'),
u('Nombre de qualifs'),
]
# Trouve toutes les personnes qui sont présentes dans cette saison
qs = get_user_model().objects
user_filter = [
# Moniteurs +
Q(sess_monplus__in=self.season.sessions_with_qualifs),
# Moniteurs 2
Q(qualifs_mon2__session__in=self.season.sessions_with_qualifs),
# Moniteurs 1
Q(qualifs_mon1__session__in=self.season.sessions_with_qualifs),
# Intervenants
Q(qualifs_actor__session__in=self.season.sessions_with_qualifs),
]
qs = (
qs.filter(reduce(operator.or_, user_filter))
.distinct()
.order_by('first_name', 'last_name')
)
firstcol += [user.get_full_name() for user in qs]
dataset.append_col(firstcol)
for session in self.season.sessions_with_qualifs:
session_place = session.place
if not session_place:
session_place = (
session.address_city if session.address_city
else session.organization.address_city
)
col = [
date(session.day),
session.organization.address_canton,
session.organization.name,
session_place,
'%s - %s' % (time(session.begin), time(session.end)),
session.n_qualifications,
]
for user in qs:
label = ''
if user == session.superleader:
# Translators: Nom court pour 'Moniteur +'
label = u('M+')
else:
for quali in session.qualifications.all():
if user == quali.leader:
# Translators: Nom court pour 'Moniteur 2'
label = u('M2')
break
elif user in quali.helpers.all():
# Translators: Nom court pour 'Moniteur 1'
label = u('M1')
break
elif user == quali.actor:
# Translators: Nom court pour 'Intervenant'
label = u('I')
break
col += [label]
dataset.append_col(col)
return dataset