Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deployment #343

Merged
merged 87 commits into from
Mar 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
0af9229
I made the application FAQ and added it to settings and urls, then
eirikamb Oct 18, 2020
c3e9a00
Added FAQ.html as a MainPage and kept 3dprinter.html to 3dprinter FAQ
eirikamb Oct 18, 2020
b64ff05
Started on the html part of the page
eirikamb Oct 20, 2020
b7f4c47
Fixed accordion UI element
eirikamb Oct 22, 2020
8245958
Made the accordion nested, so now the outer accordion is categories a…
eirikamb Oct 22, 2020
28255b9
First draft of Faq page
eirikamb Oct 27, 2020
845dd92
Added translations
eirikamb Oct 27, 2020
b3b93c2
Finished first version of FAQ
eirikamb Oct 29, 2020
9d33c6d
add internal mainpage
sigridge Oct 30, 2020
99148a6
Merge remote-tracking branch 'origin/dev' into FAQ/Eirik
eirikamb Nov 3, 2020
ae8e5f7
Merged dev and fixed permission errors
eirikamb Nov 3, 2020
896318a
add newline to end of home.css file
sigridge Nov 5, 2020
697683d
Changed icon on admin page, removed unnecessary translation and added…
eirikamb Nov 12, 2020
0770717
Froze requirements' version numbers
ddabble Dec 8, 2020
05f0635
Added dependabot.yml
ddabble Dec 8, 2020
2614d04
Customized dependabot.yml
ddabble Dec 8, 2020
ef6281c
Added codeql-analysis.yml
ddabble Dec 8, 2020
33e7b6e
Customized codeql-analysis.yml
ddabble Dec 8, 2020
666754d
Fixed CodeQL action error
ddabble Dec 8, 2020
0e41327
Reordered INSTALLED_APPS setting
ddabble Dec 3, 2020
06efeef
Cleaned up settings file
ddabble Jan 17, 2021
8a85be0
Support overriding at the end of settings.py
ddabble Jan 17, 2021
8694c49
Fixed not redirecting to subdomains after login
ddabble Jan 17, 2021
45022b5
Merge pull request #335 from MAKENTNU/feat/github-scanning
ddabble Jan 23, 2021
8e8c113
Merge pull request #336 from MAKENTNU/fix/settings
ddabble Jan 23, 2021
cad9a81
Renamed make (reservation) to create
ddabble Oct 17, 2020
86f8847
Renamed files with - or _ to match convention
ddabble Oct 17, 2020
b956931
Deleted CategoryAdmin as it will not show on admin page. Also renamed…
eirikamb Jan 25, 2021
59f3ff4
Whitespace changes
eirikamb Jan 25, 2021
d5a592d
Remade CategoryAdmin class
eirikamb Jan 25, 2021
2bb19b8
Mostly formatting changes
eirikamb Jan 25, 2021
d875afa
URL pattern changes
eirikamb Jan 25, 2021
ad19939
Changed order of rules and FAQ page in web header
eirikamb Jan 25, 2021
e4af31d
Changed bug due to change in URL from FAQ to faq
eirikamb Jan 25, 2021
db7765b
Renamed files
eirikamb Jan 25, 2021
fbc8863
One more file name change
eirikamb Jan 25, 2021
8a7d350
Fixed wrong script syntax
eirikamb Jan 25, 2021
4a327b6
Fixed FAQ-admin missing reverse_lazy bug
eirikamb Jan 25, 2021
6af0c26
Removed max lenght in questions and categories
eirikamb Jan 25, 2021
e9026e3
Some renames and deleted some superfluous lines
eirikamb Jan 25, 2021
8caa53f
Made migrations
eirikamb Jan 25, 2021
1c390b3
Moved web's templatetags to util
ddabble Dec 3, 2020
04c1642
Tidied up model + form fields and validators
ddabble Dec 4, 2020
2e592d7
Moved web/js/widgets to forms folder
ddabble Dec 26, 2020
83ac158
Renamed template and static files for consistency
ddabble Jan 31, 2021
190f585
Compiled translations + updated comments
ddabble Jan 31, 2021
987b5cd
Merge remote-tracking branch 'origin/dev' into FAQ/Eirik
eirikamb Feb 3, 2021
1b57378
Merged dev into branch
eirikamb Feb 3, 2021
9af44bc
Small code cleanup
ddabble Feb 5, 2021
73015f0
Removed superfluous add permission from Question
ddabble Feb 5, 2021
1cbca71
Merge pull request #323 from MAKENTNU/FAQ/Eirik
ddabble Feb 5, 2021
7b214c0
Merge remote-tracking branch 'origin/dev' into fix/filenames-and-fold…
ddabble Feb 5, 2021
a4fcdd4
Merge pull request #337 from MAKENTNU/fix/filenames-and-folder-structure
ddabble Feb 5, 2021
bba0584
reformat code
sigridge Feb 15, 2021
dee53c0
Merge remote-tracking branch 'origin/dev' into feature/mainpage-internal
sigridge Feb 15, 2021
d1b36a5
Renamed HomeView, removed duplication in urls.py
sigridge Feb 16, 2021
f9adb84
Merge pull request #324 from MAKENTNU/feature/mainpage-internal
ddabble Feb 16, 2021
c2322d7
Fixed weird scaling on mobile + font sizes
ddabble Oct 31, 2020
54f6ac4
Made the Ubuntu font apply everywhere
ddabble Oct 31, 2020
412e53f
Whitespace cleanup
ddabble Oct 31, 2020
5b7dcc3
Made the usage of MAKE's colors consistent
ddabble Oct 31, 2020
a1998f8
Fixed various sizing and layout issues + cleanup
ddabble Nov 2, 2020
e98ff98
Overhauled design of committee and equipment admin
ddabble Nov 2, 2020
7bcac45
Added custom template for EditUsageRulesView
ddabble Nov 3, 2020
1fc65d9
Made edit/save/cancel buttons consistent
ddabble Nov 3, 2020
329355c
Added missing priority field to machine edit form
ddabble Nov 3, 2020
c6f2b45
Added target="_blank" to some links
ddabble Nov 3, 2020
52e72fe
Fixed CategoryAdmin missing from Django admin
ddabble Feb 6, 2021
eb3117e
Fixed failing contentbox tests
ddabble Feb 6, 2021
81d962d
Replaced unnecessary `re_path()`
ddabble Feb 6, 2021
842e7b4
Compiled translations + updated comments
ddabble Feb 6, 2021
655646b
Fix buggy case where there are no rules covering a reservation
zootos Mar 3, 2021
48c2dc7
Documentation
zootos Mar 3, 2021
48f3ae1
Test for empty time period and reservation rules
zootos Mar 3, 2021
5c88326
Fix whitespace in dates, that caused errors in the frontend when a re…
zootos Mar 3, 2021
7682b37
Error message on same start and end time
zootos Mar 3, 2021
ca04c8f
Error message for when the machine is not reservable
zootos Mar 3, 2021
449ee2b
Translations
zootos Mar 3, 2021
c02d3b8
Fix failing tests due to changed error messages
zootos Mar 3, 2021
e8178ff
Merge pull request #339 from MAKENTNU/fix/reservation-error
sigridge Mar 4, 2021
baecfeb
Fix download issue when hitting 'search' on mobile
zootos Mar 4, 2021
1eee0e9
Searching now actually hides users on mobile
zootos Mar 4, 2021
231fe7b
Merge pull request #340 from MAKENTNU/fix/course-registration
zootos Mar 5, 2021
2f48497
Improved design of event ticket email copy button
ddabble Mar 7, 2021
69b2f52
Merge remote-tracking branch 'origin/dev' into fix/design-and-layout-…
ddabble Mar 8, 2021
f566d0f
Merge pull request #338 from MAKENTNU/fix/design-and-layout-cleanup
ddabble Mar 8, 2021
8cced3f
Merge branch 'master' into dev
sigridge Mar 10, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "daily"
commit-message:
prefix: ":arrow_up:"
include: "scope"

