Skip to content
Closed
Show file tree
Hide file tree
Changes from 11 commits
Commits
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
2 changes: 1 addition & 1 deletion LICENSE.md
Comment thread
janno42 marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The software is licensed under the MIT license. The source code includes other
components in whole or in part, used under these licenses:
* [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0): Bootstrap Datetimepicker, Tom Select
* [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0): Tom Select
* [CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/legalcode): Font Awesome Icons
* [OFL-1.1](https://scripts.sil.org/OFL): Font Awesome Fonts
* [MIT](https://opensource.org/licenses/MIT): Bootstrap, Font Awesome Code, jQuery, Moment, Sisyphus, Sortable
Expand Down
5 changes: 5 additions & 0 deletions evap/contributor/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ class Meta:
"participants": UserModelMultipleChoiceField,
}

widgets = {
"vote_start_datetime": forms.DateTimeInput(),
"vote_end_date": forms.DateInput(attrs={"type": "date", "class": "form-control"}),
}

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

Expand Down
6 changes: 5 additions & 1 deletion evap/evaluation/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@
<title>{% block title %}EvaP{% endblock %}</title>

<link rel="stylesheet" href="{% static 'css/tom-select.bootstrap5.min.css' %}" />
<link rel="stylesheet" href="{% static 'css/bootstrap-datetimepicker.min.css' %}" />
<link rel="stylesheet" href="{% static 'css/evap.css' %}" />
<link rel="stylesheet" href="{% static 'tempus-dominus/tempus-dominus.min.css' %}" />
<script src="{%static 'js/popper.min.js' %}"></script>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should already be available via bootstrap, please check

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you mean exactly?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw it seems popper js script is needed, when i remove it, the datetimepicker breaks...

<script src="{% static 'tempus-dominus/tempus-dominus.min.js' %}"></script>
<script src="{% static 'tempus-dominus/tempus-dominus-date-init.js' %}"></script>
<script src="{% static 'tempus-dominus/tempus-dominus-datetime-init.js' %}"></script>
{% if debug %}
<link rel="icon" type="image/png" sizes="64x64" href="{% static 'images/favicon_gray.png' %}" />
{% else %}
Expand Down
32 changes: 0 additions & 32 deletions evap/evaluation/templates/bootstrap_datetimepicker.html

This file was deleted.

26 changes: 26 additions & 0 deletions evap/evaluation/templates/django/forms/widgets/date.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<head>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need a head/body here? shouldn't all scripts and css be loaded by base.html?

{% load static %}
<link rel="stylesheet" href="{% static 'tempus-dominus/tempus-dominus.min.css' %}" />
<!-- <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.6/dist/umd/popper.min.js"></script> -->
<script src="{%static 'js/popper.min.js' %}"></script>
<script src="{% static 'tempus-dominus/tempus-dominus.min.js' %}"></script>
<!-- <script src="https://cdn.jsdelivr.net/npm/@eonasdan/tempus-dominus@6.9.4/dist/js/tempus-dominus.min.js" /> -->
<script src="{% static 'tempus-dominus/tempus-dominus-date-init.js' %}"></script>
</head>

<body>
<div class="input-group" id="datepicker1" data-td-target-input="nearest" data-td-target-toggle="nearest">

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need the number in the id?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is included in the official documentation, but actually we don't need it, so i removed it.

<input id="datetimepicker1Input"
type="text"
class="form-control"
data-td-target="#datetimepicker1"
name="{{ widget.name }}"
{% if widget.value and widget.value != 'None' %}
value="{{ widget.value }}"{% endif %}
{% include 'django/forms/widgets/attrs.html' %}
/>
<span class="input-group-text" data-td-target="#datetimepicker1" data-td-toggle="datetimepicker">
<i class="fas fa-calendar"></i>
</span>
</div>
</body>
26 changes: 26 additions & 0 deletions evap/evaluation/templates/django/forms/widgets/datetime.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<head>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here (head, ids)

{% load static %}
<link rel="stylesheet" href="{% static 'tempus-dominus/tempus-dominus.min.css' %}" />
<!-- <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.6/dist/umd/popper.min.js"></script> -->
<script src="{%static 'js/popper.min.js' %}"></script>
<script src="{% static 'tempus-dominus/tempus-dominus.min.js' %}"></script>
<!-- <script src="https://cdn.jsdelivr.net/npm/@eonasdan/tempus-dominus@6.9.4/dist/js/tempus-dominus.min.js" /> -->
<script src="{% static 'tempus-dominus/tempus-dominus-datetime-init.js' %}"></script>
</head>

<body>
<div class="input-group" id="datetimepicker1" data-td-target-input="nearest" data-td-target-toggle="nearest">
<input id="datetimepicker1Input"
type="text"
class="form-control"
data-td-target="#datetimepicker1"
name="{{ widget.name }}"
{% if widget.value and widget.value != 'None' %}
value="{{ widget.value }}"{% endif %}
{% include 'django/forms/widgets/attrs.html' %}
/>
<span class="input-group-text" data-td-target="#datetimepicker1" data-td-toggle="datetimepicker">
<i class="fas fa-calendar"></i>
</span>
</div>
</body>
4 changes: 0 additions & 4 deletions evap/evaluation/templates/evap_evaluation_edit_js.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,3 @@
}
}
</script>

{% block additional_javascript %}
{% include 'bootstrap_datetimepicker.html' %}
{% endblock %}
4 changes: 4 additions & 0 deletions evap/rewards/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ class RewardPointRedemptionEventForm(forms.ModelForm):
class Meta:
model = RewardPointRedemptionEvent
fields = ("name_en", "name_de", "date", "redeem_end_date", "step")
widgets = {
"date": forms.DateInput(attrs={"type": "date", "class": "form-control"}),
"redeem_end_date": forms.DateInput(attrs={"type": "date", "class": "form-control"}),
}

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,3 @@
</div>
</form>
{% endblock %}

