#!/usr/bin/env python3 import cgi import pymysql import connect import setdefault if setdefault.check() == False: redirectURL = "/cgi-bin/login.py" print("Content-type: text/html") print() print('<html><head><meta http-equiv="refresh" content="0;url=' + str(redirectURL) + '" /></head></html>') con = connect.con cur = connect.cur default = setdefault.init() content = """ <form action="addpost.py" method="POST" enctype='multipart/form-data'> <div style = "display: inline-block;vertical-align: top;"> <p>Полное имя</p> <input type="text" style = "width: 50em;" name = "name"> <p>Напишите немного о нем</p> <textarea name="description" style="width: 50em;height: 50em;"></textarea> <br> <input type = "submit"> </div> <div style = "display: inline-block; vertical-align: top;"> <img id = "preview" src='/cats.JPG' alt = ''><br> <input id = "id_files" type = 'file' name = 'img' accept='image/png'><br> </div> </form>
</tr><tr><td> Общая оценка\t </td><td> 1 <input type="radio" name="assessment" value=1> 2 <input type="radio" name="assessment" value=2> 3 <input type="radio" name="assessment" value=3> 4 <input type="radio" name="assessment" value=4> 5 <input type="radio" name="assessment" value=5> {7} ({12} голосов) </td> </tr> </table> <input type = "submit" value = "Проголосовать"> </form> </div> """.format(teacherinfo[1], teacherinfo[2], teacherid, knowledge, skill, communication, free, assessment, knowledgecount, skillcount, communicationcount, freecount, assessmentcount) if setdefault.check() == True : userid = setdefault.getuserid() for row in assessments : if row[1] == userid : if row[3] != None : name = "knowledge" value = row[3] content = content.replace("""<input type="radio" name="{0}" value={1}>""".format(name, value), """<input type="radio" name="{0}" value={1} checked>""".format(name, value)) if row[4] != None : name = "skill" value = row[4] content = content.replace("""<input type="radio" name="{0}" value={1}>""".format(name, value), """<input type="radio" name="{0}" value={1} checked>""".format(name, value)) if row[5] != None : name = "communication" value = row[5] content = content.replace("""<input type="radio" name="{0}" value={1}>""".format(name, value), """<input type="radio" name="{0}" value={1} checked>""".format(name, value))