added course dropdown and fixed multiple distribusi dropdown
This commit is contained in:
parent
aa89547ee1
commit
ef219832f1
@ -10,7 +10,8 @@ class Distribusis(db.Model):
|
|||||||
distribusiname = db.Column(db.String(300), nullable=True, unique=True)
|
distribusiname = db.Column(db.String(300), nullable=True, unique=True)
|
||||||
userid = db.Column(db.Integer, db.ForeignKey("users.id"))
|
userid = db.Column(db.Integer, db.ForeignKey("users.id"))
|
||||||
term = db.Column(db.Integer, nullable=False, unique=False)
|
term = db.Column(db.Integer, 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
|
# Academic year eg:2020-2021, so no need for a Datetime object
|
||||||
year = db.Column(db.String(9), nullable=True, unique=False)
|
year = db.Column(db.String(9), nullable=True, unique=False)
|
||||||
tags = db.Column(db.String(500), nullable=True, unique=False)
|
tags = db.Column(db.String(500), nullable=True, unique=False)
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
from flask_wtf import FlaskForm
|
from flask_wtf import FlaskForm
|
||||||
from flask_wtf.file import FileField, FileAllowed, FileRequired, FileSize
|
from flask_wtf.file import FileField, FileAllowed, FileRequired, FileSize
|
||||||
from wtforms import validators
|
from wtforms import validators
|
||||||
from wtforms.validators import Length, NumberRange
|
from wtforms.validators import Length, NumberRange, DataRequired
|
||||||
from wtforms import (
|
from wtforms import (
|
||||||
SubmitField,
|
SubmitField,
|
||||||
StringField,
|
StringField,
|
||||||
IntegerField,
|
IntegerField,
|
||||||
|
SelectField,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -27,6 +28,21 @@ class UploadForm(FlaskForm):
|
|||||||
"Add search tags, comma-separated:",
|
"Add search tags, comma-separated:",
|
||||||
validators=[validators.InputRequired(), Length(2, 500)],
|
validators=[validators.InputRequired(), Length(2, 500)],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
course = SelectField(
|
||||||
|
u'Course:',
|
||||||
|
validate_choice=True,
|
||||||
|
coerce=str,
|
||||||
|
choices=[
|
||||||
|
('hacking', u'Autonomous - Hacking'),
|
||||||
|
('digitalcraft', u'Autonomous - Digital Craft'),
|
||||||
|
('criticalstudies', u'Autonomous - Critical Studies'),
|
||||||
|
('publicprivate', u'Autonomous - Public&Private'),
|
||||||
|
],
|
||||||
|
option_widget=None,
|
||||||
|
validators=[DataRequired()]
|
||||||
|
)
|
||||||
|
|
||||||
zipfile = FileField(
|
zipfile = FileField(
|
||||||
"Upload your zip file with content here:",
|
"Upload your zip file with content here:",
|
||||||
validators=[
|
validators=[
|
||||||
|
@ -119,7 +119,12 @@ def upload():
|
|||||||
uploadform = UploadForm()
|
uploadform = UploadForm()
|
||||||
distribusiform = DistribusiForm()
|
distribusiform = DistribusiForm()
|
||||||
themeform = ThemeForm()
|
themeform = ThemeForm()
|
||||||
files_uploaded = False
|
selectorform = SelectorForm()
|
||||||
|
selectorform.distribusis.choices = distribusisfields()
|
||||||
|
|
||||||
|
files_uploaded = AreFilesUploaded()
|
||||||
|
has_distribusi = HasDistribusi()
|
||||||
|
|
||||||
if uploadform.validate_on_submit():
|
if uploadform.validate_on_submit():
|
||||||
user = User.query.filter_by(email=current_user.email).first()
|
user = User.query.filter_by(email=current_user.email).first()
|
||||||
|
|
||||||
@ -127,8 +132,9 @@ def upload():
|
|||||||
newdistribusi = Distribusis(
|
newdistribusi = Distribusis(
|
||||||
distribusiname=uploadform.sitename.data,
|
distribusiname=uploadform.sitename.data,
|
||||||
userid=user.id,
|
userid=user.id,
|
||||||
year=uploadform.academicyear.data,
|
|
||||||
term=uploadform.term.data,
|
term=uploadform.term.data,
|
||||||
|
course=uploadform.course.data,
|
||||||
|
year=uploadform.academicyear.data,
|
||||||
tags=uploadform.tags.data,
|
tags=uploadform.tags.data,
|
||||||
)
|
)
|
||||||
db.session.add(newdistribusi)
|
db.session.add(newdistribusi)
|
||||||
@ -156,12 +162,17 @@ def upload():
|
|||||||
shutil.copy(copyzipfile, newuserfolder)
|
shutil.copy(copyzipfile, newuserfolder)
|
||||||
os.remove(os.path.join(APP.config["UPLOAD_FOLDER"], zipfilename))
|
os.remove(os.path.join(APP.config["UPLOAD_FOLDER"], zipfilename))
|
||||||
files_uploaded = AreFilesUploaded()
|
files_uploaded = AreFilesUploaded()
|
||||||
|
else:
|
||||||
|
print("there is a problem with form validation")
|
||||||
|
print(uploadform.course.data)
|
||||||
template = render_template(
|
template = render_template(
|
||||||
"distribusi.html",
|
"distribusi.html",
|
||||||
uploadform=uploadform,
|
uploadform=uploadform,
|
||||||
distribusiform=distribusiform,
|
distribusiform=distribusiform,
|
||||||
themeform=themeform,
|
themeform=themeform,
|
||||||
|
selectorform=selectorform,
|
||||||
files_uploaded=files_uploaded,
|
files_uploaded=files_uploaded,
|
||||||
|
has_distribusi=has_distribusi,
|
||||||
)
|
)
|
||||||
return template
|
return template
|
||||||
|
|
||||||
@ -172,7 +183,12 @@ def theme():
|
|||||||
uploadform = UploadForm()
|
uploadform = UploadForm()
|
||||||
distribusiform = DistribusiForm()
|
distribusiform = DistribusiForm()
|
||||||
themeform = ThemeForm()
|
themeform = ThemeForm()
|
||||||
|
selectorform = SelectorForm()
|
||||||
|
selectorform.distribusis.choices = distribusisfields()
|
||||||
|
|
||||||
files_uploaded = AreFilesUploaded()
|
files_uploaded = AreFilesUploaded()
|
||||||
|
has_distribusi = HasDistribusi()
|
||||||
|
|
||||||
if themeform.validate_on_submit():
|
if themeform.validate_on_submit():
|
||||||
user = User.query.filter_by(email=current_user.email).first()
|
user = User.query.filter_by(email=current_user.email).first()
|
||||||
distribusi = Distribusis.query.filter_by(userid=user.id).first()
|
distribusi = Distribusis.query.filter_by(userid=user.id).first()
|
||||||
@ -188,7 +204,9 @@ def theme():
|
|||||||
uploadform=uploadform,
|
uploadform=uploadform,
|
||||||
distribusiform=distribusiform,
|
distribusiform=distribusiform,
|
||||||
themeform=themeform,
|
themeform=themeform,
|
||||||
|
selectorform=selectorform,
|
||||||
files_uploaded=files_uploaded,
|
files_uploaded=files_uploaded,
|
||||||
|
has_distribusi=has_distribusi,
|
||||||
)
|
)
|
||||||
return template
|
return template
|
||||||
|
|
||||||
@ -214,6 +232,26 @@ def editor():
|
|||||||
return template
|
return template
|
||||||
|
|
||||||
|
|
||||||
|
@APP.route("/selector", methods=["GET", "POST"])
|
||||||
|
@login_required
|
||||||
|
def selector():
|
||||||
|
selectorform = SelectorForm()
|
||||||
|
selectorform.distribusis.choices = distribusisfields()
|
||||||
|
user = User.query.filter_by(email=current_user.email).first()
|
||||||
|
if selectorform.validate_on_submit():
|
||||||
|
print(selectorform.distribusis.data)
|
||||||
|
print()
|
||||||
|
template = render_template(
|
||||||
|
"distribusi.html",
|
||||||
|
uploadform=uploadform,
|
||||||
|
distribusiform=distribusiform,
|
||||||
|
themeform=themeform,
|
||||||
|
selectorform=selectorform,
|
||||||
|
files_uploaded=files_uploaded,
|
||||||
|
has_distribusi=has_distribusi,
|
||||||
|
)
|
||||||
|
return template
|
||||||
|
|
||||||
@APP.route("/stash/<path:path>")
|
@APP.route("/stash/<path:path>")
|
||||||
def distribusistash(path):
|
def distribusistash(path):
|
||||||
return send_from_directory("stash", path)
|
return send_from_directory("stash", path)
|
||||||
|
@ -2,20 +2,25 @@
|
|||||||
padding: 0;
|
padding: 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
border: 1px solid #ccc;
|
border: 1px solid #ccc;
|
||||||
width: 120px;
|
width: 20em;
|
||||||
border-radius: 3px;
|
max-width: 20em;
|
||||||
overflow: hidden;
|
|
||||||
background-color: #fff;
|
|
||||||
background: #fff;
|
|
||||||
position: relative;
|
position: relative;
|
||||||
|
border: none;
|
||||||
|
background: #E0B0FF;
|
||||||
|
text-decoration: none;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
margin: 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.selector-style select {
|
.selector-style select {
|
||||||
padding: 5px 8px;
|
padding: 0.2em 0.2em;
|
||||||
width: 130%;
|
width: 20em;
|
||||||
|
max-width: 20em;
|
||||||
border: none;
|
border: none;
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
background-color: transparent;
|
background-color: #E0B0FF;
|
||||||
background-image: none;
|
background-image: none;
|
||||||
-webkit-appearance: none;
|
-webkit-appearance: none;
|
||||||
-moz-appearance: none;
|
-moz-appearance: none;
|
||||||
@ -25,7 +30,7 @@
|
|||||||
.selector-style:after {
|
.selector-style:after {
|
||||||
top: 50%;
|
top: 50%;
|
||||||
left: 85%;
|
left: 85%;
|
||||||
border: solid transparent;
|
border: solid;
|
||||||
content: " ";
|
content: " ";
|
||||||
height: 0;
|
height: 0;
|
||||||
width: 0;
|
width: 0;
|
||||||
@ -33,10 +38,14 @@
|
|||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
border-color: rgba(0, 0, 0, 0);
|
border-color: rgba(0, 0, 0, 0);
|
||||||
border-top-color: #000000;
|
border-top-color: #000000;
|
||||||
border-width: 5px;
|
|
||||||
margin-top: -2px;
|
margin-top: -2px;
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
}
|
}
|
||||||
|
select.selector option{
|
||||||
|
color: white;
|
||||||
|
background-color: #60337F;
|
||||||
|
padding: 0 10px;
|
||||||
|
}
|
||||||
|
|
||||||
.selector-style select:focus {
|
.selector-style select:focus {
|
||||||
outline: none;
|
outline: none;
|
||||||
|
@ -125,6 +125,7 @@ a:hover {
|
|||||||
a:active {
|
a:active {
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* STOLEN GOODS */
|
/* STOLEN GOODS */
|
||||||
#fancyboi::before {
|
#fancyboi::before {
|
||||||
content: "$ ";
|
content: "$ ";
|
||||||
@ -151,6 +152,7 @@ a:active {
|
|||||||
animation: flash 0.5s step-end infinite;
|
animation: flash 0.5s step-end infinite;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
div.maincontent{
|
div.maincontent{
|
||||||
width: 55%;
|
width: 55%;
|
||||||
border: 3px solid #E0B0FF;
|
border: 3px solid #E0B0FF;
|
||||||
|
@ -3,11 +3,15 @@
|
|||||||
<p>You have already uploaded a distribusi website, do you want to make a new one, update or delete?</p>
|
<p>You have already uploaded a distribusi website, do you want to make a new one, update or delete?</p>
|
||||||
<form method="POST" enctype="multipart/form-data" action="{{ url_for('distribusi') }}">
|
<form method="POST" enctype="multipart/form-data" action="{{ url_for('distribusi') }}">
|
||||||
{{ selectorform.csrf_token }}
|
{{ selectorform.csrf_token }}
|
||||||
<select class="selector-style">
|
<fieldset class="required">
|
||||||
{% for subfield in selectorform.distribusis %}
|
{{ selectorform.distribusis.label }}
|
||||||
{{ subfield }}
|
<div class="selector-style">
|
||||||
{% endfor %}
|
{{ selectorform.distribusis }}
|
||||||
</select>
|
{% for message in selectorform.distribusis.errors %}
|
||||||
|
<div class="error">{{ message }}</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
<fieldset class="button required multiselect">
|
<fieldset class="button required multiselect">
|
||||||
{{ selectorform.new }}
|
{{ selectorform.new }}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<div id="upload" class="workflow">
|
<div id="upload" class="workflow">
|
||||||
<h3>Step 1: Upload</h3>
|
<h3>Step 1: Upload</h3>
|
||||||
<p>Upload your files here, the only accepted file type is a zip file</p>
|
<p>Upload your files here:</p>
|
||||||
<form method="POST" enctype="multipart/form-data" action="{{ url_for('upload') }}">
|
<form method="POST" enctype="multipart/form-data" action="{{ url_for('upload') }}">
|
||||||
{{ uploadform.csrf_token }}
|
{{ uploadform.csrf_token }}
|
||||||
<fieldset class="required">
|
<fieldset class="required">
|
||||||
@ -24,6 +24,15 @@
|
|||||||
<div class="error">{{ message }}</div>
|
<div class="error">{{ message }}</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
<fieldset class="required">
|
||||||
|
{{ uploadform.course.label }}
|
||||||
|
<div class="selector-style">
|
||||||
|
{{ uploadform.course }}
|
||||||
|
{% for message in uploadform.course.errors %}
|
||||||
|
<div class="error">{{ message }}</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
<fieldset class="required tags">
|
<fieldset class="required tags">
|
||||||
{{ uploadform.tags.label }}
|
{{ uploadform.tags.label }}
|
||||||
{{ uploadform.tags }}
|
{{ uploadform.tags }}
|
||||||
|
@ -10,6 +10,7 @@ class User(UserMixin, db.Model):
|
|||||||
id = db.Column(db.Integer, primary_key=True)
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
email = db.Column(db.String(150), unique=True, nullable=False)
|
email = db.Column(db.String(150), unique=True, nullable=False)
|
||||||
password = db.Column(db.String(300), nullable=False, unique=False)
|
password = db.Column(db.String(300), nullable=False, unique=False)
|
||||||
|
currentdistribusi = db.Column(db.String(300), nullable=True, unique=False)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<User %r>" % self.email
|
return "<User %r>" % self.email
|
||||||
|
Loading…
Reference in New Issue
Block a user