Skip to content

Commit

Permalink
merged rentalsport into branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Eline Evjen committed Nov 11, 2024
2 parents 12d34b3 + ee523fa commit dd5d3f3
Show file tree
Hide file tree
Showing 86 changed files with 1,346 additions and 950 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Black Code Formatter
uses: lgeiger/[email protected]
uses: HoiskolensChemikerforening/black-action@v1 #lgeiger/[email protected]
with:
args: "./chemie --check"
10 changes: 4 additions & 6 deletions chemie/cgp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,18 +321,16 @@ def get_sorted_groups_list(self):
.split(",")
)
vote_dict = {vote_list[i]: i for i in range(len(vote_list))}
voteable_groups = self.group.cgp.group_set.exclude(id=self.group.id).exclude(
audience=True
)
voteable_groups = self.group.cgp.group_set.exclude(
id=self.group.id
).exclude(audience=True)
# Place newly created groups not contained in the previous vote groups last
for group in voteable_groups:
if group.country.country_name not in vote_dict.keys():
vote_dict[group.country.country_name] = len(vote_list)

group_list = sorted(
list(
voteable_groups
),
list(voteable_groups),
key=lambda group: vote_dict[group.country.country_name],
)

Expand Down
10 changes: 9 additions & 1 deletion chemie/cgp/tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,17 @@ def setUp(self):
User.objects.create(username="g", password="f", email="[email protected]")
User.objects.create(username="h", password="hsfd", email="[email protected]")
self.country = Country.objects.create(country_name="heh", slug="heh")
self.country2 = Country.objects.create(
country_name="heh2", slug="heh2"
)

def test_group_form(self):
form = GroupForm(
self.cgp, None, data={"real_name": "hehe", "country": 1}
self.cgp,
None,
data={
"real_name": "hehe",
"country": self.country.id,
},
)
self.assertTrue(form.is_valid())
7 changes: 4 additions & 3 deletions chemie/cgp/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_index_GET(self):

response = self.client.get(self.index_url)

self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "cgp/index.html")

def test_vote_index_GET(self):
Expand All @@ -39,7 +39,7 @@ def test_vote_index_GET(self):
self.cgp.is_open = True
self.cgp.save()
response = self.client.get(self.vote_index_url)
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "cgp/vote_index.html")


Expand Down Expand Up @@ -168,6 +168,7 @@ def setUp(self):
4,
],
]

# Points 184 183 130 132
def generateVotes(array, voteString, fiaskovoteindex, showvoteindex):
for u in array:
Expand All @@ -189,4 +190,4 @@ def test_close_election(self):
self.cgp.toggle(self.users[0])
self.cgp.toggle(self.users[0])
audiencevote = Vote.objects.get(final_vote=True, group__audience=True)
self.assertEquals(audiencevote.vote[:11], "1c,2c,4c,3c")
self.assertEqual(audiencevote.vote[:11], "1c,2c,4c,3c")
1 change: 0 additions & 1 deletion chemie/cgp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ def vote_index(request, slug):
request, group
)


points = POINTS
if request.method == "POST":
if not request.POST.get("showprize") or not request.POST.get(
Expand Down
2 changes: 1 addition & 1 deletion chemie/cgp/views_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def group_add(request, cgp_id):
)
return redirect(reverse("cgp:cgp_edit", kwargs={"cgp_id": cgp_id}))

context = {"form": form, "type": "Gruppe", "cgp":cgp}
context = {"form": form, "type": "Gruppe", "cgp": cgp}
return render(request, "cgp/admin/forms.html", context)


Expand Down
1 change: 0 additions & 1 deletion chemie/chemie/management/commands/import_emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
EMAIL_TEMPLATE_DIR = os.path.join(settings.BASE_DIR, "emails", "")



class Command(BaseCommand):
help = (
"Command for importing email HTML-files. "
Expand Down
4 changes: 2 additions & 2 deletions chemie/chemie/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,9 +498,9 @@
["Maximize", "Find", "Replace"],
["Table"],
],
'extraPlugins': 'table',
"extraPlugins": "table",
"customConfig": "/static/js/ckeditor_config.js",
}
},
}

DEFAULT_CONFIG = CKEDITOR_CONFIGS
Expand Down
5 changes: 1 addition & 4 deletions chemie/chemie/settings/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,4 @@
}
}

CORS_ALLOWED_ORIGINS = [
"http://127.0.0.1:3000",
"http://localhost:3000",
]
CORS_ALLOWED_ORIGINS = ["http://127.0.0.1:3000", "http://localhost:3000"]
Binary file added chemie/chemie/static/images/Fotoboks-010.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chemie/chemie/static/images/JR-3832.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chemie/chemie/static/images/fotograf1.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chemie/chemie/static/images/fotograf2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions chemie/chemie/static/js/makeItRain.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ function selectSymbols(choose_your_holiday) {
return [ ]; // Return an empty array if the holiday is not recognized
}

const chosenHoliday = "webkom"; // Change this to select the holiday you want
const chosenHoliday = "mustache"; // Change this to select the holiday you want
const selectedSymbols = selectSymbols(chosenHoliday);