{% block additional_javascript %}
{% include 'bootstrap_datetimepicker.html' %}
{% endblock %}
33 changes: 29 additions & 4 deletions evap/staff/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,19 @@ def clean(self):
class ImportForm(forms.Form):
use_required_attribute = False

vote_start_datetime = forms.DateTimeField(label=_("Start of evaluation"), localize=True, required=False)
vote_end_date = forms.DateField(label=_("End of evaluation"), localize=True, required=False)
vote_start_datetime = forms.DateTimeField(
label=_("Start of evaluation"),
widget=forms.DateTimeInput(),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary? I would have expected tht forms.DateTimeInput is the default widget for a forms.DateTimeField.

localize=True,
required=False,
)

vote_end_date = forms.DateField(
label=_("End of evaluation"),
widget=forms.DateInput(attrs={"type": "date", "class": "form-control"}),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do we need "type": "date" for here? Should it just be part of the default for the widget? (And I guess the same for "class": "form-control")

localize=True,
required=False,
)

excel_file = forms.FileField(
label=_("Excel file"),
Expand Down Expand Up @@ -283,8 +294,18 @@ def __init__(self, *args, **kwargs):

class CourseCopyForm(CourseFormMixin, forms.ModelForm): # type: ignore[misc]
semester = forms.ModelChoiceField(Semester.objects.all())
vote_start_datetime = forms.DateTimeField(label=_("Start of evaluations"), localize=True)
vote_end_date = forms.DateField(label=_("Last day of evaluations"), localize=True)

vote_start_datetime = forms.DateTimeField(
label=_("Start of evaluations"),
localize=True,
widget=forms.DateTimeInput(),
)

vote_end_date = forms.DateField(
label=_("Last day of evaluations"),
localize=True,
widget=forms.DateInput(attrs={"type": "date", "class": "form-control"}),
)

field_order = ["semester"]

Expand Down Expand Up @@ -401,6 +422,10 @@ class Meta:
field_classes = {
"participants": UserModelMultipleChoiceField,
}
widgets = {
"vote_start_datetime": forms.DateTimeInput(),
"vote_end_date": forms.DateInput(attrs={"type": "date", "class": "form-control"}),
}

def __init__(self, *args, requires_decided_main_language=False, **kwargs):
semester = kwargs.pop("semester", None)
Expand Down
4 changes: 0 additions & 4 deletions evap/staff/templates/staff_course_copyform.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,3 @@ <h5 class="card-title">{% translate 'Evaluations that will be copied' %}</h5>
</div>
</form>
{% endblock %}

{% block additional_javascript %}
{% include 'bootstrap_datetimepicker.html' %}
{% endblock %}
1 change: 0 additions & 1 deletion evap/staff/templates/staff_semester_import.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ <h3>{% translate 'Import semester data' %}</h3>
{% endblock %}
Comment thread
HannesClausnitzer marked this conversation as resolved.

{% block additional_javascript %}
{% include 'bootstrap_datetimepicker.html' %}
<script type="module">
import { copyHeaders } from "{% static 'js/copy-to-clipboard.js' %}";

Expand Down
5 changes: 0 additions & 5 deletions evap/static/css/bootstrap-datetimepicker.min.css

This file was deleted.

2 changes: 0 additions & 2 deletions evap/static/js/bootstrap-datetimepicker.min.js

This file was deleted.

7 changes: 7 additions & 0 deletions evap/static/js/popper.min.js

Large diffs are not rendered by default.

14 changes: 0 additions & 14 deletions evap/static/scss/_adjustments.scss
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,6 @@ $alert-colors: (
padding-top: 0.25rem;
}

// datetimepicker adjustments
.bootstrap-datetimepicker-widget.dropdown-menu.timepicker-sbs {
width: 33em;

.datepicker {
flex: 0 0 60%;
max-width: 60%;
}

.timepicker {
flex: 0 0 40%;
}
}

// tomselect adjustments
.ts-wrapper.multi .ts-control > div.active {
background-color: $component-active-bg;
Expand Down
1 change: 1 addition & 0 deletions evap/static/scss/_components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@
@import "components/staff-index";
@import "components/notebook";
@import "components/range-slider";
@import "components/datetime-picker";
6 changes: 6 additions & 0 deletions evap/static/scss/components/_datetime-picker.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// fix datetimepicker time selector width
.time-container-clock,
.time-container-hour,
.time-container-minute {
width: 100%;
}
29 changes: 29 additions & 0 deletions evap/static/tempus-dominus/tempus-dominus-date-init.js

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are the two tempus-dominus js files from us? then we should use typescript.

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
document.addEventListener('DOMContentLoaded', function() {
const picker = new tempusDominus.TempusDominus(document.getElementById('datepicker1'), {
display: {
theme: 'light',
icons: {
time: 'fa fa-clock',
date: 'fa fa-calendar',
up: 'fa fa-arrow-up',
down: 'fa fa-arrow-down',
previous: 'fa fa-chevron-left',
next: 'fa fa-chevron-right',
today: 'fa fa-calendar-check',
clear: 'fa fa-trash',
close: 'fa fa-times'
},
components: {
clock: false, // Hides the clock toggle button
hours: false, // Hides the hour picker
minutes: false, // Hides the minute picker
seconds: false // (Already false by default, but good to ensure)
},
},
localization: {
format: 'yyyy-MM-dd',
startOfTheWeek: 1,
hourCycle: 'h23'
}
});
});
Loading
Loading