2020-03-24 15:26:15 +01:00
|
|
|
from flask import Blueprint, render_template
|
2020-04-28 17:12:11 +02:00
|
|
|
from hubsrht.types import Project, Event, EventType, Visibility
|
2020-04-27 17:45:53 +02:00
|
|
|
from srht.flask import paginate_query
|
|
|
|
from srht.oauth import current_user, loginrequired
|
2020-03-24 15:26:15 +01:00
|
|
|
|
|
|
|
public = Blueprint("public", __name__)
|
|
|
|
|
|
|
|
@public.route("/")
|
|
|
|
def index():
|
|
|
|
if current_user:
|
2020-04-27 17:45:53 +02:00
|
|
|
projects = (Project.query
|
|
|
|
.filter(Project.owner_id == current_user.id)
|
|
|
|
.order_by(Project.updated.desc())
|
|
|
|
.limit(5)).all()
|
|
|
|
if any(projects):
|
|
|
|
events = (Event.query
|
|
|
|
.filter(Event.user_id == current_user.id)
|
|
|
|
.order_by(Event.created.desc())
|
|
|
|
.limit(2)).all()
|
|
|
|
return render_template("dashboard.html",
|
|
|
|
projects=projects, EventType=EventType, events=events)
|
2020-03-24 15:26:15 +01:00
|
|
|
return render_template("new-user-dashboard.html")
|
|
|
|
return render_template("index.html")
|
2020-04-27 17:45:53 +02:00
|
|
|
|
|
|
|
@public.route("/getting-started")
|
|
|
|
@loginrequired
|
|
|
|
def getting_started():
|
|
|
|
return render_template("new-user-dashboard.html")
|
2020-04-28 17:12:11 +02:00
|
|
|
|
|
|
|
@public.route("/projects")
|
|
|
|
def project_index():
|
|
|
|
projects = (Project.query
|
|
|
|
.filter(Project.visibility == Visibility.public))
|
|
|
|
projects, pagination = paginate_query(projects)
|
|
|
|
return render_template("project-index.html",
|
|
|
|
projects=projects, **pagination)
|