forked from crunk/distribusi-verse
users now have anonymous username option
This commit is contained in:
parent
6a475024d3
commit
6507b05c64
@ -7,7 +7,7 @@ class Distribusis(db.Model):
|
||||
__tablename__ = "distribusis"
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
distribusiname = db.Column(db.String(300), nullable=True, unique=True)
|
||||
distribusiname = db.Column(db.String(300), nullable=False, unique=True)
|
||||
userid = db.Column(db.Integer, db.ForeignKey("users.id"))
|
||||
term = db.Column(db.String(5), nullable=False, unique=False)
|
||||
course = db.Column(db.String(500), nullable=True, unique=False)
|
||||
@ -15,6 +15,8 @@ class Distribusis(db.Model):
|
||||
# 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)
|
||||
publictheme = db.Column(db.String(300), unique=True, nullable=True)
|
||||
|
||||
visible = db.Column(db.Boolean, default=False)
|
||||
|
||||
def __repr__(self):
|
||||
|
@ -12,6 +12,10 @@ from flask_wtf import FlaskForm
|
||||
|
||||
class RegisterForm(FlaskForm):
|
||||
"""Register for distribusi-verse form class"""
|
||||
username = StringField(
|
||||
"Username:",
|
||||
validators=[validators.InputRequired(), Length(6, 150)],
|
||||
)
|
||||
|
||||
email = StringField(
|
||||
"Email address:",
|
||||
|
@ -4,7 +4,6 @@ import zipfile
|
||||
import shutil
|
||||
from datetime import timedelta
|
||||
|
||||
|
||||
from flask import (
|
||||
render_template,
|
||||
redirect,
|
||||
@ -32,20 +31,24 @@ from forms.editorform import EditorForm
|
||||
from forms.selectorform import SelectorForm
|
||||
|
||||
# CRUD!
|
||||
from selector import SelectNewDistribusi
|
||||
from selector import SelectUpdateDistribusi
|
||||
from selector import DeleteDistribusi
|
||||
from selector import SelectorVisible
|
||||
from selector import (
|
||||
SelectNewDistribusi,
|
||||
SelectUpdateDistribusi,
|
||||
DeleteDistribusi,
|
||||
SelectorVisible,
|
||||
)
|
||||
|
||||
# Upload
|
||||
from upload import UploadNewDistribusi
|
||||
from upload import UploadUpdatedFiles
|
||||
from upload import UploadNewDistribusi, UploadUpdatedFiles
|
||||
|
||||
# UserPengguna
|
||||
from statuspengguna.helper import IsZipUploaded
|
||||
from statuspengguna.helper import IsCssSelected
|
||||
from statuspengguna.helper import CurrentDistribusi
|
||||
from statuspengguna.helper import ResetUserState
|
||||
from statuspengguna.helper import (
|
||||
IsZipUploaded,
|
||||
IsCssSelected,
|
||||
CurrentDistribusi,
|
||||
HasDistribusi,
|
||||
ResetUserState,
|
||||
)
|
||||
from statuspengguna.loginuser import LoginUser
|
||||
from statuspengguna.registeruser import RegisterUser
|
||||
|
||||
@ -73,7 +76,7 @@ def index():
|
||||
for distribusi in distribusis:
|
||||
user = User.query.filter_by(id=distribusi.userid).first()
|
||||
singledistribusi = {
|
||||
"useremail": user.email,
|
||||
"username": user.username,
|
||||
"term": distribusi.term,
|
||||
"course": distribusi.course,
|
||||
"year": distribusi.year,
|
||||
@ -160,7 +163,7 @@ def upload():
|
||||
selectorvisible = SelectorVisible()
|
||||
|
||||
current_distribusi = CurrentDistribusi()
|
||||
if current_distribusi == "new":
|
||||
if current_distribusi == "new" or HasDistribusi() == False:
|
||||
uploadform = UploadNewDistribusi(APP.config["UPLOAD_FOLDER"])
|
||||
else:
|
||||
uploadform = UploadUpdatedFiles(APP.config["UPLOAD_FOLDER"])
|
||||
|
@ -23,10 +23,12 @@ def RegisterUser():
|
||||
registerform = RegisterForm()
|
||||
if registerform.validate_on_submit():
|
||||
try:
|
||||
username = registerform.username.data
|
||||
email = registerform.email.data
|
||||
password = registerform.confirmpassword.data
|
||||
|
||||
newuser = User(
|
||||
username=username,
|
||||
email=email,
|
||||
password=generate_password_hash(password),
|
||||
)
|
||||
|
@ -46,7 +46,7 @@
|
||||
<ul>
|
||||
{% for name, distribusi in distribusies.items() %}
|
||||
<li class='distribusi filter {{ distribusi["term"] }} {{ distribusi["year"] }} {{ distribusi["course"] }}'>
|
||||
<a href='stash/{{name}}/index.html'>{{distribusi["useremail"]}}:{{name}}</a>
|
||||
<a href='stash/{{name}}/index.html'>{{distribusi["username"]}}:{{name}}</a>
|
||||
{% for tag in distribusi["tags"] %}
|
||||
<span class="tags">{{tag}}</span>
|
||||
{% endfor%}
|
||||
|
@ -3,6 +3,13 @@
|
||||
<div id="login">
|
||||
<form class="form" action="{{ url_for('register') }}" method="post">
|
||||
{{ registerform.csrf_token }}
|
||||
<fieldset class="required">
|
||||
{{ registerform.username.label }}
|
||||
{{ registerform.username }}
|
||||
{% for message in registerform.username.errors %}
|
||||
<div class="error">{{ message }}</div>
|
||||
{% endfor %}
|
||||
</fieldset>
|
||||
<fieldset class="required">
|
||||
{{ registerform.email.label }}
|
||||
{{ registerform.email }}
|
||||
|
@ -8,10 +8,12 @@ class User(UserMixin, db.Model):
|
||||
__tablename__ = "users"
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
username = 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)
|
||||
currentdistribusi = db.Column(db.String(300), nullable=True, unique=False)
|
||||
admin = db.Column(db.Boolean, server_default="false")
|
||||
tutor = db.Column(db.Boolean, server_default="false")
|
||||
|
||||
def __repr__(self):
|
||||
return "<User %r>" % self.email
|
||||
|
Loading…
Reference in New Issue
Block a user