mirror of
https://github.com/ae-utbm/sith.git
synced 2025-02-27 01:47:14 +00:00
Apply review comments
This commit is contained in:
parent
92d282f4ba
commit
f9c36c8f99
@ -5,7 +5,7 @@ from typing import final
|
||||
import requests
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from django.conf import settings
|
||||
from django.db.models import QuerySet
|
||||
from django.db.models import F, QuerySet
|
||||
from django.urls import reverse
|
||||
from django.utils import timezone
|
||||
from ical.calendar import Calendar
|
||||
@ -80,11 +80,11 @@ class IcsCalendar:
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def ics_from_queryset(cls, queryset: QuerySet) -> bytes:
|
||||
def ics_from_queryset(cls, queryset: QuerySet[NewsDate]) -> bytes:
|
||||
calendar = Calendar()
|
||||
for news_date in queryset.prefetch_related("news"):
|
||||
for news_date in queryset.annotate(news_title=F("news__title")):
|
||||
event = Event(
|
||||
summary=news_date.news.title,
|
||||
summary=news_date.news_title,
|
||||
start=news_date.start_date,
|
||||
end=news_date.end_date,
|
||||
url=reverse("com:news_detail", kwargs={"news_id": news_date.news.id}),
|
||||
|
@ -68,7 +68,6 @@ export class IcsCalendar extends inheritHtmlElement("div") {
|
||||
}
|
||||
|
||||
getNewsId(event: EventImpl) {
|
||||
// return Number.parseInt(event.url.split("/").pop());
|
||||
return Number.parseInt(
|
||||
event.url
|
||||
.toString()
|
||||
@ -80,6 +79,9 @@ export class IcsCalendar extends inheritHtmlElement("div") {
|
||||
|
||||
async refreshEvents() {
|
||||
this.click(); // Remove focus from popup
|
||||
// We can't just refresh events because some ics files are in
|
||||
// local browser cache (especially internal.ics)
|
||||
// To invalidate the cache, we need to remove the source and add it again
|
||||
this.calendar.removeAllEventSources();
|
||||
for (const source of await this.getEventSources()) {
|
||||
this.calendar.addEventSource(source);
|
||||
@ -198,7 +200,7 @@ export class IcsCalendar extends inheritHtmlElement("div") {
|
||||
};
|
||||
|
||||
const makePopupTools = (event: EventImpl) => {
|
||||
if (event.source.internalEventSource.ui.classNames.indexOf("external") >= 0) {
|
||||
if (event.source.internalEventSource.ui.classNames.includes("external")) {
|
||||
return null;
|
||||
}
|
||||
if (!(this.canDelete || this.canModerate)) {
|
||||
@ -207,9 +209,7 @@ export class IcsCalendar extends inheritHtmlElement("div") {
|
||||
const newsId = this.getNewsId(event);
|
||||
const div = document.createElement("div");
|
||||
if (this.canModerate) {
|
||||
if (
|
||||
event.source.internalEventSource.ui.classNames.indexOf("unmoderated") >= 0
|
||||
) {
|
||||
if (event.source.internalEventSource.ui.classNames.includes("unmoderated")) {
|
||||
const button = document.createElement("button");
|
||||
button.innerHTML = `<i class="fa fa-check"></i>${gettext("Moderate")}`;
|
||||
button.setAttribute("class", "btn btn-green");
|
||||
|
@ -12,6 +12,7 @@
|
||||
"esModuleInterop": true,
|
||||
"resolveJsonModule": true,
|
||||
"types": ["jquery", "alpinejs"],
|
||||
"lib": ["es7"],
|
||||
"paths": {
|
||||
"#openapi": ["./staticfiles/generated/openapi/index.ts"],
|
||||
"#core:*": ["./core/static/bundled/*"],
|
||||
|
Loading…
x
Reference in New Issue
Block a user