start of public custom css sharing
This commit is contained in:
parent
2d34ab0af5
commit
4eef509a74
@ -2,11 +2,13 @@
|
|||||||
from wtforms import (
|
from wtforms import (
|
||||||
StringField,
|
StringField,
|
||||||
TextAreaField,
|
TextAreaField,
|
||||||
|
BooleanField,
|
||||||
SubmitField,
|
SubmitField,
|
||||||
)
|
)
|
||||||
|
|
||||||
from wtforms import validators
|
from wtforms import validators
|
||||||
from wtforms.validators import Length
|
from wtforms.validators import Length
|
||||||
|
from flask_wtf.file import FileField, FileAllowed, FileSize
|
||||||
from flask_wtf import FlaskForm
|
from flask_wtf import FlaskForm
|
||||||
|
|
||||||
|
|
||||||
@ -17,5 +19,17 @@ class EditorForm(FlaskForm):
|
|||||||
"fill in a name for your css style:",
|
"fill in a name for your css style:",
|
||||||
validators=[validators.InputRequired(), Length(5, 200)],
|
validators=[validators.InputRequired(), Length(5, 200)],
|
||||||
)
|
)
|
||||||
|
cssfile = FileField(
|
||||||
|
"(Optional) upload your own css file:",
|
||||||
|
validators=[
|
||||||
|
FileAllowed(["css"], "css files only!"),
|
||||||
|
FileSize(
|
||||||
|
max_size=10485760,
|
||||||
|
message="Zipfile size must be smaller than 100MB",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
css = TextAreaField()
|
css = TextAreaField()
|
||||||
|
public = BooleanField("Make your CSS public so others can use it")
|
||||||
|
|
||||||
submit = SubmitField("Save")
|
submit = SubmitField("Save")
|
||||||
|
@ -72,20 +72,18 @@ def index():
|
|||||||
distribusies = {}
|
distribusies = {}
|
||||||
for distribusi in distribusis:
|
for distribusi in distribusis:
|
||||||
user = User.query.filter_by(id=distribusi.userid).first()
|
user = User.query.filter_by(id=distribusi.userid).first()
|
||||||
#distribusies[distribusi.distribusiname] = user.email
|
|
||||||
distribusies[user.email] = distribusi
|
|
||||||
singledistribusi = {
|
singledistribusi = {
|
||||||
"name": distribusi.distribusiname,
|
"useremail": user.email,
|
||||||
"term": distribusi.term,
|
"term": distribusi.term,
|
||||||
"course": distribusi.course,
|
"course": distribusi.course,
|
||||||
"year": distribusi.year,
|
"year": distribusi.year,
|
||||||
"tags": distribusi.tags.split(','),
|
"tags": distribusi.tags.split(','),
|
||||||
}
|
}
|
||||||
distribusies[user.email] = singledistribusi
|
distribusies[distribusi.distribusiname] = singledistribusi
|
||||||
years = uploadform.academicyear.choices
|
years = uploadform.academicyear.choices
|
||||||
terms = uploadform.term.choices
|
terms = uploadform.term.choices
|
||||||
courses = uploadform.course.choices
|
courses = uploadform.course.choices
|
||||||
print(type(courses[0]))
|
|
||||||
template = render_template(
|
template = render_template(
|
||||||
"index.html",
|
"index.html",
|
||||||
distribusies=distribusies,
|
distribusies=distribusies,
|
||||||
|
@ -27,6 +27,20 @@
|
|||||||
<div class="error">{{ message }}</div>
|
<div class="error">{{ message }}</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
<fieldset class="required">
|
||||||
|
{{ editorform.cssfile.label }}
|
||||||
|
{{ editorform.cssfile }}
|
||||||
|
{% for message in editorform.cssfile.errors %}
|
||||||
|
<div class="error">{{ message }}</div>
|
||||||
|
{% endfor %}
|
||||||
|
</fieldset>
|
||||||
|
<fieldset class="button">
|
||||||
|
{{ editorform.public.label }}
|
||||||
|
{{ editorform.public }}
|
||||||
|
{% for message in editorform.public.errors %}
|
||||||
|
<div class="error">{{ message }}</div>
|
||||||
|
{% endfor %}
|
||||||
|
</fieldset>
|
||||||
<fieldset class="button required">
|
<fieldset class="button required">
|
||||||
{{ editorform.submit }}
|
{{ editorform.submit }}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
@ -44,9 +44,9 @@
|
|||||||
<h2>List of distribusis</h2>
|
<h2>List of distribusis</h2>
|
||||||
{% include 'filtermenu.html' %}
|
{% include 'filtermenu.html' %}
|
||||||
<ul>
|
<ul>
|
||||||
{% for id, distribusi in distribusies.items() %}
|
{% for name, distribusi in distribusies.items() %}
|
||||||
<li class='distribusi filter {{ distribusi["term"] }} {{ distribusi["year"] }} {{ distribusi["course"] }}'>
|
<li class='distribusi filter {{ distribusi["term"] }} {{ distribusi["year"] }} {{ distribusi["course"] }}'>
|
||||||
{{id}}: <a href='stash/{{distribusi["name"]}}/index.html'>{{distribusi["name"]}}</a>
|
{{distribusi["useremail"]}}: <a href='stash/{{name}}/index.html'>{{name}}</a>
|
||||||
{% for tag in distribusi["tags"] %}
|
{% for tag in distribusi["tags"] %}
|
||||||
<span class="tags">{{tag}}</span>
|
<span class="tags">{{tag}}</span>
|
||||||
{% endfor%}
|
{% endfor%}
|
||||||
|
Loading…
Reference in New Issue
Block a user