diff --git a/apps/core/forms/photos.py b/apps/core/forms/photos.py index 883f3a2e..3be3f56c 100644 --- a/apps/core/forms/photos.py +++ b/apps/core/forms/photos.py @@ -13,8 +13,22 @@ class MultipleFileInput(forms.ClearableFileInput): allow_multiple_selected = True +class MultipleImageField(forms.ImageField): + def __init__(self, *args, **kwargs): + kwargs.setdefault("widget", MultipleFileInput()) + super().__init__(*args, **kwargs) + + def clean(self, data, initial=None): + single_file_clean = super().clean + if isinstance(data, (list, tuple)): + result = [single_file_clean(d, initial) for d in data] + else: + result = [single_file_clean(data, initial)] + return result + + class PhotoAlbumForm(forms.ModelForm): - photos = forms.ImageField(widget=MultipleFileInput(), required=False) + photos = MultipleImageField(widget=MultipleFileInput(), required=False) class Meta: model = PhotoAlbum @@ -57,17 +71,17 @@ def __init__(self, *args, **kwargs): class PhotoObjectForm(forms.ModelForm): - photo = forms.ImageField(widget=MultipleFileInput(), required=True) + photos = forms.ImageField(widget=MultipleFileInput(), required=True) class Meta: model = PhotoObject - fields = ["photo"] + fields = ["photos"] def __init__(self, *args, **kwargs): super(PhotoObjectForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_tag = False - self.helper.layout = Layout(Field("photo")) + self.helper.layout = Layout(Field("photos")) PHOTO_ALBUM_FUTURE_DATE = "future_photo_album" diff --git a/apps/core/static/cosmos/pdf/CodeOfConduct1-0-0.pdf b/apps/core/static/cosmos/pdf/CodeOfConduct1-0-0.pdf new file mode 100644 index 00000000..3a78f623 Binary files /dev/null and b/apps/core/static/cosmos/pdf/CodeOfConduct1-0-0.pdf differ diff --git a/apps/core/templates/resources.html b/apps/core/templates/resources.html index a0acb523..6ed206af 100644 --- a/apps/core/templates/resources.html +++ b/apps/core/templates/resources.html @@ -1,6 +1,7 @@ {% extends "subpage.html" %} {% block title %}Resources{% endblock title%} {% block content %} +{% load static %}
+ Everyone within Cosmos, in the Common Room, and at Cosmos events, including students, + staff, and guests, is entitled to fair treatment. The Code of Conduct details the rules that + we all have to follow, your rights, and who you can go to when you feel these rights + have been violated. +
++ The Code of Conduct is available + here, + and applies to anyone at a Cosmos event, and to any Cosmos + member in the Common Room. +
+ {% if user.is_authenticated %}Members' Initiative is a way for anyone to host events at Cosmos without the need to join an event organizing committee. Simply fill in the form, in which you outline your idea as well as the required budget, and we'll provide you with the means to make the event happen!
diff --git a/apps/core/views/photos.py b/apps/core/views/photos.py index 85ff0599..b33acab4 100644 --- a/apps/core/views/photos.py +++ b/apps/core/views/photos.py @@ -73,7 +73,7 @@ def photo_album_add_photo(request, pk): if request.method == "POST": print(request.FILES) - for img in request.FILES.getlist("photo"): + for img in request.FILES.getlist("photos"): PhotoObject.objects.create(album=album, photo=img) return redirect(reverse("cosmos_core:photo_album-view", kwargs={"pk": album.id})) else: