Skip to content

Commit

Permalink
Merge pull request #60 from Elthan/feature-20-user-data-deletion
Browse files Browse the repository at this point in the history
Feature #20 (user data deletion)
  • Loading branch information
torgeirl committed Aug 6, 2018
2 parents 4ea0e33 + 05bed1c commit 227b4a7
Show file tree
Hide file tree
Showing 16 changed files with 163 additions and 27 deletions.
Binary file modified trix/trix_admin/locale/nb/LC_MESSAGES/django.mo
Binary file not shown.
8 changes: 4 additions & 4 deletions trix/trix_admin/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_admin\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-08-03 19:26+0200\n"
"POT-Creation-Date: 2018-08-06 13:12+0200\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"
Expand All @@ -20,7 +20,7 @@ msgstr ""

#: trix/trix_admin/cradmin.py:37
msgid "Frontpage"
msgstr ""
msgstr "Forside"

#: trix/trix_admin/cradmin.py:42
msgid "Course overview"
Expand Down Expand Up @@ -104,7 +104,7 @@ msgid ""
" "
msgstr ""
"\n"
"Statistikken nedenfor hvis hvor mange prosent av det totale antall brukere "
"Statistikken nedenfor viser hvor mange prosent av det totale antall brukere "
"som har løst oppgaven på egenhånd, med hjelp, eller ikke løst den.\n"
" "

Expand Down Expand Up @@ -136,7 +136,7 @@ msgid "Not completed"
msgstr "Ikke løst"

#: trix/trix_admin/templates/trix_admin/statistics.django.html:110
msgid "There was no assignments matching the choosen tag"
msgid "There was no assignments matching the chosen tag"
msgstr "Det fantes ingen oppgaver som er merket med valgte tag"

#: trix/trix_admin/views/assignments.py:30
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ <h2>{{ assignment }}</h2>
</div>
<hr style="border-bottom: dotted 1px #ccc;" />
{% empty %}
<h2 class="empty-assignment-list-info">{% trans "There was no assignments matching the choosen tag" %}</h2>
<h2 class="empty-assignment-list-info">{% trans "There was no assignments matching the chosen tag" %}</h2>
{% endfor %}
{% include "trix_student/include/pager.django.html" %}
</div>
Expand Down
Binary file modified trix/trix_core/locale/nb/LC_MESSAGES/django.mo
Binary file not shown.
2 changes: 1 addition & 1 deletion 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-03 19:26+0200\n"
"POT-Creation-Date: 2018-08-06 13:12+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 Down
Binary file modified trix/trix_student/locale/nb/LC_MESSAGES/django.mo
Binary file not shown.
51 changes: 42 additions & 9 deletions trix/trix_student/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_student\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-08-03 19:26+0200\n"
"POT-Creation-Date: 2018-08-06 13:12+0200\n"
"PO-Revision-Date: 2015-01-03 17:40+0100\n"
"Last-Translator: Espen Angell Kristiansen <post@espenak.net>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand Down Expand Up @@ -93,6 +93,7 @@ msgstr ""
#: trix/trix_student/templates/trix_student/include/header.django.html:58
msgid "Sign in"
msgstr "Logg inn"
#~ msgstr "Superbruker panel"

#: trix/trix_student/templates/trix_student/course.django.html:13
#: trix/trix_student/templates/trix_student/include/assignment.django.html:15
Expand Down Expand Up @@ -134,7 +135,7 @@ msgid ""
"day to day learning tool as well as a preparatory tool for focused learning."
msgstr ""
"Trix består av en enkel tagstruktur hvor hver oppgave er merket med "
"informative tags. Dette sammen med muligheter for å kunne filtrere på tager "
"informative tags. Dette sammen med muligheter for å kunne filtrere på tagger "
"sørger for et skreddersydd utplukk av oppgaver tilpasset ditt personlige "
"nivå. Trix er et verktøy du kan bruke underveis i en læringsprosess samt et "
"forberedende verktøy for fokusert læring."
Expand Down Expand Up @@ -180,7 +181,7 @@ msgid "Toggle navigation"
msgstr "Vis/skjul navigering"

