コード例 #1
0
def display_visas(person):
    visas = Visa.get_visas([person])
    if visas.count() > 1:
        result = '<a href="%s">More than one visa found</a>' % reverse(
            'visas:list_all_visas',
            kwargs={'emplid': person.userid_or_emplid()})
        return mark_safe(result)

    elif visas.count() == 0:
        result = '<a href="%s">No visa found</a>' % reverse(
            'visas:new_visa', kwargs={'emplid': person.userid_or_emplid()})
        return mark_safe(result)

    elif visas.count() == 1:
        visa = visas[0]

        result = [
            '<a href="',
            reverse('visas:edit_visa', kwargs={'visa_id': visa.id}), '" ',
            e(add_visa_display_class(visa)), '>',
            e(visa.status), ' valid from ',
            e(unicode(visa.start_date)), ' until ',
            e(unicode(visa.end_date)), ' -- ',
            e(visa.get_validity()), '</a>'
        ]
        return mark_safe(''.join(result))

    else:
        return "Undefined visa error, please contact support."
コード例 #2
0
ファイル: queries.py プロジェクト: avacariu/coursys
def more_offering_info(offering, browse_data=False, offering_effdt=False):
    """
    More info about a course offering (for the course browser) 
    """
    db = SIMSConn()
    req_map = get_reqmnt_designtn()

    data = {}
    crse_id = "%06i" % (offering.crse_id)
    eff_where = ''
    if offering_effdt:
        effdt = offering.semester.start
        eff_where = "AND effdt<=%s" % (db.escape_arg(effdt.isoformat()))

    db.execute("""
        SELECT descr, ssr_component, course_title_long, descrlong
        FROM ps_crse_catalog
        WHERE eff_status='A' AND crse_id=%s """ + eff_where + """
        ORDER BY effdt DESC FETCH FIRST 1 ROWS ONLY""", (crse_id,))
    for shorttitle, component, longtitle, descrlong in db:
        data['shorttitle'] = e(shorttitle)
        data['component'] = e(component)
        data['longtitle'] = e(longtitle)
        data['descrlong'] = e(descrlong)
        #data['rqmnt_designtn'] = e(req_map.get(rqmnt_designtn, 'none'))

    if browse_data and 'shorttitle' in data:
        del data['shorttitle']
    
    if not data:
        return None

    return data
コード例 #3
0
def display_visas(person):
    visas = Visa.get_visas([person])
    if visas.count() > 1:
        result = '<a href="%s">More than one visa found</a>' % reverse('visas:list_all_visas', kwargs={'emplid':person.userid_or_emplid()})
        return mark_safe(result)

    elif visas.count() == 0:
        result = '<a href="%s">No visa found</a>' % reverse('visas:new_visa', kwargs={'emplid':person.userid_or_emplid()})
        return mark_safe(result)

    elif visas.count() == 1:
        visa = visas[0]

        result = ['<a href="', reverse('visas:edit_visa', kwargs={'visa_id': visa.id}), '" ',
                  e(add_visa_display_class(visa)),'>', e(visa.status),' valid from ', e(str(visa.start_date)), ' until ',
                  e(str(visa.end_date)), ' -- ', e(visa.get_validity()), '</a>']
        return mark_safe(''.join(result))

    else:
        return "Undefined visa error, please contact support."
コード例 #4
0
def a_tag(con, href='#', style=''):
    return '<a href="%s" style="%s">%s</a>' % (href, style, e(con))
コード例 #5
0
    def format_file_operation(self, ev):
        lib_link = a_tag(ev.repo_name, repo_url(ev.repo_id, ev.repo_name))
        small_lib_link = a_tag(ev.repo_name, repo_url(ev.repo_id,
                                                      ev.repo_name),
                               'color:#868e96;font-size:87.5%;')
        if ev.obj_type == 'repo':
            if ev.op_type == 'create':
                op = _('Created library')
                details = td(lib_link)
            elif ev.op_type == 'rename':
                op = _('Renamed library')
                details = td('%s => %s' % (e(ev.old_repo_name), lib_link))
            elif ev.op_type == 'delete':
                op = _('Deleted library')
                details = td(e(ev.repo_name))
            elif ev.op_type == 'recover':
                op = _('Restored library')
                details = td(lib_link)
            else:  # ev.op_type == 'clean-up-trash':
                if ev.days == 0:
                    op = _('Removed all items from trash.')
                else:
                    op = _('Removed items older than %s days from trash.' %
                           ev.days)
                details = td(lib_link)

        elif ev.obj_type == 'file':
            file_name = os.path.basename(ev.path)
            file_link = a_tag(file_name, file_url(ev.repo_id, ev.path))
            if ev.op_type == 'create':
                op = _('Created file')
                details = td("%s<br />%s" % (file_link, small_lib_link))
            elif ev.op_type == 'delete':
                op = _('Deleted file')
                details = td("%s<br />%s" % (e(file_name), small_lib_link))
            elif ev.op_type == 'recover':
                op = _('Restored file')
                details = td("%s<br />%s" % (file_link, small_lib_link))
            elif ev.op_type == 'rename':
                op = _('Renamed file')
                old_name = os.path.basename(ev.old_path)
                details = td("%s => %s<br />%s" %
                             (e(old_name), file_link, small_lib_link))
            elif ev.op_type == 'move':
                op = _('Moved file')
                file_path_link = a_tag(ev.path, file_url(ev.repo_id, ev.path))
                details = td('%s => %s<br />%s' %
                             (e(ev.old_path), file_path_link, small_lib_link))
            else:  # ev.op_type == 'edit':
                op = _('Updated file')
                details = td("%s<br />%s" % (file_link, small_lib_link))

        else:  # dir
            dir_name = os.path.basename(ev.path)
            dir_link = a_tag(dir_name,
                             dir_url(ev.repo_id, ev.repo_name, ev.path))
            if ev.op_type == 'create':
                op = _('Created folder')
                details = td('%s<br />%s' % (dir_link, small_lib_link))
            elif ev.op_type == 'delete':
                op = _('Deleted folder')
                details = td('%s<br />%s' % (e(dir_name), small_lib_link))
            elif ev.op_type == 'recover':
                op = _('Restored folder')
                details = td('%s<br />%s' % (dir_link, small_lib_link))
            elif ev.op_type == 'rename':
                op = _('Renamed folder')
                old_name = os.path.basename(ev.old_path)
                details = td('%s => %s<br />%s' %
                             (e(old_name), dir_link, small_lib_link))
            else:  # ev.op_type == 'move':
                op = _('Moved folder')
                details = td('%s => %s<br />%s' %
                             (e(ev.old_path), dir_link, small_lib_link))

        return (op, details)
