Skip to content

Commit

Permalink
Trix v4.1 (#153)
Browse files Browse the repository at this point in the history
* Improved contrast course admin assignment and editor

* Fixed missing labels and iframe title

* wrapped in fieldset

* Fixed Empty header

* Empty table header fix, and added missing label to search field

* Fixed language not being set

* Added link icon to link

* Removed redundant login button

* Removed django.middleware.clickjacking.XFrameOptionsMiddleware

* Added the ability to hide courses from students

* Hopefully fixed 145

* Statics view optimization

* redirect url cleanup

* (re-)moved some inline styling (#146)

* added and improved translation for add admin (#148)

* moved more inline styling (#146)

* Move inline javascript to own file

* removed «Print this page» (#146)

* Moved out inline styles

* Replace inline style with correct css classes

* Fixed #149

* added `TRIX_VERSION` template variable

* releasing Trix 4.1.0

---------

Co-authored-by: Levijatan <[email protected]>
  • Loading branch information
torgeirl and Levijatan authored Jan 25, 2024
1 parent dfa3e8f commit 6f98d36
Show file tree
Hide file tree
Showing 46 changed files with 1,002 additions and 147 deletions.
3 changes: 3 additions & 0 deletions docs/sysadmin/deploy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ Customize the footer template to contain your own information

<span class="fa fa-info"></span>
<a href="link2">{% trans "Privacy" %}</a>

<span class="fa fa-info"></span>
<a href="version url">Trix v{{ TRIX_VERSION }}<a>
{% endblock %}


Expand Down
21 changes: 10 additions & 11 deletions trix/project/default/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,8 @@
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'allauth.account.middleware.AccountMiddleware',
'trix.trix_student.middleware.consent.ConsentMiddleware',
]
Expand Down Expand Up @@ -125,15 +123,16 @@
'OPTIONS': {
'debug': DEBUG,
'context_processors': [
"django.contrib.auth.context_processors.auth",
"django.template.context_processors.debug",
"django.template.context_processors.i18n",
"django.template.context_processors.media",
"django.template.context_processors.static",
"django.template.context_processors.tz",
"django.contrib.messages.context_processors.messages",
"cradmin_legacy.context_processors.cradmin",
"django.template.context_processors.request",
'django.contrib.auth.context_processors.auth',
'django.template.context_processors.debug',
'django.template.context_processors.i18n',
'django.template.context_processors.media',
'django.template.context_processors.static',
'django.template.context_processors.tz',
'django.contrib.messages.context_processors.messages',
'cradmin_legacy.context_processors.cradmin',
'django.template.context_processors.request',
'trix.project.default.templatecontext.template_variables',
],
},
}
Expand Down
8 changes: 8 additions & 0 deletions trix/project/default/templatecontext.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import trix


def template_variables(request):
template_variables_dict = {
'TRIX_VERSION': trix.__version__
}
return template_variables_dict
Empty file.
Empty file.
84 changes: 84 additions & 0 deletions trix/trix_admin/management/commands/generatetestdata.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import os
from django.core.management.base import BaseCommand, CommandParser
from itertools import cycle
from trix.trix_core import models as trix_models


DJANGOENV = os.environ.get('DJANGOENV', 'develop')

if DJANGOENV == 'develop': # Used for local development
from model_bakery import baker
from model_bakery.recipe import Recipe, seq
GENERATED_USER_EMAIL = 'generated_user_email'
TEST_TAG_NAME = 'generate_course'

UserRecipe = Recipe(trix_models.User, email=seq(GENERATED_USER_EMAIL, suffix='@example.com'))

class Command(BaseCommand):
help = "Generate a new course with n number of assignments"

def add_arguments(self, parser: CommandParser) -> None:
parser.add_argument(
'-n',
type=int,
help='Number of assignments to generate, defaults to 5',
default=5
)
parser.add_argument(
'--clean',
action='store_true',
help='Clean the database of courses generated by this command'
)
parser.add_argument(
'-b',
type=int,
help='Number of "bymyself" Howsolved objects and the corresponding users to generate, defaults to 5',
default=5
)
parser.add_argument(
'-w',
type=int,
help='Number of "withhelp" Howsolved objects and the corresponding users to generate, defaults to 5',
default=5
)
parser.add_argument(
'-s',
type=int,
help='Number of users who has not solved to generate, defaults to 5',
default=5
)

def _generate_howsolved_objects(self, howsolved, users, assignments, n):
for a in assignments:
baker.make(
trix_models.HowSolved,
howsolved=howsolved,
user=cycle(users),
assignment=a,
_quantity=n
)

def handle(self, *args, **options) -> None:
if options['clean']:
queryset = trix_models.Course.objects.filter(active_period__tag=TEST_TAG_NAME)
course_tags = queryset.values_list('course_tag__id', flat=True)
trix_models.Tag.objects.filter(id__in=course_tags).delete()
queryset.delete()
trix_models.Assignment.objects.filter(tags__tag=TEST_TAG_NAME).delete()
trix_models.Tag.objects.filter(tag=TEST_TAG_NAME).delete()
trix_models.User.objects.filter(email__startswith=GENERATED_USER_EMAIL).delete()
else:
tag, _ = trix_models.Tag.objects.get_or_create(
tag=TEST_TAG_NAME, defaults={'category': 'p'}
)
course = baker.make(trix_models.Course, active_period=tag)

assignments = baker.make(trix_models.Assignment, tags=[tag, course.course_tag], _quantity=options['n'])

bymyself_users = UserRecipe.make(_quantity=options['b'])
withhelp_users = UserRecipe.make(_quantity=options['w'])
notsolved_users = UserRecipe.make(_quantity=options['s'])

self._generate_howsolved_objects('bymyself', bymyself_users, assignments, options['b'])
self._generate_howsolved_objects('withhelp', withhelp_users, assignments, options['w'])
self._generate_howsolved_objects('notsolved', notsolved_users, assignments, options['s'])
15 changes: 15 additions & 0 deletions trix/trix_admin/static/trix_admin/plain_es6/datepicker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
$(function () {
$('#datetimepicker').datetimepicker({
format: 'YYYY-MM-DD'
});
$('#datetimepicker2').datetimepicker({
format: 'YYYY-MM-DD',
useCurrent: false //Important! See issue #1075
});
$("#datetimepicker").on("dp.change", function (e) {
$('#datetimepicker2').data("DateTimePicker").minDate(e.date);
});
$("#datetimepicker2").on("dp.change", function (e) {
$('#datetimepicker').data("DateTimePicker").maxDate(e.date);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{% load i18n %}
{% load cradmin_legacy_icon_tags %}
{% comment %}
Include template used to show an embedded iframe floating above
the page with a close button. This renders the
``cradmin-legacy-floating-fullsize-iframe-wrapper`` AngularJS directive
components with some extra components to make it stylable and accessible.

Example::

<div cradmin-legacy-page-preview-wrapper>
{% include "cradmin_legacy/pagepreview/includes/pagepreview.django.html" %}
<div cradmin-legacy-page-preview-open-on-page-load="'{{ preview_url }}'"></div>
</div>

{% endcomment %}

<div class="cradmin-legacy-floating-fullsize-iframe-wrapper"
cradmin-legacy-page-preview-iframe-wrapper>
<a href="#" class="cradmin-legacy-floating-fullsize-iframe-closebutton"
cradmin-legacy-page-preview-iframe-closebutton>
<span aria-hidden="true"
class="{% cradmin_icon 'close-overlay-right-to-left' %}
cradmin-legacy-floating-fullsize-iframe-closebutton-icon"></span>
<span class="sr-only">{% trans "Close preview" %}</span>
</a>
<div class="cradmin-legacy-floating-fullsize-content">
<div class="ng-hide cradmin-legacy-floating-fullsize-loadspinner"
cradmin-legacy-page-preview-load-spinner>
<span class="{% cradmin_icon 'loadspinner' %}"></span>
</div>
<nav class="cradmin-legacy-floating-fullsize-iframe-navbar"
cradmin-legacy-page-preview-navbar
cradmin-legacy-page-preview-navbar-mobile-menu-header="{% trans 'Preview options' %}">
</nav>
<div class="cradmin-legacy-floating-fullsize-iframe-inner"
cradmin-legacy-page-preview-iframe-wrapper-inner>
<iframe cradmin-legacy-page-preview-iframe title="preview"></iframe>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{% extends "cradmin_legacy/standalone-base-internal.django.html" %}
{% load i18n %}
{% load static %}
{% get_current_language as LANGUAGE_CODE %}
{% block html-element-lang %}{{ LANGUAGE_CODE }}{% endblock %}

{% block title-pre %}{% trans "Trix" %} - {% endblock title-pre %}
{% block jsimports %}
Expand Down
Loading

0 comments on commit 6f98d36

Please sign in to comment.