def assigmentRate(assigment_id): """Úprava a obodování zadání""" usr = getUser() assigment = Assigment.get( assigment_id ) if not assigment: return HTTPError(404, "Cvičení nebylo nalezeno") #todo if ???: return HTTPError(403, "Nemáte oprávnění") if request.method == 'POST': action = request.forms.get("action") if (not action) or (not action in ("lock", "rate", "unlock")): HTTPError(400, "Neznámá akce") print("----------action", action) try: if action == "lock": assigment.lock() msg("Řešení bylo zamčeno", "success") elif action == "rate": assigment.rate( request.forms.get("points") ) msg("Řešení bylo ohodnoceno", "success") elif action == "unlock": assigment.unlock() msg("Řešení bylo odemčeno", "success") except ModelException as e: msg("Chyba při manipulaci: %s" %s, "error") redirect('/assigments-lector') return return template("assigments_rate", {"assigment" : assigment } )
def assigmentRate(assigment_id): """Úprava a obodování zadání""" usr = getUser() assigment = Assigment.get(assigment_id) if not assigment: return HTTPError(404, "Cvičení nebylo nalezeno") #todo if ???: return HTTPError(403, "Nemáte oprávnění") if request.method == 'POST': action = request.forms.get("action") if (not action) or (not action in ("lock", "rate", "unlock")): HTTPError(400, "Neznámá akce") print("----------action", action) try: if action == "lock": assigment.lock() msg("Řešení bylo zamčeno", "success") elif action == "rate": assigment.rate(request.forms.get("points")) msg("Řešení bylo ohodnoceno", "success") elif action == "unlock": assigment.unlock() msg("Řešení bylo odemčeno", "success") except ModelException as e: msg("Chyba při manipulaci: %s" % s, "error") redirect('/assigments-lector') return return template("assigments_rate", {"assigment": assigment})
def assigmentDownload(assigment_id): """Stažení zadání""" usr = getUser() assigment = Assigment.get( assigment_id ) if not assigment: return HTTPError(404, "Cvičení nebylo nalezeno") #todo if ???: return HTTPError(403, "Nemáte oprávnění") headers = {} headers['Content-Type'] = "text/txt" headers['Content-Disposition'] = 'attachment; filename="%s.asm"' % assigment.login data = assigment.response return HTTPResponse(data, **headers)
def assigmentDownload(assigment_id): """Stažení zadání""" usr = getUser() assigment = Assigment.get(assigment_id) if not assigment: return HTTPError(404, "Cvičení nebylo nalezeno") #todo if ???: return HTTPError(403, "Nemáte oprávnění") headers = {} headers['Content-Type'] = "text/txt" headers[ 'Content-Disposition'] = 'attachment; filename="%s.asm"' % assigment.login data = assigment.response return HTTPResponse(data, **headers)