コード例 #6
0
ファイル: send_file_updates.py プロジェクト: haiwen/seahub
def a_tag(con, href='#', style=''):
    return '<a href="%s" style="%s">%s</a>' % (href, style, e(con))
コード例 #7
0
ファイル: send_file_updates.py プロジェクト: haiwen/seahub
    def format_file_operation(self, ev):
        lib_link = a_tag(ev.repo_name, repo_url(ev.repo_id, ev.repo_name))
        small_lib_link = a_tag(ev.repo_name, repo_url(ev.repo_id, ev.repo_name), 'color:#868e96;font-size:87.5%;')
        if ev.obj_type == 'repo':
            if ev.op_type == 'create':
                op = _('Created library')
                details = td(lib_link)
            elif ev.op_type == 'rename':
                op = _('Renamed library')
                details = td('%s => %s' % (e(ev.old_repo_name), lib_link))
            elif ev.op_type == 'delete':
                op = _('Deleted library')
                details = td(e(ev.repo_name))
            elif ev.op_type == 'recover':
                op = _('Restored library')
                details = td(lib_link)
            else:  # ev.op_type == 'clean-up-trash':
                if ev.days == 0:
                    op = _('Removed all items from trash.')
                else:
                    op = _('Removed items older than %s days from trash.' %
                           ev.days)
                details = td(lib_link)

        elif ev.obj_type == 'file':
            file_name = os.path.basename(ev.path)
            file_link = a_tag(file_name, file_url(ev.repo_id, ev.path))
            if ev.op_type == 'create':
                op = _('Created file')
                details = td("%s<br />%s" % (file_link, small_lib_link))
            elif ev.op_type == 'delete':
                op = _('Deleted file')
                details = td("%s<br />%s" % (e(file_name), small_lib_link))
            elif ev.op_type == 'recover':
                op = _('Restored file')
                details = td("%s<br />%s" % (file_link, small_lib_link))
            elif ev.op_type == 'rename':
                op = _('Renamed file')
                old_name = os.path.basename(ev.old_path)
                details = td("%s => %s<br />%s" % (
                    e(old_name), file_link, small_lib_link)
                )
            elif ev.op_type == 'move':
                op = _('Moved file')
                file_path_link = a_tag(ev.path, file_url(ev.repo_id, ev.path))
                details = td('%s => %s<br />%s' % (
                    e(ev.old_path), file_path_link, small_lib_link)
                )
            else:  # ev.op_type == 'edit':
                op = _('Updated file')
                details = td("%s<br />%s" % (file_link, small_lib_link))

        else:                   # dir
            dir_name = os.path.basename(ev.path)
            dir_link = a_tag(dir_name, dir_url(ev.repo_id, ev.repo_name, ev.path))
            if ev.op_type == 'create':
                op = _('Created folder')
                details = td('%s<br />%s' % (dir_link, small_lib_link))
            elif ev.op_type == 'delete':
                op = _('Deleted folder')
                details = td('%s<br />%s' % (e(dir_name), small_lib_link))
            elif ev.op_type == 'recover':
                op = _('Restored folder')
                details = td('%s<br />%s' % (dir_link, small_lib_link))
            elif ev.op_type == 'rename':
                op = _('Renamed folder')
                old_name = os.path.basename(ev.old_path)
                details = td('%s => %s<br />%s' % (e(old_name), dir_link,
                                                   small_lib_link))
            else:  # ev.op_type == 'move':
                op = _('Moved folder')
                details = td('%s => %s<br />%s' % (e(ev.old_path), dir_link,
                                                   small_lib_link))

        return (op, details)