Skip to content

Commit

Permalink
Merge pull request #29 from rcthomas/dehardcode-update-url
Browse files Browse the repository at this point in the history
Dehardcode update URL
  • Loading branch information
rcthomas authored Jun 5, 2024
2 parents 7107986 + 57fff97 commit eb834c7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions jupyterhub_announcement/announcement.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ def initialize(self, argv=None):
queue=self.queue,
fixed_message=self.fixed_message,
loader=loader,
service_prefix=self.service_prefix,
),
"view",
),
Expand Down
5 changes: 4 additions & 1 deletion jupyterhub_announcement/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,20 @@ def log(self):
class AnnouncementViewHandler(AnnouncementHandler):
"""View announcements page"""

def initialize(self, queue, fixed_message, loader):
def initialize(self, queue, fixed_message, loader, service_prefix):
super().initialize(queue)
self.fixed_message = fixed_message
self.loader = loader
self.env = Environment(loader=self.loader)
self.template = self.env.get_template("index.html")
self.service_prefix = service_prefix

@web.authenticated
def get(self):
user = self.get_current_user()
prefix = self.hub_auth.hub_prefix
logout_url = url_path_join(prefix, "logout")
update_url = url_path_join(self.service_prefix, "update")
self.write(
self.template.render(
user=user,
Expand All @@ -47,6 +49,7 @@ def get(self):
no_spawner_check=True,
parsed_scopes=user.get("hub_scopes") or [],
xsrf_form_html=self.xsrf_form_html,
update_url=update_url,
)
)

Expand Down
2 changes: 1 addition & 1 deletion templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

{% if user.admin %}
<div class="row">
<form action="/services/announcement/update" method="post" class="col-md-offset-3 col-md-6">
<form action="{{ update_url }}" method="post" class="col-md-offset-3 col-md-6">
{{ xsrf_form_html() | safe }}
<div class="form-group">
<label for="announcement">Announcement</label>
Expand Down

0 comments on commit eb834c7

Please sign in to comment.