當前位置: 首頁>>代碼示例>>Python>>正文


Python User.email_by_id方法代碼示例

本文整理匯總了Python中server.models.User.email_by_id方法的典型用法代碼示例。如果您正苦於以下問題:Python User.email_by_id方法的具體用法?Python User.email_by_id怎麽用?Python User.email_by_id使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在server.models.User的用法示例。


在下文中一共展示了User.email_by_id方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: write_final_submission

# 需要導入模塊: from server.models import User [as 別名]
# 或者: from server.models.User import email_by_id [as 別名]
def write_final_submission(zf, logger, assignment, student, seen, anonymize):
    """ Get the final submission STUDENT and write it into the zipfile ZF. """
    student_user = student.user
    stats = assignment.user_status(student_user)
    backup = stats.final_subm
    if not backup:
        return
    if stats.group:
        group_emails = [User.email_by_id(m.user_id) for m in stats.group.members]
    else:
        group_emails = [student_user.email]

    group_str = '-'.join(sorted(group_emails))
    if group_str in seen:
        return
    seen.add(group_str)

    course = assignment.course
    files = backup.files()

    if anonymize:
        for email in group_emails:
            if pii_present(files, email, assignment.course, logger):
                return
        identifier = '-'.join(sorted([student_hash(e) for e in group_emails]))
        folder = "{}/{}/".format(assignment.name.replace('/', '-'), identifier)
    else:
        folder = "{}/{}/{}".format(assignment.name.replace('/', '-'),
                                   group_str, backup.hashid)
        dump_info = {
            'group': group_emails,
            'scores': [s.export for s in stats.scores],
            'submitter': User.email_by_id(backup.submitter_id),
            'subm_time_local': local_time(stats.subm_time, course)
        }
        if backup.custom_submission_time:
            dump_info['custom_time_local'] = local_time(backup.custom_submission_time,
                                                        course)

        zf.writestr("{}/info.json".format(folder), json.dumps(dump_info))

    for name, contents in files.items():
        # Write the file to the in-memory zip
        zf.writestr("{}/{}".format(folder, name), contents)
開發者ID:Cal-CS-61A-Staff,項目名稱:ok,代碼行數:46,代碼來源:export.py


注:本文中的server.models.User.email_by_id方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。