Conversation
|
|
||
| def status_page(request, slug): | ||
| status = get_object_or_404(Status, slug=slug) | ||
| print("status", status) |
|
Hey @rjsparks this is ready for another review |
| console.info("No status message") | ||
| return | ||
| } | ||
| const dismissedStatuses = getDismissedStatuses() | ||
| if(dismissedStatuses.includes(status.id)) { | ||
| console.info(`Not showing site status ${status.id} because it was already dismissed. Dismissed Ids:`, dismissedStatuses) | ||
| return | ||
| } | ||
|
|
||
| const isSameStatusPage = Boolean(document.querySelector(`[data-status-id="${status.id}"]`)) | ||
|
|
||
| if(isSameStatusPage) { | ||
| console.info(`Not showing site status ${status.id} because we're on the target page`) | ||
| return | ||
| } | ||
|
|
||
| if(notificationInstances[status.id]) { | ||
| console.info(`Not showing site status ${status.id} because it's already been displayed`) |
| @@ -0,0 +1,83 @@ | |||
| <script> | |||
There was a problem hiding this comment.
Use <script setup> instead of manually defining the component further down.
There was a problem hiding this comment.
Various uses of semi-colons. Remove all.
| const availableComponents = { | ||
| ChatLog: defineAsyncComponent(() => import('./components/ChatLog.vue')), | ||
| Polls: defineAsyncComponent(() => import('./components/Polls.vue')), | ||
| Status: defineAsyncComponent(() => import('./components/Status.vue')), |
| @@ -0,0 +1,18 @@ | |||
| export const JSONWrapper = { | |||
| parse(jsonString, defaultValue) { | |||
| if(typeof jsonString !== "string") return defaultValue | |||
| @@ -0,0 +1,22 @@ | |||
| # Copyright The IETF Trust 2017-2020, All Rights Reserved | |||
There was a problem hiding this comment.
this is a new model copyright should be 2024 - same with all other new files. Modified files should have the date range extended to 2024
| @@ -0,0 +1,48 @@ | |||
| # Generated by Django 4.2.13 on 2024-06-24 04:24 | |||
There was a problem hiding this comment.
Replace the Generated by with the trust copyright line
There was a problem hiding this comment.
Also, since this is a new app coming in, delete the migrations and regenerate them so that there's only a 0001_initial.
|
I wrote a tool for OpenSSL to do it automatically. Do you want me to open an issue to add something like that to the release process? https://github.com/openssl/tools/blob/master/release-tools/do-copyright-year |
|
Sure - split that into a separate issue so we don't distract from this PR too much. |
rjsparks
left a comment
There was a problem hiding this comment.
Very close, but I've marked a few things I think need to change.
| status = Status.objects.order_by("-date").first() | ||
| if status is None or status.active == False: | ||
| return { "hasMessage": False } |
There was a problem hiding this comment.
This prevents us from staging the next message.
Consider instead:
status = Status.objects.filter(active=True).order_by("-date").first()
There was a problem hiding this comment.
Changed. This was intentional (ie only the latest status which must also be active is used) but happy to change it.
| if status.slug is None: | ||
| raise FieldError("No slug generated. This shouldn't happen.") |
There was a problem hiding this comment.
Not sure this is a valid use of FieldError. In any case there's nothing to catch this, so it would result in a 500 being served.
It would be better to make the slug a required and unique field in the model with null=False, blank-False, unique=True, with and let the ORM ensure it will never be empty,
| "body": status.body, | ||
| "url": f"/status/{status.slug}", | ||
| "date": status.date.isoformat(), | ||
| "by": status.by.name, |
There was a problem hiding this comment.
by seems to be inconsistently used? The admin could default it to the logged in user, but maybe we should remove it from the model?
There was a problem hiding this comment.
I've removed it from the templates / API response, but kept it in the model for auditing purposes. Happy to remove it if you'd prefer though.
| <h1 data-status-id="{{ status.id }}"> | ||
| {% block title %} {{ status.title }} {% endblock %} | ||
| </h1> | ||
| <div> |
There was a problem hiding this comment.
Since the view that uses this will let you look at inactive slugs, it would be good to put something in the template that warns if the status is no longer active.
There was a problem hiding this comment.
Good idea. I've added a Bootstrap 'badge' to the <h1> saying "inactive"... thoughts?
|
I think the failing URL test is caused by not covering the |
jennifer-richards
left a comment
There was a problem hiding this comment.
This is looking good. I have a few minor comments / change requests.
| }) | ||
|
|
||
| def status_latest_json(request): | ||
| return HttpResponse(json.dumps(get_context_data()), status=200, content_type='application/json') |
There was a problem hiding this comment.
There's a JsonResponse that might be more appropriate here
jennifer-richards
left a comment
There was a problem hiding this comment.
lgtm. Only nit I'm noticing (which I should have noticed before) is that we have copyright year ranges going back to 2016 or 2017 on newly added files. In some cases maybe this is appropriate if it's copied code, but I have generally started with only the current year in a new file if it's only standard boilerplate carried over from other places.
Don't know if we're consistent enough about this for it to be worthwhile to change (or if it's even appropriate).
|
@jennifer-richards i've updated the © |
Noting change was made on Nick's behalf
b21661c

Features
<iframe>pointing to a route showing the latest status message. If no site message is active it shows "No site status message.". The iframe is a<noscript><iframe src=></iframe></noscript>so only browser without JavaScript have this fallback.localStorage(ie per device and browser) not per user, so dismissed statuses aren't remembered on a different device and will need to be dismissed again./status