User profile next event

This commit is contained in:
Oleg Lavrovsky 2023-06-02 16:51:55 +02:00
parent d2d9ef5c64
commit be9e3e8803
No known key found for this signature in database
GPG Key ID: 31E523030632FF4B
3 changed files with 20 additions and 2 deletions

1
.gitignore vendored
View File

@ -38,6 +38,7 @@ nosetests.xml
.cache
tests/.cache
.pytest_cache/
.vscode/
# Translations
*.mo

View File

@ -12,7 +12,7 @@ from dribdat.aggregation import GetEventUsers
from dribdat.user import getProjectStages, isUserActive
from urllib.parse import quote, quote_plus, urlparse
from datetime import datetime
from sqlalchemy import or_
from sqlalchemy import and_, or_
import re
blueprint = Blueprint('public', __name__, static_folder="../static")
@ -143,8 +143,18 @@ def user(username):
submissions = user.posted_challenges()
projects = user.joined_projects(True)
posts = user.latest_posts(20)
today = datetime.utcnow()
events_next = Event.query.filter(and_(
Event.is_hidden.isnot(True),
Event.lock_resources.isnot(True),
Event.ends_at > today
))
events_next = events_next.order_by(Event.starts_at.desc())
if events_next.count() == 0: events_next = None
# Filter out by today's date
return render_template("public/userprofile.html", active="profile",
user=user, projects=projects, posts=posts,
events_next=events_next,
score=user.get_score(),
submissions=submissions,
may_certify=user.may_certify()[0])

View File

@ -120,7 +120,6 @@
</ul>
</div>
</div>
{% if user.my_story %}
@ -140,6 +139,14 @@
<div class="alert alert-success">
No projects here yet. Time to <b>Join</b> or <b>Start</b> something awesome!
</div>
{% if events_next %}
<div class="row events-next mt-4 mb-4">
{% for event in events_next %}
{{ misc.render_home_event(event) }}
{% endfor %}
</div><!-- /.row events-next -->
{% endif %}
{% endif %}
{% else %}
<a name="projects"><h1>Projects</h1></a>