#: trix/trix_student/templates/trix_student/include/header.django.html:28
#: trix/trix_student/views/users.py:24
#: trix/trix_student/views/users.py:26
msgid "Superuser"
msgstr "Superbruker"

Expand Down Expand Up @@ -242,27 +243,59 @@ msgstr "Liste over permalinker"
msgid "All the permalinks created are listed below"
msgstr "Under listes alle permalinker opp"

#: trix/trix_student/templates/trix_student/user_delete.django.html:8
msgid "Delete user"
msgstr "Slett bruker"

#: trix/trix_student/templates/trix_student/user_delete.django.html:10
#, python-format
msgid ""
"\n"
" Are you sure you want to delete %(object)s? This cannot "
"be undone!\n"
" All progress will be deleted and cannot be recovered.\n"
" "
msgstr ""
"\n"
" Er du sikker på at du vil slette %(object)s? Dette kan "
"ikke angres!\n"
" All progresjon vil bli slettet og kan ikke "
"gjennopprettes.\n"
" "

#: trix/trix_student/templates/trix_student/user_delete.django.html:18
msgid "Delete"
msgstr "Slett"

#: trix/trix_student/templates/trix_student/user_delete.django.html:20
msgid "Cancel"
msgstr "Avbryt"

#: trix/trix_student/templates/trix_student/users.django.html:6
msgid "User"
msgstr "Brukernavn"

#: trix/trix_student/templates/trix_student/users.django.html:11
#: trix/trix_student/templates/trix_student/users.django.html:12
msgid "Account overview"
msgstr "Kontooversikt"

#: trix/trix_student/templates/trix_student/users.django.html:12
#: trix/trix_student/templates/trix_student/users.django.html:15
#: trix/trix_student/views/login.py:13
msgid "Email"
msgstr "E-post"

#: trix/trix_student/templates/trix_student/users.django.html:14
#: trix/trix_student/templates/trix_student/users.django.html:19
msgid "Last login"
msgstr "Sist innlogget"

#: trix/trix_student/templates/trix_student/users.django.html:16
#: trix/trix_student/templates/trix_student/users.django.html:23
msgid "Role"
msgstr "Rolle"

#: trix/trix_student/templates/trix_student/users.django.html:31
msgid "DELETE ME"
msgstr "SLETT MEG"

#: trix/trix_student/views/common.py:119
msgid ""
"You have completed {{ solvedPercentage }} percent of assignments matching "
Expand All @@ -289,10 +322,10 @@ msgstr ""
"Vennligst skriv inn en gyldig e-postaddresse og passord. Begge feltene "
"skiller mellom store og små bokstaver."

#: trix/trix_student/views/users.py:28
#: trix/trix_student/views/users.py:30
msgid "Administrator for "
msgstr "Administrator for "

