Skip to content

Commit 7c6013d

Browse files
committed
Merge branch 'announcement' into develop
2 parents 904691d + 869087a commit 7c6013d

File tree

14 files changed

+231
-76
lines changed

14 files changed

+231
-76
lines changed

core/admin.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ class Meta:
266266

267267

268268
class AnnouncementAdmin(CustomTimeMixin, PostAdmin):
269-
list_display = ["__str__", "organization", "status"]
269+
list_display = ["__str__", "organization", "organization_string", "status"]
270270
list_filter = [OrganizationListFilter, "status"]
271271
ordering = ["-show_after"]
272272
actions = [resend_approval_email]
@@ -302,7 +302,7 @@ def get_readonly_fields(self, request, obj=None):
302302

303303
all_fields = [
304304
"organization",
305-
"author",
305+
"organization_stringauthor",
306306
"title",
307307
"body",
308308
"tags",
@@ -319,6 +319,7 @@ def get_readonly_fields(self, request, obj=None):
319319
{
320320
"author",
321321
"organization",
322+
"organization_string",
322323
"title",
323324
"tags",
324325
"is_public",
@@ -327,6 +328,7 @@ def get_readonly_fields(self, request, obj=None):
327328
{
328329
"author",
329330
"organization",
331+
"organization_string",
330332
"title",
331333
"tags",
332334
"is_public",
@@ -335,6 +337,7 @@ def get_readonly_fields(self, request, obj=None):
335337
{
336338
"author",
337339
"organization",
340+
"organization_string",
338341
"title",
339342
"body",
340343
"tags",
@@ -346,6 +349,7 @@ def get_readonly_fields(self, request, obj=None):
346349
{
347350
"author",
348351
"organization",
352+
"organization_string",
349353
"title",
350354
"body",
351355
"tags",
@@ -356,18 +360,26 @@ def get_readonly_fields(self, request, obj=None):
356360
},
357361
],
358362
[
359-
{"author", "organization", "supervisor"},
360-
{"author", "organization", "status", "supervisor"},
363+
{"author", "organization", "organization_string", "supervisor"},
364+
{
365+
"author",
366+
"organization",
367+
"organization_string",
368+
"status",
369+
"supervisor",
370+
},
361371
{
362372
"author",
363373
"organization",
374+
"organization_string",
364375
"status",
365376
"show_after",
366377
"supervisor",
367378
},
368379
{
369380
"author",
370381
"organization",
382+
"organization_string",
371383
"status",
372384
"supervisor",
373385
"rejection_reason",
@@ -389,6 +401,7 @@ def get_readonly_fields(self, request, obj=None):
389401
def get_fields(self, request, obj=None):
390402
all_fields = [
391403
"organization",
404+
"organization_string",
392405
"author",
393406
"title",
394407
"body",
@@ -424,6 +437,7 @@ def get_exclude(self, request, obj=None):
424437
"body",
425438
"tags",
426439
"organization",
440+
"organization_string",
427441
"is_public",
428442
"supervisor",
429443
"status",

core/management/commands/auth_google.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
from django.core.management.base import BaseCommand, CommandError
22
from django.conf import settings
3-
from core.tasks import load_client
43
from pathlib import Path
54
import gspread
65

6+
from core.tasks import load_creds
7+
78

89
class Command(BaseCommand):
910
help = "Authenticates Google Account"
@@ -14,9 +15,9 @@ def handle(self, *args, **options):
1415
CLIENT_PATH = SECRETS_PATH + "/client_secret.json"
1516
AUTHORIZED_PATH = SECRETS_PATH + "/authorized_user.json"
1617

17-
client, error_msg, client_path_exists = load_client()
18+
creds, error_msg, client_path_exists = load_creds()
1819

19-
if client is None:
20+
if creds is None:
2021
if not client_path_exists:
2122
raise CommandError(error_msg)
2223
elif Path(AUTHORIZED_PATH).is_file():
@@ -29,7 +30,7 @@ def handle(self, *args, **options):
2930
Path(AUTHORIZED_PATH).unlink()
3031

3132
try:
32-
scopes = gspread.auth.READONLY_SCOPES
33+
scopes = settings.GOOGLE_SCOPES
3334

3435
gspread.oauth(
3536
credentials_filename=CLIENT_PATH,
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Generated by Django 5.1.13 on 2025-11-02 03:35
2+
3+
import django.db.models.deletion
4+
from django.db import migrations, models
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('core', '0079_alter_event_name'),
11+
]
12+
13+
operations = [
14+
migrations.AlterModelOptions(
15+
name='announcement',
16+
options={},
17+
),
18+
migrations.AddField(
19+
model_name='announcement',
20+
name='organization_string',
21+
field=models.CharField(blank=True, max_length=64, null=True),
22+
),
23+
migrations.AlterField(
24+
model_name='announcement',
25+
name='organization',
26+
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='announcements', related_query_name='announcement', to='core.organization'),
27+
),
28+
migrations.AddConstraint(
29+
model_name='announcement',
30+
constraint=models.CheckConstraint(condition=models.Q(('organization__isnull', False), ('organization_string__isnull', False), _connector='OR'), name='organization_or_organization_string_required'),
31+
),
32+
]

core/models/post.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,12 @@ class Announcement(Post):
259259
on_delete=models.CASCADE,
260260
related_name="announcements",
261261
related_query_name="announcement",
262+
blank=True,
263+
null=True,
262264
)
263265

266+
organization_string = models.CharField(max_length=64, blank=True, null=True)
267+
264268
is_public = models.BooleanField(
265269
default=True,
266270
help_text="Whether if this announcement pertains to the general school population, not just those in the organization.",
@@ -318,6 +322,15 @@ def approvable(self, user=None):
318322
return False
319323
return self.organization.supervisors.filter(user=user).exists()
320324

325+
class Meta:
326+
constraints = [
327+
models.CheckConstraint(
328+
name="organization_or_organization_string_required",
329+
check=models.Q(organization__isnull=False)
330+
| models.Q(organization_string__isnull=False),
331+
)
332+
]
333+
321334

322335
def featured_image_file_path_generator(instance, file_name):
323336
return file_upload_path_generator("featured_image")(instance, file_name)

core/static/core/css/announcement-detail.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@
7575
.card-authors a {
7676
font-weight: bold;
7777
}
78+
79+
.card-authors-text-string {
80+
color: var(--near-black);
81+
font-weight: bold;
82+
}
83+
7884
hr {
7985
border: 0px solid var(--light-grey);
8086
border-top-width: 2px;

core/static/core/css/announcement-list.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@
122122
.card-authors-text br {
123123
display: none;
124124
}
125+
126+
.card-authors-text-string {
127+
color: var(--near-black);
128+
font-weight: bold;
129+
}
130+
125131
.circle {
126132
-o-object-fit: cover;
127133
object-fit: cover;

core/static/core/css/index.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,12 @@ hr {
191191
color: var(--link-colour);
192192
font-weight: bold;
193193
}
194+
195+
.authors-text-string {
196+
color: var(--near-black);
197+
font-weight: bold;
198+
}
199+
194200
#recent-announcements{
195201
padding: 2%;
196202
}

0 commit comments

Comments
 (0)