Skip to content

Commit

Permalink
Merge pull request #62 from Elthan/feature-21-consent-dialog
Browse files Browse the repository at this point in the history
Feature #21 - Consent form and DateTimeField to HowSolved
  • Loading branch information
torgeirl committed Aug 13, 2018
2 parents 227b4a7 + 7c7d2d9 commit 904251f
Show file tree
Hide file tree
Showing 28 changed files with 401 additions and 74 deletions.
29 changes: 29 additions & 0 deletions docs/sysadmin/deploy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,35 @@ Create a ``trix_uio_ldap_auth.py`` as follows (but adjust the email suffix)::
def django_to_ldap_username(self, username):
return username.split('@')[0]


****************
Consent template
****************
Customising the consent template is highly recommended and can be done by following these steps:

1. Create a directory for custom templates with a subfolder named ``trix_student``
2. Create a django html file called ``consent_form.django.html`` and make it look like this::

{% extends "trix_student/consent_form_base.django.html" %}

{% block consent_title %}<h1>Consent title here</h1>{% endblock %}

{% block consent_text %}Lorem Ipsum{% endblock %}

{# If you want to override the buttons you can add this #}
{# {% block consent_buttons %}BUTTONS{% endblock %} #}


3. In ``trix_settings.py`` do::

from trix.utils.template import add_custom_template

add_custom_template('custom_template_directory/goes/here')

If you which to disable the consent dialog completely for some reason, add ``DISABLE_CONSENT = True``
to your ``trix_settings.py`` file.


******************
Make sure it works
******************
Expand Down
1 change: 1 addition & 0 deletions trix/project/default/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'trix.trix_student.middleware.consent.ConsentMiddleware',
]


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
{% block styles %}
{{ block.super }}
<link href='{% static "trix_student/dist/css/styles.css" %}' rel="stylesheet">
{% endblock styles %}
{% endblock %}
Binary file modified trix/trix_core/locale/nb/LC_MESSAGES/django.mo
Binary file not shown.
60 changes: 32 additions & 28 deletions trix/trix_core/locale/nb/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: trix_core\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-08-06 13:12+0200\n"
"POT-Creation-Date: 2018-08-10 15:50+0200\n"
"PO-Revision-Date: 2014-12-21 22:43+0100\n"
"Last-Translator: Tor Ivar Johansen <tor@appresso.no>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand All @@ -30,11 +30,11 @@ msgstr "Fjern administratortilgang til valgte brukere"
msgid "tag is in use"
msgstr "tag er i bruk"

#: trix/trix_core/admin.py:77 trix/trix_core/models.py:270
#: trix/trix_core/admin.py:77 trix/trix_core/models.py:279
msgid "Yes"
msgstr "Ja"

#: trix/trix_core/admin.py:78 trix/trix_core/models.py:270
#: trix/trix_core/admin.py:78 trix/trix_core/models.py:279
msgid "No"
msgstr "Nei"

Expand Down Expand Up @@ -66,101 +66,105 @@ msgstr ""
"Er brukeren administrator? Administratorer har full tilgang til "
"admingrensesnittet"

#: trix/trix_core/models.py:62
#: trix/trix_core/models.py:67
msgid "User"
msgstr "Bruker"

#: trix/trix_core/models.py:63
#: trix/trix_core/models.py:68
msgid "Users"
msgstr "Brukere"

#: trix/trix_core/models.py:148
#: trix/trix_core/models.py:157
msgid "No category"
msgstr "Ingen kategori"

#: trix/trix_core/models.py:149 trix/trix_core/models.py:217
#: trix/trix_core/models.py:330
#: trix/trix_core/models.py:158 trix/trix_core/models.py:226
#: trix/trix_core/models.py:343
msgid "Course"
msgstr "Kurs"

#: trix/trix_core/models.py:150
#: trix/trix_core/models.py:159
msgid "Period"
msgstr "Semester"

#: trix/trix_core/models.py:155
#: trix/trix_core/models.py:164
msgid "Tag"
msgstr "Tag"

#: trix/trix_core/models.py:156 trix/trix_core/models.py:255
#: trix/trix_core/models.py:334
#: trix/trix_core/models.py:165 trix/trix_core/models.py:264
#: trix/trix_core/models.py:347
msgid "Tags"
msgstr "Tags"

#: trix/trix_core/models.py:193 trix/trix_core/models.py:342
#: trix/trix_core/models.py:202 trix/trix_core/models.py:355
msgid "Description"
msgstr "Beskrivelse"

#: trix/trix_core/models.py:218
#: trix/trix_core/models.py:227
msgid "Courses"
msgstr "Kurs"

#: trix/trix_core/models.py:252 trix/trix_core/models.py:336
#: trix/trix_core/models.py:261 trix/trix_core/models.py:349
msgid "Title"
msgstr "Tittel"

#: trix/trix_core/models.py:257
#: trix/trix_core/models.py:266
msgid "Assignment text"
msgstr "Oppgavetekst"

#: trix/trix_core/models.py:258
#: trix/trix_core/models.py:267
msgid "Write the assignment here."
msgstr "Skriv oppgaven her."

#: trix/trix_core/models.py:261
#: trix/trix_core/models.py:270
msgid "Solution"
msgstr "Løsning"

#: trix/trix_core/models.py:262
#: trix/trix_core/models.py:271
msgid ""
"If you want your students to be able to view a suggested solution, write the "
"solution here."
msgstr ""
"Hvis du vil at studentene skal kunne se et løsningsforslag, skriv løsningen "
"her."

#: trix/trix_core/models.py:265
#: trix/trix_core/models.py:274
msgid "Created"
msgstr "Opprettet"

#: trix/trix_core/models.py:268
#: trix/trix_core/models.py:277
msgid "Last changed"
msgstr "Sist modifisert"

#: trix/trix_core/models.py:274
#: trix/trix_core/models.py:283
msgid "Hide assignment from students"
msgstr "Skjul oppgaven for studenter"

#: trix/trix_core/models.py:279
#: trix/trix_core/models.py:288
msgid "Assignment"
msgstr "Oppgave"

#: trix/trix_core/models.py:280
#: trix/trix_core/models.py:289
msgid "Assignments"
msgstr "Oppgaver"

#: trix/trix_core/models.py:315
#: trix/trix_core/models.py:324
msgid "Solved by myself"
msgstr "Løste på egen hånd"

#: trix/trix_core/models.py:316
#: trix/trix_core/models.py:325
msgid "Solved with help"
msgstr "Løste med hjelp"

#: trix/trix_core/models.py:348
#: trix/trix_core/models.py:332
msgid "Solved"
msgstr "Løst"

#: trix/trix_core/models.py:361
msgid "Permalink"
msgstr "Permalink"

#: trix/trix_core/models.py:349
#: trix/trix_core/models.py:362
msgid "Permalinks"
msgstr "Permalinker"

Expand Down
25 changes: 25 additions & 0 deletions trix/trix_core/migrations/0003_auto_20180809_1220.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.14 on 2018-08-09 10:20
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('trix_core', '0002_assignment_hidden'),
]