const maxElements = 100; // Maximum number of elements
const maxElements = 70; // Maximum number of elements

// Image width and hight
const imageWidth = 4 //rem
Expand Down
8 changes: 4 additions & 4 deletions chemie/chemie/templates/chemie/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
</head>

<body>
<div id="makeItRain"></div>
<!-- <div id="makeItRain"></div> -->
<header>
<nav class="top-nav">
<div class="container">
Expand Down Expand Up @@ -150,7 +150,7 @@ <h4 class="logo-text">Høiskolens Chemikerforening</h4>
<li><a href="{% url "frontpage:officeaccess" %}" class="waves-effect">Søknad om kontortilgang</a> </li>
<li><a href="{% url "frontpage:fundsapplication" %}" class="waves-effect">Søknad om midler</a></li>
<li><a href="{% url "refund:index" %}" class="waves-effect">Søknad om refusjon</a></li>
<li><a href="{% url "exchangepage:index" %}" class="waves-effect"> <div style="display: flex;flex-direction: row;justify-items: center; align-items: center">Utvekslingsside <i class="material-icons" style="padding-left: 10px">new_releases</i></div></a></li>
<li><a href="{% url "exchangepage:index" %}" class="waves-effect">Utvekslingsside</a></li>
<li><a href="{% url "elections:index" %}" class="waves-effect">Valg</a></li>
<li><a href="{% url "electofood:index_valgomat" %}" class="waves-effect">Valgomat</a></li>
<li><a href="{% url "wiki:root" %}" class="waves-effect">Wiki</a></li>
Expand All @@ -169,8 +169,8 @@ <h4 class="logo-text">Høiskolens Chemikerforening</h4>
<li class="bold"><a class="collapsible-header waves-effect"><i class="material-icons micon">shopping_cart</i>Utleie</a>
<div class="collapsible-body">
<ul>
<li><a href="{% url 'rentalservice:index' %}" class="waves-effect">Audiochromatene</a></li>
<li><a href="{% url 'rentalservice:index_promo' %}" class="waves-effect">Promoteringskomiteen</a></li>
<li><a href="{% url 'rentalservice:index' %}" class="waves-effect">Lyd og lys</a></li>
<li><a href="{% url 'rentalservice:index_promo' %}" class="waves-effect">Foto</a></li>
<li><a href="{% url 'rentalservice:index_sportskom' %}" class="waves-effect">Sportskomiteen</a></li>
</ul>
</div>
Expand Down
9 changes: 6 additions & 3 deletions chemie/chemie/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,12 @@
"utleie/",
include("chemie.rentalservice.urls", namespace="rentalservice"),
),
path("cgp/",include("chemie.cgp.urls", namespace="cgp")),
path("valgomat/",include("chemie.electofood.urls", namespace="valgomat")),
path("reisebrev/", include("chemie.exchangepage.urls", namespace="reisebrev")),
path("cgp/", include("chemie.cgp.urls", namespace="cgp")),
path("valgomat/", include("chemie.electofood.urls", namespace="valgomat")),
path(
"reisebrev/",
include("chemie.exchangepage.urls", namespace="reisebrev"),
),
# For authentication
path(
"api/token/",
Expand Down
18 changes: 18 additions & 0 deletions chemie/committees/migrations/0004_committee_committee_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.28 on 2024-11-09 10:51

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('committees', '0003_auto_20180127_0949'),
]

operations = [
migrations.AddField(
model_name='committee',
name='committee_type',
field=models.PositiveSmallIntegerField(choices=[(1, 'Kommitee'), (2, 'Undergruppe'), (3, 'Organisasjon med særskilt tilknytning')], default=1, verbose_name='gruppe_type'),
),
]
13 changes: 12 additions & 1 deletion chemie/committees/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
from django.dispatch import receiver
from django.utils.text import slugify
from sorl.thumbnail import ImageField
from extended_choices import Choices

COMMITTEE_TYPE = Choices(
("COMMITTEE", 1, "Komité"),
("SUBGROUP", 2, "Undergruppe"),
("ASSOSIATEDGROUP", 3, "Organisasjon med særskilt tilknytning"),
)


class Committee(models.Model):
Expand All @@ -19,6 +26,11 @@ class Committee(models.Model):
description = RichTextField(
verbose_name="Beskrivelse", config_name="committees"
)
committee_type = models.PositiveSmallIntegerField(
choices=COMMITTEE_TYPE,
default=COMMITTEE_TYPE.COMMITTEE,
verbose_name="gruppe_type",
)

def __str__(self):
return self.title
Expand Down Expand Up @@ -54,7 +66,6 @@ def add_to_group(self, users):
def consistent_permissions(
sender, instance, action, reverse, model, pk_set, **kwargs
):

