Skip to content

Commit

Permalink
Merge pull request #1197 from ScilifelabDataCentre/motd-change
Browse files Browse the repository at this point in the history
set motd as session variable
  • Loading branch information
i-oden authored Jun 13, 2022
2 parents 696b5c8 + b073f6d commit 12a0f4a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ Please add a _short_ line describing the PR you make, if the PR implements a spe
- New tests for `dds_web/utils.py` ([#1188](https://github.com/ScilifelabDataCentre/dds_web/pull/1188))
- Removed FontAwesome from web ([#1192](https://github.com/ScilifelabDataCentre/dds_web/pull/1192))

## Sprint (2022-06-01 - 2022-05-15)
## Sprint (2022-06-01 - 2022-06-15)

- Change FontAwesome source link to own license ([#1194](https://github.com/ScilifelabDataCentre/dds_web/pull/1194))
- Display MOTD on web ([#1196](https://github.com/ScilifelabDataCentre/dds_web/pull/1196))
5 changes: 5 additions & 0 deletions dds_web/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ def prepare():
if "/api/v1" in flask.request.path:
validate_major_cli_version()

# Get message of the day
flask.g.motd = (
db.session.query(models.MOTD).order_by(models.MOTD.date_created.desc()).first()
)

flask.g.current_user = None
flask.g.current_user_emails = None
if auth.current_user():
Expand Down
9 changes: 9 additions & 0 deletions dds_web/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
<body>
{% include 'components/navbar.html' %}

<div class="container content pt-2">
{% if g.motd %}
<div class="alert alert-warning" role="alert">
<h3>Important Information</h3>
{{ g.motd.message }}
</div>
{% endif %}
</div>

<div class="container content pt-2">

{%if self.page_title() != "Data Delivery System" %}<h1>{{ self.page_title() }}</h1>{%endif%}
Expand Down
8 changes: 0 additions & 8 deletions dds_web/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@
</div>
</div>

<p class="lead">
{% if motd %}
<h2>Current status/System news</h2>
{{ motd['message'] }}
{% endif %}
</p>


<h2>Background</h2>
<p class="lead">
SciLifeLab is a national resource, providing multiple unique technologies and expertise to life scientists in
Expand Down
4 changes: 1 addition & 3 deletions dds_web/web/root.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@
from dds_web import forms, db
from dds_web.database import models


pages = Blueprint("pages", __name__)


@pages.route("/", methods=["GET"])
def home():
"""Home page."""
form = forms.LoginForm()
motds = db.session.query(models.MOTD).order_by(models.MOTD.date_created.desc()).first()
return render_template("home.html", form=form, motd=motds)
return render_template("home.html", form=form)


@pages.route("/policy", methods=["GET"])
Expand Down

0 comments on commit 12a0f4a

Please sign in to comment.