- package-ecosystem: "github-actions"
# Workflow files stored in the
# default location of `.github/workflows`
directory: "/"
schedule:
interval: "weekly"
commit-message:
prefix: ":construction_worker:"
include: "scope"
61 changes: 61 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: "CodeQL"

on:
push:
branches: [ master, dev ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master, dev ]
schedule:
# Runs at 03:45 UTC every day
- cron: '45 3 * * *'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
language: [ 'python', 'javascript' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install System Dependencies
run: |
sudo apt update && sudo apt install python-dev libldap2-dev libsasl2-dev libssl-dev

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ coverage.xml
# Django stuff:
*.log
local_settings.py
local_settings_post.py
media/

# Flask stuff:
Expand Down
3 changes: 2 additions & 1 deletion announcements/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.contrib import admin

from announcements.models import Announcement
from web.multilingual.database import MultiLingualFieldAdmin
from web.multilingual.admin import MultiLingualFieldAdmin


admin.site.register(Announcement, MultiLingualFieldAdmin)
4 changes: 2 additions & 2 deletions announcements/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import datetime
from django.db import migrations, models
import web.multilingual.database
import web.multilingual.modelfields


class Migration(migrations.Migration):
Expand All @@ -19,7 +19,7 @@ class Migration(migrations.Migration):
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('classification', models.CharField(choices=[('I', 'Information'), ('W', 'Warning message'), ('E', 'Error message')], default='I', max_length=1, verbose_name='Type')),
('site_wide', models.BooleanField(verbose_name='Site-wide')),
('content', web.multilingual.database.MultiLingualTextField(max_length=256, verbose_name='Content')),
('content', web.multilingual.modelfields.MultiLingualTextField(max_length=256, verbose_name='Content')),
('link', models.CharField(blank=True, max_length=2048, null=True, verbose_name='Link')),
('display_from', models.DateTimeField(default=datetime.datetime(2020, 3, 14, 13, 57, 40, 9695), verbose_name='Display from')),
('display_to', models.DateTimeField(blank=True, null=True, verbose_name='Display to')),
Expand Down
11 changes: 6 additions & 5 deletions announcements/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.utils import timezone
from django.utils.translation import gettext_lazy as _

from web.multilingual.database import MultiLingualTextField
from web.multilingual.modelfields import MultiLingualTextField


class AnnouncementManager(models.Manager):
Expand All @@ -27,27 +27,28 @@ class Announcement(models.Model):
Model for general announcements. All announcements are time-based, but can be shown for an indefinite time period if
there is no end time given. An announcement may also link to another page with more information.
"""
objects = AnnouncementManager()

class AnnouncementType(models.TextChoices):
INFO = "I", _("Information")
WARNING = "W", _("Warning")
CRITICAL = "C", _("Critical")

classification = models.CharField(max_length=1, choices=AnnouncementType.choices, default=AnnouncementType.INFO,
classification = models.CharField(choices=AnnouncementType.choices, max_length=1, default=AnnouncementType.INFO,
verbose_name=_("Type"))
site_wide = models.BooleanField(verbose_name=_("Site-wide"),
help_text=_("If selected, the announcement will be shown on all pages, otherwise it"
" is only shown on the front page."))
content = MultiLingualTextField(max_length=256, verbose_name=_("Content"))
link = models.CharField(max_length=2048, verbose_name=_("Link"), blank=True, null=True,
link = models.CharField(max_length=2048, null=True, blank=True, verbose_name=_("Link"),
help_text=_("An optional link to an information page."))
display_from = models.DateTimeField(default=timezone.localtime, verbose_name=_("Display from"),
help_text=_("The date from which the announcement will be shown."))
display_to = models.DateTimeField(blank=True, null=True, verbose_name=_("Display to"),
display_to = models.DateTimeField(null=True, blank=True, verbose_name=_("Display to"),
help_text=_("The announcement will be shown until this date. If none is given, it"
" is shown indefinitely."))

objects = AnnouncementManager()

def __str__(self):
return f"{self.get_classification_display()}: {self.content}"

Expand Down
3 changes: 2 additions & 1 deletion announcements/templates/announcements/announcement.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{% load announcement_tags %}


<div class="{% announcement_css_class announcement %} announcement">
{% if announcement.link %}
<a href="{{ announcement.link }}">
<a href="{{ announcement.link }}" target="_blank">
{{ announcement.content }}
</a>
{% else %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{% extends "web/base.html" %}
{% load i18n %}


{% block body %}
<div class="ui container">
<h1>
Expand All @@ -19,7 +20,7 @@ <h1>
{{ announcement.get_classification_display }}
{% if perms.announcements.change_announcement %}
<a href="{% url "edit_announcement" pk=announcement.pk %}">
<i class="yellow pencil icon"></i>
<i class="make-col-yellow pencil icon"></i>
</a>
{% endif %}
{% if perms.announcements.delete_announcement %}
Expand All @@ -30,9 +31,9 @@ <h1>
</div>
<div class="meta">
{% if announcement.site_wide %}
<i class="ui yellow globe icon"></i>{% trans "Site-wide" %}
<i class="ui make-col-yellow globe icon"></i>{% trans "Site-wide" %}
{% else %}
<i class="ui yellow home icon"></i>{% trans "Front page" %}
<i class="ui make-col-yellow home icon"></i>{% trans "Front page" %}
{% endif %}
</div>
<div class="description">{{ announcement.content }}</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{% extends "web/base.html" %}
{% load i18n %}


{% block body %}
<div class="ui container">
<h1>{% block header_text %}{% trans "New Announcement" %}{% endblock %}</h1>
Expand All @@ -14,7 +15,7 @@ <h1>{% block header_text %}{% trans "New Announcement" %}{% endblock %}</h1>
<div class="ui field">
<label>{{ form.link.label }}
<span data-content="{{ form.link.help_text }}">
<i class="ui yellow question circle icon"></i>
<i class="ui make-col-yellow question circle icon"></i>
</span>
</label>
{{ form.link }}
Expand All @@ -24,15 +25,15 @@ <h1>{% block header_text %}{% trans "New Announcement" %}{% endblock %}</h1>
<div class="ui field">
<label>{{ form.display_from.label }}
<span data-content="{{ form.display_from.help_text }}">
<i class="ui yellow question circle icon"></i>
<i class="ui make-col-yellow question circle icon"></i>
</span>
</label>
{{ form.display_from }}
</div>
<div class="ui field">
<label>{{ form.display_to.label }}
<span data-content="{{ form.display_to.help_text }}">
<i class="ui yellow question circle icon"></i>
<i class="ui make-col-yellow question circle icon"></i>
</span>
</label>
{{ form.display_to }}
Expand All @@ -45,12 +46,12 @@ <h1>{% block header_text %}{% trans "New Announcement" %}{% endblock %}</h1>
<div class="ui field">
<label>{{ form.site_wide.label }}
<span data-content="{{ form.site_wide.help_text }}">
<i class="ui yellow question circle icon"></i>
<i class="ui make-col-yellow question circle icon"></i>
</span>
</label>
{{ form.site_wide }}
</div>
<button class="ui right floated yellow button">
<button class="ui right floated make-bg-yellow button">
{% trans "Save" %}
</button>
<a class="ui right floated red button" href="{% url "announcement_admin" %}">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{% extends "announcements/create_announcement.html" %}
{% extends "announcements/announcement_create.html" %}
{% load i18n %}


{% block header_text %}
{% trans "Edit Announcement" %}
{% endblock %}
Expand Down
1 change: 1 addition & 0 deletions announcements/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from announcements.views import AnnouncementAdminView, CreateAnnouncementView, EditAnnouncementView, \
DeleteAnnouncementView


urlpatterns = [
path('admin/', AnnouncementAdminView.as_view(), name="announcement_admin"),
path('create/', CreateAnnouncementView.as_view(), name="create_announcement"),
Expand Down
22 changes: 7 additions & 15 deletions announcements/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,29 @@


class AnnouncementAdminView(PermissionRequiredMixin, ListView):
permission_required = ("announcements.change_announcement",)
model = Announcement
template_name = "announcements/announcements_admin.html"
template_name = "announcements/announcement_admin.html"
context_object_name = "announcements"
permission_required = (
"announcements.change_announcement",
)


class CreateAnnouncementView(PermissionRequiredMixin, CreateView):
permission_required = ("announcements.add_announcement",)
model = Announcement,
template_name = "announcements/create_announcement.html"
form_class = AnnouncementForm
permission_required = (
"announcements.add_announcement",
)
template_name = "announcements/announcement_create.html"
success_url = reverse_lazy("announcement_admin")


class EditAnnouncementView(PermissionRequiredMixin, UpdateView):
permission_required = ("announcements.change_announcement",)
model = Announcement
template_name = "announcements/edit_announcement.html"
form_class = AnnouncementForm
permission_required = (
"announcements.change_announcement",
)
template_name = "announcements/announcement_edit.html"
success_url = reverse_lazy("announcement_admin")


class DeleteAnnouncementView(PermissionRequiredMixin, DeleteView):
permission_required = ("announcements.delete_announcement",)
model = Announcement
permission_required = (
"announcements.delete_announcement",
)
success_url = reverse_lazy("announcement_admin")
14 changes: 5 additions & 9 deletions card/forms.py → card/formfields.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
import re

from django import forms
from django.core.exceptions import ValidationError
from django.core.validators import RegexValidator
from django.forms import CharField
from django.utils.translation import gettext_lazy as _

from card.widgets import CardNumberInput
from .validators import card_number_validator
from .widgets import CardNumberInput

card_number_validators = (
RegexValidator(r"^\d{10}$", _("Card number must be ten digits long.")),
)


class CardNumberField(CharField):
class CardNumberField(forms.CharField):
"""
Custom form field for card numbers
"""
widget = CardNumberInput
default_validators = card_number_validators
default_validators = [card_number_validator]

def __init__(self, **kwargs):
super().__init__(**{
Expand Down
11 changes: 7 additions & 4 deletions card/models.py → card/modelfields.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
from django.db import models
from django.utils.translation import gettext_lazy as _

import card.forms
from .validators import card_number_validator


class CardNumberField(models.CharField):
"""
Custom field for card numbers, doing some extra validation
"""
default_validators = [card_number_validator]

def __init__(self, **kwargs):
kwargs = {
"verbose_name": _("Card number"),
**kwargs,
"validators": card.forms.card_number_validators,
"validators": self.default_validators,
"max_length": 10,
"error_messages": {
"unique": _("Card number already in use"),
},
**kwargs,
}
super().__init__(**kwargs) # No card numbers are more than ten digits long

def formfield(self, **kwargs):
from . import formfields # avoids circular imports

if "form_class" not in kwargs:
kwargs["form_class"] = card.forms.CardNumberField
kwargs["form_class"] = formfields.CardNumberField
return super().formfield(**kwargs)

def get_prep_value(self, value):
Expand Down
1 change: 1 addition & 0 deletions card/templates/card/widgets/card_number_input.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% load i18n %}


<div class="ui right labeled input">
<div class="ui label">EM</div>
{% include "django/forms/widgets/text.html" %}
Expand Down
2 changes: 1 addition & 1 deletion card/tests.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.test import TestCase

from card.models import CardNumberField, CardNumber
from card.modelfields import CardNumberField, CardNumber


class CardNumberModelFieldTest(TestCase):
Expand Down
Loading