#: trix/trix_student/views/users.py:30
#: trix/trix_student/views/users.py:32
msgid "Student"
msgstr "Student"
13 changes: 13 additions & 0 deletions trix/trix_student/static/trix_student/dist/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -9264,6 +9264,19 @@ body {
display: block;
}
}
/**
* Styles for the profile page.
**/
.trix-user-buttons {
margin-top: 80px;
}
.trix-user-text > h1,
.trix-user-text > p {
margin-bottom: 50px;
}
.trix-user-text > p {
font-size: 1.1em;
}
.codehilite {
/* Comment */
/* Error */
Expand Down
1 change: 1 addition & 0 deletions trix/trix_student/static/trix_student/src/less/styles.less
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
@import "delete";
@import "trix";
@import "print";
@import "users";


.codehilite {
Expand Down
18 changes: 18 additions & 0 deletions trix/trix_student/static/trix_student/src/less/users.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Styles for the profile page.
**/

.trix-user-buttons {
margin-top: 80px;
}

.trix-user-text {
> h1,
> p {
margin-bottom: 50px;
}

> p {
font-size: 1.1em;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
{% if not remove_login %}
<li>
{% if request.user.is_authenticated %}
<a href="{% url 'trix-logout' %}?next={{ request.get_full_path | urlencode }}">
<a href="{% url 'trix_logout' %}?next={{ request.get_full_path | urlencode }}">
<span class="fas fa-sign-out-alt"></span>
{% trans "Sign out" %}
</a>
Expand Down
26 changes: 26 additions & 0 deletions trix/trix_student/templates/trix_student/user_delete.django.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{% extends 'trix_student/users.django.html' %}
{% load i18n %}

{% block body %}
<div class="page-header">
<div class="container">
<div class="trix-user-text">
<h1>{% trans "Delete user" %}</h1>
<p>
{% blocktrans %}
Are you sure you want to delete {{ object }}? This cannot be undone!
All progress will be deleted and cannot be recovered.
{% endblocktrans %}
</p>
</div>
<form action="" method="post">{% csrf_token %}
<div class="trix-user-button">
<button type="submit" class="btn btn-danger">{% trans "Delete" %}</button>
<a class="btn btn-cancel" href="{% url 'trix_profile_page' %}">
{% trans "Cancel" %}
</a>
</div>
</form>
</div>
</div>
{% endblock %}
30 changes: 23 additions & 7 deletions trix/trix_student/templates/trix_student/users.django.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,29 @@
{% block body %}
<div class="page-header">
<div class="container">
<h1>{% trans "Account overview" %}</h3>
<h3>{% trans "Email" %}</h3>
<p>{{ user }}</p>
<h3>{% trans "Last login" %}</h3>
<p>{{ user.last_login }}</p>
<h3>{% trans "Role" %}</h3>
<p>{{ user_role }}</p>
<div class="trix-user-text">
<h1>{% trans "Account overview" %}</h3>
<ul class="list-unstyled">
<li>
<h3>{% trans "Email" %}</h3>
<p>{{ user }}</p>
</li>
<li>
<h3>{% trans "Last login" %}</h3>
<p>{{ user.last_login }}</p>
</li>
<li>
<h3>{% trans "Role" %}</h3>
<p>{{ user_role }}</p>
</li>
</ul>
</div>
<div class="trix-user-buttons">
<a href="{% url 'trix_delete_user' pk=user.id %}" class="btn btn-danger">
<span class="fa fa-bin"></span>
{% trans "DELETE ME" %}
</a>
</div>
</div>
</div>
{% comment %}
Expand Down
7 changes: 5 additions & 2 deletions trix/trix_student/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@
name='trix_student_permalink_list_view'),
url('^user/$',
users.ProfilePageView.as_view(),
name='profile-page'),
name='trix_profile_page'),
url('^user/delete/(?P<pk>\d+)$',
users.UserDeleteView.as_view(),
name="trix_delete_user"),
url(r'^login$', login.TrixLoginView.as_view(), name='trix-login'),
url(r'^logout$',
auth_views.logout,
{'template_name': 'trix_student/logout.django.html'},
name='trix-logout'),
name='trix_logout'),
]
18 changes: 16 additions & 2 deletions trix/trix_student/views/users.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
from django.views.generic import ListView
from django.views.generic import ListView, DeleteView
from django.contrib.auth.mixins import LoginRequiredMixin
from django.utils.translation import ugettext_lazy as _
from django.shortcuts import get_object_or_404
from django.http import Http404
from django.urls import reverse_lazy

from trix.trix_core import models


class ProfilePageView(LoginRequiredMixin, ListView):
template_name = 'trix_student/users.django.html'
model = models.HowSolved
paginate_by = 2

def get_context_data(self):
context = super(ProfilePageView, self).get_context_data()
Expand All @@ -28,3 +30,15 @@ def get_user_role(self):
return _('Administrator for ') + courses_string
else:
return _('Student')


class UserDeleteView(LoginRequiredMixin, DeleteView):
template_name = 'trix_student/user_delete.django.html'
model = models.User
success_url = reverse_lazy('trix_student_dashboard')

def get_object(self, queryset=None):
user = super(UserDeleteView, self).get_object()
if not user.id == self.request.user.id:
raise Http404
return user
12 changes: 12 additions & 0 deletions trix_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from trix.project.production.settings import *
import dj_database_url

# Make this 50 chars and RANDOM - do not share it with anyone
SECRET_KEY = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'

# Database config
DATABASE_URL = 'sqlite:///db.sqlite3'
DATABASES = {'default': dj_database_url.config(default=DATABASE_URL)}

# Set this to False to turn of debug mode in production
DEBUG = False

0 comments on commit 227b4a7

Please sign in to comment.