Volunteer Janitor: Initial hooks.

This commit is contained in:
Ben Rog-Wilhelm 2022-11-14 02:49:59 -06:00 committed by Ben Rog-Wilhelm
parent 8a9e1bc54a
commit e43db0535d
7 changed files with 41 additions and 0 deletions

View file

@ -66,3 +66,7 @@ def inject_constants():
"COLORS":COLORS,
"THEMES":THEMES,
}
def template_function(func):
assert(func.__name__ not in app.jinja_env.globals)
app.jinja_env.globals[func.__name__] = func

View file

@ -14,4 +14,5 @@ from .votes import *
from .feeds import *
from .awards import *
from .giphy import *
from .volunteer import *
# from .subs import *

16
files/routes/volunteer.py Normal file
View file

@ -0,0 +1,16 @@
from files.__main__ import app
from files.classes.user import User
import files.helpers.jinja2
from files.helpers.wrappers import auth_required
from flask import render_template
@app.get("/volunteer")
@auth_required
def volunteer(v: User):
return render_template("volunteer.html", v=v)
@files.helpers.jinja2.template_function
def volunteer_available_for(u: User) -> bool:
return True

View file

@ -520,6 +520,8 @@
</div>
{% endif %}
{% include "volunteer_teaser.html" %}
{% if p.replies %}
<div class="comment-section" id="replies-of-{{p.id}}">
{% with comments=p.replies %}

View file

@ -68,6 +68,8 @@
</div>
{% include "volunteer_teaser.html" %}
<div class="comment-section">
{% with comments=p.replies %}
{% include "comments.html" %}

View file

@ -0,0 +1,11 @@
{% extends "default.html" %}
{% block pagetitle %}Volunteer{% endblock %}
{% block content %}
<div>
hello! welcome to the volunteering
</div>
{% endblock %}

View file

@ -0,0 +1,5 @@
{% if volunteer_available_for(v) %}
<div class="volunteer_teaser">
hello come <a href="/volunteer">the voluntter</a>!
</div>
{% endif %}