fixes to academic information, dropdown menus
This commit is contained in:
parent
ef219832f1
commit
6e4ae4b419
@ -9,13 +9,13 @@ class Distribusis(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
distribusiname = db.Column(db.String(300), nullable=True, unique=True)
|
||||
userid = db.Column(db.Integer, db.ForeignKey("users.id"))
|
||||
term = db.Column(db.Integer, nullable=False, unique=False)
|
||||
term = db.Column(db.String(5), nullable=False, unique=False)
|
||||
course = db.Column(db.String(500), nullable=True, unique=False)
|
||||
|
||||
# Academic year eg:2020-2021, so no need for a Datetime object
|
||||
year = db.Column(db.String(9), nullable=True, unique=False)
|
||||
tags = db.Column(db.String(500), nullable=True, unique=False)
|
||||
visible = db.Column(db.Boolean, server_default="false")
|
||||
visible = db.Column(db.Boolean, default=False)
|
||||
|
||||
def __repr__(self):
|
||||
return "<Distribusi %r>" % self.distribusiname
|
||||
|
@ -21,8 +21,19 @@ class UploadForm(FlaskForm):
|
||||
"Academic year:",
|
||||
validators=[validators.InputRequired(), Length(9, 10)],
|
||||
)
|
||||
term = IntegerField(
|
||||
"Term:", [validators.InputRequired(), NumberRange(min=1, max=4)]
|
||||
term = SelectField(
|
||||
"Term:",
|
||||
validate_choice=True,
|
||||
coerce=str,
|
||||
choices=[
|
||||
(u'1.2', u'1.2'),
|
||||
(u'2.3', u'2.3'),
|
||||
(u'3.1', u'3.1'),
|
||||
(u'4.1', u'4.1'),
|
||||
(u'4.2', u'4.2'),
|
||||
],
|
||||
option_widget=None,
|
||||
validators=[DataRequired()]
|
||||
)
|
||||
tags = StringField(
|
||||
"Add search tags, comma-separated:",
|
||||
|
@ -84,7 +84,7 @@ def distribusi():
|
||||
zipfilename = "{}.zip".format(distribusi.distribusiname)
|
||||
userfolder = os.path.join("stash", distribusi.distribusiname)
|
||||
unzipfile = os.path.join(userfolder, zipfilename)
|
||||
print(unzipfile)
|
||||
|
||||
if os.path.exists(unzipfile):
|
||||
with zipfile.ZipFile(unzipfile, "r") as zip_ref:
|
||||
# To do, replace extractall with inspection and extract
|
||||
@ -100,6 +100,8 @@ def distribusi():
|
||||
parser = build_argparser()
|
||||
args = parser.parse_args(["-s", cssfile])
|
||||
distribusify(args, userfolder)
|
||||
distribusi.visible = True
|
||||
db.session.commit()
|
||||
return redirect(url_for("index"))
|
||||
template = render_template(
|
||||
"distribusi.html",
|
||||
@ -162,9 +164,6 @@ def upload():
|
||||
shutil.copy(copyzipfile, newuserfolder)
|
||||
os.remove(os.path.join(APP.config["UPLOAD_FOLDER"], zipfilename))
|
||||
files_uploaded = AreFilesUploaded()
|
||||
else:
|
||||
print("there is a problem with form validation")
|
||||
print(uploadform.course.data)
|
||||
template = render_template(
|
||||
"distribusi.html",
|
||||
uploadform=uploadform,
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
.selector-style:after {
|
||||
top: 50%;
|
||||
left: 85%;
|
||||
left: 95%;
|
||||
border: solid;
|
||||
content: " ";
|
||||
height: 0;
|
||||
@ -50,3 +50,6 @@ select.selector option{
|
||||
.selector-style select:focus {
|
||||
outline: none;
|
||||
}
|
||||
.selector-style select option:hover {
|
||||
background: #60337F;
|
||||
}
|
||||
|
@ -22,8 +22,10 @@ div#login form {
|
||||
}
|
||||
|
||||
input[type=text], input[type=password], input[type=file] {
|
||||
background-color: #2D3039;
|
||||
color: white;
|
||||
width: 18em;
|
||||
max-width: 18em;
|
||||
background-color: #2D3039;
|
||||
border: 1px solid #E0B0FF;
|
||||
}
|
||||
|
||||
@ -104,6 +106,9 @@ input[type="submit"]:disabled:focus {
|
||||
.error {
|
||||
color: #ff5a5a;
|
||||
}
|
||||
.delete !important {
|
||||
color: #ff5a5a;
|
||||
}
|
||||
|
||||
|
||||
/* unvisited link */
|
||||
@ -169,8 +174,13 @@ medium
|
||||
dark
|
||||
#60337F
|
||||
|
||||
yellow
|
||||
background dark
|
||||
#2D3039
|
||||
|
||||
yellow important
|
||||
#fff600
|
||||
|
||||
red: danger
|
||||
ff5a5a
|
||||
backgrounds
|
||||
*/
|
||||
|
@ -8,7 +8,7 @@ def AreFilesUploaded():
|
||||
user = User.query.filter_by(email=current_user.email).first()
|
||||
distribusi = Distribusis.query.filter_by(userid=user.id).first()
|
||||
if distribusi is None:
|
||||
print("distribusi is empty")
|
||||
print("distribusi folder is empty")
|
||||
return False
|
||||
userfolder = os.path.join("stash", distribusi.distribusiname)
|
||||
if os.path.exists(userfolder):
|
||||
@ -20,7 +20,10 @@ def HasDistribusi():
|
||||
user = User.query.filter_by(email=current_user.email).first()
|
||||
distribusi = Distribusis.query.filter_by(userid=user.id).first()
|
||||
if distribusi is None:
|
||||
print("distribusi is empty")
|
||||
print("no distribusi found")
|
||||
return False
|
||||
if distribusi.visible is False:
|
||||
print("distribusi not visible")
|
||||
return False
|
||||
return True
|
||||
|
||||
|
@ -19,10 +19,12 @@
|
||||
</fieldset>
|
||||
<fieldset class="required">
|
||||
{{ uploadform.term.label }}
|
||||
<div class="selector-style">
|
||||
{{ uploadform.term }}
|
||||
{% for message in uploadform.term.errors %}
|
||||
<div class="error">{{ message }}</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset class="required">
|
||||
{{ uploadform.course.label }}
|
||||
|
@ -11,6 +11,7 @@ class User(UserMixin, db.Model):
|
||||
email = db.Column(db.String(150), unique=True, nullable=False)
|
||||
password = db.Column(db.String(300), nullable=False, unique=False)
|
||||
currentdistribusi = db.Column(db.String(300), nullable=True, unique=False)
|
||||
admin = db.Column(db.Boolean, server_default="false")
|
||||
|
||||
def __repr__(self):
|
||||
return "<User %r>" % self.email
|
||||
|
Loading…
Reference in New Issue
Block a user