Skip to content

Commit

Permalink
Far better roleselect view.
Browse files Browse the repository at this point in the history
  • Loading branch information
espenak committed Jan 8, 2015
1 parent 5d0948f commit 494f981
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 24 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var/
*.egg-info/
.installed.cfg
*.egg
.DS_Store

# Installer logs
pip-log.txt
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
'django-extensions',
'South>=0.8.4',
'dj-database-url>=0.3.0',
'django_cradmin==1.0.0-beta.004',
'django_cradmin==1.0.0-beta.005',
'gunicorn',
],
classifiers=[
Expand Down
3 changes: 3 additions & 0 deletions trix/project/default/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,6 @@

# TRIX_LOGIN_MESSAGE = 'Logg inn med ditt UiO brukernavn og passord'
# TRIX_LOGIN_IS_USERNAME = True

TRIX_ADMIN_DOCUMENTATION_URL = 'http://trix2.readthedocs.org/'
TRIX_ADMIN_DOCUMENTATION_LABEL = 'trix2.readthedocs.org'
20 changes: 10 additions & 10 deletions trix/trix_admin/cradmin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from django.contrib.auth.decorators import login_required
from django.utils.translation import ugettext_lazy as _
from django_cradmin import crinstance, crmenu
from django.core.urlresolvers import reverse
from trix.trix_admin.views import roleselect

from trix.trix_core.models import Course
# from .views import dashboard
Expand All @@ -13,6 +15,10 @@ class Menu(crmenu.Menu):
def build_menu(self):
# self.add(label=_('Dashboard'), url=self.appindex_url('dashboard'),
# icon="home")
self.add(
label=_('Course overview'),
url=self.cradmin_instance.roleselectview_url(),
icon='arrow-up')
self.add(
label=_('Assignments'),
url=self.appindex_url('assignments'),
Expand All @@ -25,16 +31,6 @@ def build_menu(self):
label=_('Statistics'),
url=self.appindex_url('statistics'),
icon='bar-chart-o')
if self.request.user.is_admin:
self.add(
label=_('Courses, users, ...'),
url=reverse('admin:index'),
icon='cog')
self.add(
label=_('Back to website'),
url=reverse('trix_student_dashboard'),
icon='arrow-left')



class CrAdminInstance(crinstance.BaseCrAdminInstance):
Expand Down Expand Up @@ -63,3 +59,7 @@ def get_titletext_for_role(self, role):
Remember that the role is a Course.
"""
return role.course_tag.tag

@classmethod
def get_roleselect_view(cls):
return login_required(roleselect.TrixRoleSelectView.as_view())
Binary file modified trix/trix_admin/locale/nb/LC_MESSAGES/django.mo
Binary file not shown.
52 changes: 39 additions & 13 deletions trix/trix_admin/locale/nb/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: trix_admin\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-01-04 15:21+0000\n"
"PO-Revision-Date: 2015-01-04 16:22+0100\n"
"POT-Creation-Date: 2015-01-08 11:35+0000\n"
"PO-Revision-Date: 2015-01-08 12:35+0100\n"
"Last-Translator: Espen Angell Kristiansen <post@espenak.net>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: nb\n"
Expand All @@ -18,31 +18,53 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 1.6.5\n"

#: cradmin.py:17
#: cradmin.py:19
msgid "Course overview"
msgstr "Kursoversikt"

#: cradmin.py:23
msgid "Assignments"
msgstr "Oppgaver"

#: cradmin.py:21
#: cradmin.py:27
msgid "Permalinks"
msgstr "Permalinker"

#: cradmin.py:25 templates/trix_admin/statistics.django.html:11
#: cradmin.py:31 templates/trix_admin/statistics.django.html:11
msgid "Statistics"
msgstr "Statistikk"

#: cradmin.py:30
msgid "Courses, users, ..."
msgstr ""

#: cradmin.py:34
msgid "Back to website"
msgstr "Tilbake til websiden"

#: templates/trix_admin/frontpage.django.html:9
#: templates/trix_admin/statistics.django.html:10
msgid "Trix"
msgstr "Trix"

#: templates/trix_admin/roleselect.django.html:14
msgid "Back to the website"
msgstr "Tilbake til websiden"

#: templates/trix_admin/roleselect.django.html:21
msgid "Documentation"
msgstr "Dokumentasjon"

#: templates/trix_admin/roleselect.django.html:24
msgid "Edit courses and users?"
msgstr "Rediger kurs og brukere?"

#: templates/trix_admin/roleselect.django.html:25
msgid "Need to create/edit courses, change active semester or edit users?"
msgstr ""
"Trenger du å lage/redigere kurs, endre aktivt semester eller redigere "
"brukere?"

#: templates/trix_admin/roleselect.django.html:27
msgid "Go to the superuser panel"
msgstr "Gå til superbruker panelet"

#: templates/trix_admin/roleselect.django.html:29
msgid "You need to ask a superuser to grant you superuser access."
msgstr "Du må be en superbruker om å gjøre deg til superbruker."

#: templates/trix_admin/statistics.django.html:18
msgid "Aggregated statistics on how the assignments where solved"
msgstr "Aggregert statistikk over hvordan oppgavene ble løst"
Expand Down Expand Up @@ -164,6 +186,10 @@ msgstr "Slett tag"
msgid "Type in the tag you want to remove from the selected assignments"
msgstr "Skriv inn taggen du vil fjerne fra valgte oppgaver"

#: views/roleselect.py:6
msgid "Select a course to edit create/edit assignments"
msgstr "Velg et kurs for å lage og redigere oppgaver"

#: views/statistics.py:128
msgid ""
"Simple statitics showing percentage share of how the assignments where solved"
Expand Down
27 changes: 27 additions & 0 deletions trix/trix_admin/templates/trix_admin/roleselect.django.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{% extends "django_cradmin/roleselect.django.html" %}
{% load i18n %}

{% block body %}
<div class="container" style="margin-top: 20px;">
<a href="{% url 'trix_student_dashboard' %}">
<span class="fa fa-arrow-left"></span>
{% trans "Back to the website" %}
</a>
</div>

{{ block.super }}

<div class="container" style="margin-top: 40px;">
<h2>{% trans "Documentation" %}</h2>
<a href="{{ TRIX_ADMIN_DOCUMENTATION_URL }}">{{ TRIX_ADMIN_DOCUMENTATION_LABEL }}</a>

<h2>{% trans "Edit courses and users?" %}</h2>
<p>{% trans "Need to create/edit courses, change active semester or edit users?" %}
{% if user.is_admin %}
<a href="{% url 'admin:index' %}">{% trans "Go to the superuser panel" %}</a>.
{% else %}
{% trans "You need to ask a superuser to grant you superuser access." %}
{% endif %}
</p>
</div>
{% endblock body %}
15 changes: 15 additions & 0 deletions trix/trix_admin/views/roleselect.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from django_cradmin.views import roleselect


class TrixRoleSelectView(roleselect.RoleSelectView):
pagetitle=_('Select a course to edit create/edit assignments')
template_name = 'trix_admin/roleselect.django.html'
autoredirect_if_single_role = False

def get_context_data(self, **kwargs):
context = super(TrixRoleSelectView, self).get_context_data(**kwargs)
context['TRIX_ADMIN_DOCUMENTATION_URL'] = settings.TRIX_ADMIN_DOCUMENTATION_URL
context['TRIX_ADMIN_DOCUMENTATION_LABEL'] = settings.TRIX_ADMIN_DOCUMENTATION_LABEL
return context

0 comments on commit 494f981

Please sign in to comment.