if action == "pre_add":
if len(pk_set) + instance.users.count() > instance.max_members:
raise ValidationError(
Expand Down
85 changes: 49 additions & 36 deletions chemie/committees/templates/committees/list_committees.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,47 +10,60 @@
</div>
{% endblock nav_sub_header %}


{% block content %}
<div class="row">
<div class="col s12">
<ul class="tabs z-depth-1">
<li class="tab col s4 m4 l4"><a href="#committee" style="text-transform: initial">Komitteer</a></li>
<li class="tab col s5 m4 l4"><a href="#subgroup" style="text-transform: initial">Undergrupper</a></li>
<li class="tab col s4 m4 l4 hide-on-small-only"><a href="#associatedgroup" style="text-transform: initial">Særskilt tilknytning</a></li>
<li class="tab col s3 m4 l4 hide-on-med-and-up"><a href="#associatedgroup" style="text-transform: initial">Særskilt</a></li>
</ul>
</div>
</div>

{% for type, committees in committees_by_type.items %}
<div id="{{ type|lower }}" class="col s12">
<div class="row">
{% for committee in committees %}
<div class="col s12 m6 l4">
<div class="card small" style="height: 320px">
<div class="card-image">
<a href="{{ committee.get_absolute_url }}">
{% thumbnail committee.image "400x300" crop="center" as im %}
<img src="{{ im.url }}">
{% endthumbnail %}
</a>
<a class="card-title card-event-title" href="{{ committee.get_absolute_url }}">
<h5 class="truncate" style="font-size: 1.54rem;">{{ committee.title }}</h5>
</a>
</div>
<div class="card-content">
<p>{{ committee.one_liner }}</p>
</div>
<div class="card-action">
<div class="row valign-wrapper" style="margin: 0">
<div class="col s8 m8 l8">
<a href="{{ committee.get_absolute_url }}">Detaljer</a>
</div>
<div class="col s4 m4 l4" style="display: flex;justify-content: right">
<a href="mailto:{{ committee.email }}" class="valign-wrapper" style="margin: 0">
<i class="material-icons valign small">email</i>
</a>
</div>
</div>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
{% endfor %}

<style>
.card .card-image .card-title {
padding: 10px;
}
</style>
<div class="row">
{% for committee in committees %}
<div class="col s12 m6 l4">
<div class="card small" style="height: 320px">
<div class="card-image">
<a href="{{ committee.get_absolute_url }}">
{% thumbnail committee.image "400x300" crop="center" as im %}
<img src="{{ im.url }}">
{% endthumbnail %}
</a>
<a class="card-title card-event-title" href="{{ committee.get_absolute_url }}">
<h5 class="truncate" style="font-size: 1.54rem;">{{ committee.title }}</h5>
</a>
</div>
<div class="card-content">
<p>
{{ committee.one_liner }}
</p>
</div>
<div class="card-action">
<div class="row valign-wrapper" style="margin: 0">
<div class="col s8 m8 l8">
<a href="{{ committee.get_absolute_url }}">Detaljer</a>
</div>
<div class="col s4 m4 l4" style="display: flex;justify-content: right">
<a href="mailto:{{ committee.email }}" class="valign-wrapper" style="margin: 0">
<i class="material-icons valign small">email</i>
</a>
</div>
</div>
</div>
</div>
</div>
{% endfor %}
</div>

{% endblock %}
4 changes: 3 additions & 1 deletion chemie/committees/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
path(
"<slug:slug>/rediger/", views.edit_description, name="edit_description"
),
path("<slug:slug>/epost/", views.email_download_view, name="download_email"),
path(
"<slug:slug>/epost/", views.email_download_view, name="download_email"
),
path(
"<slug:slug>/rediger-medlemmmer/",
views.edit_committee_memberships,
Expand Down
20 changes: 15 additions & 5 deletions chemie/committees/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ def index(request):
# Fetch all members, who belong to a committee (Member -> Committee)
# Group all these members by the committee type
committees = Committee.objects.order_by("title")
context = {"committees": committees}
committees_by_type = {
"COMMITTEE": committees.filter(committee_type=1),
"SUBGROUP": committees.filter(committee_type=2),
"ASSOCIATEDGROUP": committees.filter(committee_type=3),
}
context = {"committees_by_type": committees_by_type}

return render(request, "committees/list_committees.html", context)

Expand All @@ -41,7 +46,9 @@ def email_download_view(request, slug):
committee = get_object_or_404(Committee, slug=slug)

# check permissions
no_permissions, redirect_target = check_if_admin_of_group(request, committee, slug)
no_permissions, redirect_target = check_if_admin_of_group(
request, committee, slug
)
if no_permissions:
return redirect_target

Expand Down Expand Up @@ -79,8 +86,9 @@ def check_if_admin_of_group(request, committee, slug):
"Du har bare lov å endre egne undergrupper.",
extra_tags="Manglende rettigheter!",
)
return True, redirect(
reverse("verv:committee_detail", kwargs={"slug": slug})
return (
True,
redirect(reverse("verv:committee_detail", kwargs={"slug": slug})),
)
return False, None

Expand All @@ -90,7 +98,9 @@ def edit_description(request, slug):
committee = get_object_or_404(Committee, slug=slug)

# check permissions
no_permissions, redirect_target = check_if_admin_of_group(request, committee, slug)
no_permissions, redirect_target = check_if_admin_of_group(
request, committee, slug
)
if no_permissions:
return redirect_target

Expand Down
Loading

0 comments on commit dd5d3f3

Please sign in to comment.