Skip to content

Commit 131b4de

Browse files
authored
Merge pull request #5 from UWCS/publicity
Publicity
2 parents 95871f8 + 00742ac commit 131b4de

File tree

10 files changed

+188
-108
lines changed

10 files changed

+188
-108
lines changed

USER.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ An event can be edited by going to its permalink and clicking the edit button in
7070

7171
Follow the steps to edit an event, but once in the edit form scroll to the bottom and click the delete button. Confirm your chouse and the event will be deleted. THIS CANNOT BE UNDONE.
7272

73-
## iCal
73+
## [iCal](https://events.uwcs.co.uk/uwcs.ics)
7474

7575
An ical feed for all events is available at `/uwcs.ics`. This can be added to any calendar application that supports ical feeds, such as Google Calendar or Outlook. Note that the feed is read-only, and any changes made to events on the site will be reflected in the feed.
7676

77-
## Publicity
77+
## [Publicity](https://events.uwcs.co.uk/exec/publicity/)
7878

7979
An exec-only endpoint for creating single week calendars is available at `/exec/publicity/`.
8080

@@ -86,4 +86,4 @@ If the generated SVG looks good, it can be downloaded direct to PNG via the `Sav
8686

8787
### Multi week calendar
8888

89-
soonTM
89+
Same as single week calendar, but select a different `End Week`. Note if more than 4 events are in a single day, only the first 4 will be shown.

auth/api.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,7 @@
22
from functools import wraps
33
from typing import Callable
44

5-
from flask import (
6-
Blueprint,
7-
abort,
8-
flash,
9-
jsonify,
10-
redirect,
11-
render_template,
12-
request,
13-
url_for,
14-
)
5+
from flask import Blueprint, abort, flash, jsonify, redirect, render_template, request, url_for
156
from werkzeug.security import check_password_hash, generate_password_hash
167
from werkzeug.wrappers import Response
178

config.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@
3939
phosphor_icons = sorted(
4040
set(
4141
re.findall(
42-
r"\.ph-bold\.ph-([a-z0-9-]+):before",
43-
Path("static/icons/phosphor-bold.css").read_text(),
42+
r"\.ph-bold\.ph-([a-z0-9-]+):before", Path("static/icons/phosphor-bold.css").read_text()
4443
)
4544
)
4645
)
@@ -51,11 +50,7 @@
5150
phosphor_icon_paths = json.loads(Path("icons.json").read_text())
5251

5352
custom_icon_paths = {
54-
icon: re.search(
55-
r"<path d=\"([^\"]+)\"", Path(f"static/icons/{icon}.svg").read_text()
56-
).group( # type: ignore
57-
1
58-
)
53+
icon: re.search(r"<path d=\"([^\"]+)\"", Path(f"static/icons/{icon}.svg").read_text()).group(1) # type: ignore
5954
for icon in custom_icons
6055
}
6156

events/api.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -319,13 +319,7 @@ def create_event_api() -> tuple[Response, int]: # noqa: PLR0911
319319
if not data:
320320
return jsonify({"error": "No data provided"}), 400
321321

322-
required_fields = [
323-
"name",
324-
"description",
325-
"location",
326-
"start_time",
327-
"end_time",
328-
]
322+
required_fields = ["name", "description", "location", "start_time", "end_time"]
329323

330324
for field in required_fields:
331325
if field not in data:
@@ -444,13 +438,7 @@ def create_repeat_event_api() -> tuple[Response, int]: # noqa: PLR0911
444438
if not data:
445439
return jsonify({"error": "No data provided"}), 400
446440

447-
required_fields = [
448-
"name",
449-
"description",
450-
"location",
451-
"start_times",
452-
"end_times",
453-
]
441+
required_fields = ["name", "description", "location", "start_times", "end_times"]
454442

455443
for field in required_fields:
456444
if field not in data:

events/ui.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ def get_event_from_form(form_data: ImmutableMultiDict) -> dict:
4444
"text_colour": (form_data["text_colour"] if form_data["text_colour"] != "" else None),
4545
"color_colour": (form_data["color_colour"] if form_data["color_colour"] != "" else None),
4646
"times": zip(
47-
form_data.getlist("start_time[]"),
48-
form_data.getlist("end_time[]"),
49-
strict=True,
47+
form_data.getlist("start_time[]"), form_data.getlist("end_time[]"), strict=True
5048
),
5149
"duration": (form_data["duration"] if form_data["duration"] != "" else None),
5250
"tags": [tag for tag in form_data.getlist("tags[]") if tag],
@@ -271,10 +269,7 @@ def view(year: int, term: int, week: int, slug: str) -> str:
271269

272270
event = prepare_event(event)
273271

274-
return render_template(
275-
"events/event.html",
276-
event=event,
277-
)
272+
return render_template("events/event.html", event=event)
278273

279274

280275
@events_ui_bp.route("/<int:year>/")
@@ -345,8 +340,7 @@ def get_calendar(events: list[Event]) -> Calendar:
345340
ical_event.add("uid", f"{event.id}@uwcs-fulcrum")
346341
ical_event.add("dtstart", event.start_time)
347342
ical_event.add(
348-
"dtend",
349-
event.end_time if event.end_time else event.start_time + timedelta(hours=1),
343+
"dtend", event.end_time if event.end_time else event.start_time + timedelta(hours=1)
350344
)
351345
ical_event.add("dtstamp", datetime.now(timezone("Europe/London")))
352346
ical_event.add(

events/utils.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ def create_event( # noqa: PLR0913
107107
if get_event_by_slug(week.academic_year, week.term, week.week, event.slug):
108108
db.session.rollback()
109109
return (
110-
f"An event with the name '{event.slug}' already exists in "
111-
f"{week.academic_year} t{week.term} w{week.week}"
110+
f"An event with the name '{event.slug}' already "
111+
f"exists in {week.academic_year} t{week.term} w{week.week}"
112112
)
113113

114114
# add the event to db to allow tags
@@ -401,10 +401,7 @@ def group_events(events: list[Event]) -> list[dict]:
401401
start_date = next(iter(days.values()))[0].week.start_date
402402
for day, day_events in days.items():
403403
day_list.append(
404-
{
405-
"day": day,
406-
"events": [prepare_event(event) for event in day_events],
407-
}
404+
{"day": day, "events": [prepare_event(event) for event in day_events]}
408405
)
409406
week_list.append({"week": week, "days": day_list, "start_date": start_date})
410407
term_list.append({"term": term, "weeks": week_list})

0 commit comments

Comments
 (0)