operations = [
migrations.AddField(
model_name='howsolved',
name='solved_datetime',
field=models.DateTimeField(auto_now=True, verbose_name='Solved'),
),
migrations.AddField(
model_name='user',
name='consent_datetime',
field=models.DateTimeField(blank=True, null=True),
),
]
13 changes: 13 additions & 0 deletions trix/trix_core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ class User(AbstractBaseUser):
unique=True
)

consent_datetime = models.DateTimeField(
blank=True,
null=True
)

USERNAME_FIELD = 'email'
REQUIRED_FIELDS = []

Expand Down Expand Up @@ -115,6 +120,10 @@ def is_superuser(self):
"""
return self.is_admin

@property
def has_consented(self):
return self.consent_datetime is not None


class TagQuerySet(models.query.QuerySet):
def to_unicode(self):
Expand Down Expand Up @@ -319,6 +328,10 @@ class HowSolved(models.Model):

assignment = models.ForeignKey(Assignment, on_delete=models.CASCADE)
user = models.ForeignKey(User, on_delete=models.CASCADE)
solved_datetime = models.DateTimeField(
verbose_name=_('Solved'),
auto_now=True
)

def __unicode__(self):
return self.howsolved
Expand Down
Binary file modified trix/trix_student/locale/nb/LC_MESSAGES/django.mo
Binary file not shown.

0 comments on commit 904251f

Please sign in to comment.