mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-25 02:24:26 +00:00
Rename Matmat to Trombi
This commit is contained in:
parent
dec1a2cdd7
commit
f2b2ff533d
@ -7,10 +7,10 @@
|
|||||||
<ul>
|
<ul>
|
||||||
<li> <a href="{{ url('com:news_new') }}?club={{ object.id }}">{% trans %}Create a news{% endtrans %}</a></li>
|
<li> <a href="{{ url('com:news_new') }}?club={{ object.id }}">{% trans %}Create a news{% endtrans %}</a></li>
|
||||||
<li> <a href="{{ url('com:weekmail_article') }}?club={{ object.id }}">{% trans %}Post in the Weekmail{% endtrans %}</a></li>
|
<li> <a href="{{ url('com:weekmail_article') }}?club={{ object.id }}">{% trans %}Post in the Weekmail{% endtrans %}</a></li>
|
||||||
{% if object.matmat %}
|
{% if object.trombi %}
|
||||||
<li> <a href="{{ url('matmat:detail', matmat_id=object.matmat.id) }}">{% trans %}Edit Matmatronch{% endtrans %}</a></li>
|
<li> <a href="{{ url('trombi:detail', trombi_id=object.trombi.id) }}">{% trans %}Edit Trombi{% endtrans %}</a></li>
|
||||||
{% else %}
|
{% else %}
|
||||||
<li> <a href="{{ url('matmat:create', club_id=object.id) }}">{% trans %}New Matmatronch{% endtrans %}</a></li>
|
<li> <a href="{{ url('trombi:create', club_id=object.id) }}">{% trans %}New Trombi{% endtrans %}</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
<h4>{% trans %}Counters:{% endtrans %}</h4>
|
<h4>{% trans %}Counters:{% endtrans %}</h4>
|
||||||
|
@ -88,7 +88,7 @@
|
|||||||
{% if not popup %}
|
{% if not popup %}
|
||||||
<nav>
|
<nav>
|
||||||
<a href="https://ae.utbm.fr/">{% trans %}Main{% endtrans %}</a>
|
<a href="https://ae.utbm.fr/">{% trans %}Main{% endtrans %}</a>
|
||||||
<a href="https://ae.utbm.fr/matmatronch/">{% trans %}Matmatronch{% endtrans %}</a>
|
<a href="https://ae.utbm.fr/trombironch/">{% trans %}Matmatronch{% endtrans %}</a>
|
||||||
<a href="{{ url('core:page', page_name="Index") }}">{% trans %}Wiki{% endtrans %}</a>
|
<a href="{{ url('core:page', page_name="Index") }}">{% trans %}Wiki{% endtrans %}</a>
|
||||||
<a href="{{ url('sas:main') }}">{% trans %}SAS{% endtrans %}</a>
|
<a href="{{ url('sas:main') }}">{% trans %}SAS{% endtrans %}</a>
|
||||||
<a href="{{ url('forum:main') }}">{% trans %}Forum{% endtrans %}</a>
|
<a href="{{ url('forum:main') }}">{% trans %}Forum{% endtrans %}</a>
|
||||||
|
@ -11,14 +11,14 @@
|
|||||||
{{ form.as_p() }}
|
{{ form.as_p() }}
|
||||||
<p><input type="submit" value="{% trans %}Save{% endtrans %}" /></p>
|
<p><input type="submit" value="{% trans %}Save{% endtrans %}" /></p>
|
||||||
</form>
|
</form>
|
||||||
{% if matmat_form %}
|
{% if trombi_form %}
|
||||||
<form action="{{ url('matmat:user_tools') }}" method="post" enctype="multipart/form-data">
|
<form action="{{ url('trombi:user_tools') }}" method="post" enctype="multipart/form-data">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ matmat_form.as_p() }}
|
{{ trombi_form.as_p() }}
|
||||||
<p><input type="submit" value="{% trans %}Save{% endtrans %}" /></p>
|
<p><input type="submit" value="{% trans %}Save{% endtrans %}" /></p>
|
||||||
</form>
|
</form>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p><a href="{{ url('matmat:user_tools') }}">Matmatronch tools</a></p>
|
<p><a href="{{ url('trombi:user_tools') }}">Trombi tools</a></p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ from core.views.forms import RegisteringForm, UserPropForm, UserProfileForm, Log
|
|||||||
from core.models import User, SithFile, Preferences
|
from core.models import User, SithFile, Preferences
|
||||||
from club.models import Club
|
from club.models import Club
|
||||||
from subscription.models import Subscription
|
from subscription.models import Subscription
|
||||||
from matmat.views import UserMatmatForm
|
from trombi.views import UserTrombiForm
|
||||||
|
|
||||||
def login(request):
|
def login(request):
|
||||||
"""
|
"""
|
||||||
@ -449,8 +449,8 @@ class UserPreferencesView(UserTabsMixin, CanEditMixin, UpdateView):
|
|||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
kwargs = super(UserPreferencesView, self).get_context_data(**kwargs)
|
kwargs = super(UserPreferencesView, self).get_context_data(**kwargs)
|
||||||
if not hasattr(self.object, 'matmat_user'):
|
if not hasattr(self.object, 'trombi_user'):
|
||||||
kwargs['matmat_form'] = UserMatmatForm()
|
kwargs['trombi_form'] = UserTrombiForm()
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
class UserUpdateGroupView(UserTabsMixin, CanEditPropMixin, UpdateView):
|
class UserUpdateGroupView(UserTabsMixin, CanEditPropMixin, UpdateView):
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
from django.conf import settings
|
|
||||||
import django.db.models.deletion
|
|
||||||
import django.utils.timezone
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
|
||||||
('club', '0007_auto_20170324_0917'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='Matmat',
|
|
||||||
fields=[
|
|
||||||
('id', models.AutoField(primary_key=True, verbose_name='ID', auto_created=True, serialize=False)),
|
|
||||||
('subscription_deadline', models.DateField(verbose_name='subscription deadline', default=django.utils.timezone.now, help_text='Before this date, users are allowed to subscribe to this Matmatronch. After this date, users subscribed will be allowed to comment on each other.')),
|
|
||||||
('comments_deadline', models.DateField(verbose_name='comments deadline', default=django.utils.timezone.now, help_text="After this date, users won't be able to make comments anymore")),
|
|
||||||
('club', models.OneToOneField(related_name='matmat', to='club.Club')),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='MatmatComment',
|
|
||||||
fields=[
|
|
||||||
('id', models.AutoField(primary_key=True, verbose_name='ID', auto_created=True, serialize=False)),
|
|
||||||
('author', models.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, blank=True, verbose_name='matmat', to=settings.AUTH_USER_MODEL, related_name='users', null=True)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='MatmatUser',
|
|
||||||
fields=[
|
|
||||||
('id', models.AutoField(primary_key=True, verbose_name='ID', auto_created=True, serialize=False)),
|
|
||||||
('matmat', models.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, blank=True, verbose_name='matmat', to='matmat.Matmat', related_name='users', null=True)),
|
|
||||||
('user', models.OneToOneField(related_name='matmat_user', verbose_name='matmat user', to=settings.AUTH_USER_MODEL)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
]
|
|
@ -1,41 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('matmat', '0001_initial'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='matmat',
|
|
||||||
name='max_chars',
|
|
||||||
field=models.IntegerField(help_text='maximum number of characters allowed in a comment', default=400, verbose_name='maximum characters'),
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='matmatcomment',
|
|
||||||
name='content',
|
|
||||||
field=models.TextField(default='', verbose_name='content'),
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='matmatcomment',
|
|
||||||
name='is_moderated',
|
|
||||||
field=models.BooleanField(default=False, verbose_name='is moderated'),
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='matmatcomment',
|
|
||||||
name='target',
|
|
||||||
field=models.ForeignKey(verbose_name='target', to='matmat.MatmatUser', related_name='received_comments', default=0),
|
|
||||||
preserve_default=False,
|
|
||||||
),
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='matmatcomment',
|
|
||||||
name='author',
|
|
||||||
field=models.ForeignKey(verbose_name='author', to='matmat.MatmatUser', related_name='given_comments', default=0),
|
|
||||||
preserve_default=False,
|
|
||||||
),
|
|
||||||
]
|
|
@ -1,18 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('matmat', '0002_auto_20170510_1754'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.RemoveField(
|
|
||||||
model_name='matmatcomment',
|
|
||||||
name='is_moderated',
|
|
||||||
),
|
|
||||||
]
|
|
@ -86,7 +86,7 @@ INSTALLED_APPS = (
|
|||||||
'election',
|
'election',
|
||||||
'forum',
|
'forum',
|
||||||
'stock',
|
'stock',
|
||||||
'matmat',
|
'trombi',
|
||||||
)
|
)
|
||||||
|
|
||||||
MIDDLEWARE_CLASSES = (
|
MIDDLEWARE_CLASSES = (
|
||||||
|
@ -66,7 +66,7 @@ urlpatterns = [
|
|||||||
url(r'^api/v1/', include('api.urls', namespace="api", app_name="api")),
|
url(r'^api/v1/', include('api.urls', namespace="api", app_name="api")),
|
||||||
url(r'^election/', include('election.urls', namespace="election", app_name="election")),
|
url(r'^election/', include('election.urls', namespace="election", app_name="election")),
|
||||||
url(r'^forum/', include('forum.urls', namespace="forum", app_name="forum")),
|
url(r'^forum/', include('forum.urls', namespace="forum", app_name="forum")),
|
||||||
url(r'^matmat/', include('matmat.urls', namespace="matmat", app_name="matmat")),
|
url(r'^trombi/', include('trombi.urls', namespace="trombi", app_name="trombi")),
|
||||||
url(r'^admin/', include(admin.site.urls)),
|
url(r'^admin/', include(admin.site.urls)),
|
||||||
url(r'^ajax_select/', include(ajax_select_urls)),
|
url(r'^ajax_select/', include(ajax_select_urls)),
|
||||||
url(r'^i18n/', include('django.conf.urls.i18n')),
|
url(r'^i18n/', include('django.conf.urls.i18n')),
|
||||||
|
@ -24,6 +24,6 @@
|
|||||||
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
from matmat.models import Matmat
|
from trombi.models import Trombi
|
||||||
|
|
||||||
admin.site.register(Matmat)
|
admin.site.register(Trombi)
|
53
trombi/migrations/0001_initial.py
Normal file
53
trombi/migrations/0001_initial.py
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
from django.conf import settings
|
||||||
|
import django.utils.timezone
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
('club', '0007_auto_20170324_0917'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Trombi',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(primary_key=True, verbose_name='ID', serialize=False, auto_created=True)),
|
||||||
|
('subscription_deadline', models.DateField(verbose_name='subscription deadline', default=django.utils.timezone.now, help_text='Before this date, users are allowed to subscribe to this Trombi. After this date, users subscribed will be allowed to comment on each other.')),
|
||||||
|
('comments_deadline', models.DateField(verbose_name='comments deadline', default=django.utils.timezone.now, help_text="After this date, users won't be able to make comments anymore")),
|
||||||
|
('max_chars', models.IntegerField(verbose_name='maximum characters', default=400, help_text='maximum number of characters allowed in a comment')),
|
||||||
|
('club', models.OneToOneField(to='club.Club', related_name='trombi')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='TrombiComment',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(primary_key=True, verbose_name='ID', serialize=False, auto_created=True)),
|
||||||
|
('content', models.TextField(verbose_name='content', default='')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='TrombiUser',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(primary_key=True, verbose_name='ID', serialize=False, auto_created=True)),
|
||||||
|
('trombi', models.ForeignKey(to='trombi.Trombi', related_name='users', verbose_name='trombi', null=True, blank=True, on_delete=django.db.models.deletion.SET_NULL)),
|
||||||
|
('user', models.OneToOneField(to=settings.AUTH_USER_MODEL, related_name='trombi_user', verbose_name='trombi user')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='trombicomment',
|
||||||
|
name='author',
|
||||||
|
field=models.ForeignKey(to='trombi.TrombiUser', related_name='given_comments', verbose_name='author'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='trombicomment',
|
||||||
|
name='target',
|
||||||
|
field=models.ForeignKey(to='trombi.TrombiUser', related_name='received_comments', verbose_name='target'),
|
||||||
|
),
|
||||||
|
]
|
@ -34,34 +34,34 @@ from datetime import timedelta, date
|
|||||||
from core.models import User
|
from core.models import User
|
||||||
from club.models import Club
|
from club.models import Club
|
||||||
|
|
||||||
class MatmatManager(models.Manager):
|
class TrombiManager(models.Manager):
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return super(MatmatManager, self).get_queryset()
|
return super(TrombiManager, self).get_queryset()
|
||||||
|
|
||||||
class AvailableMatmatManager(models.Manager):
|
class AvailableTrombiManager(models.Manager):
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return super(AvailableMatmatManager,
|
return super(AvailableTrombiManager,
|
||||||
self).get_queryset().filter(subscription_deadline__gte=date.today())
|
self).get_queryset().filter(subscription_deadline__gte=date.today())
|
||||||
|
|
||||||
class Matmat(models.Model):
|
class Trombi(models.Model):
|
||||||
"""
|
"""
|
||||||
This is the main class, the Matmat itself.
|
This is the main class, the Trombi itself.
|
||||||
It contains the deadlines for the users, and the link to the club that makes
|
It contains the deadlines for the users, and the link to the club that makes
|
||||||
its Matmatronch.
|
its Trombi.
|
||||||
"""
|
"""
|
||||||
subscription_deadline = models.DateField(_('subscription deadline'),
|
subscription_deadline = models.DateField(_('subscription deadline'),
|
||||||
default=timezone.now, help_text=_("Before this date, users are "
|
default=timezone.now, help_text=_("Before this date, users are "
|
||||||
"allowed to subscribe to this Matmatronch. "
|
"allowed to subscribe to this Trombi. "
|
||||||
"After this date, users subscribed will be allowed to comment on each other."))
|
"After this date, users subscribed will be allowed to comment on each other."))
|
||||||
comments_deadline = models.DateField(_('comments deadline'),
|
comments_deadline = models.DateField(_('comments deadline'),
|
||||||
default=timezone.now, help_text=_("After this date, users won't be "
|
default=timezone.now, help_text=_("After this date, users won't be "
|
||||||
"able to make comments anymore"))
|
"able to make comments anymore"))
|
||||||
max_chars = models.IntegerField(_('maximum characters'), default=400,
|
max_chars = models.IntegerField(_('maximum characters'), default=400,
|
||||||
help_text=_('maximum number of characters allowed in a comment'))
|
help_text=_('maximum number of characters allowed in a comment'))
|
||||||
club = models.OneToOneField(Club, related_name='matmat')
|
club = models.OneToOneField(Club, related_name='trombi')
|
||||||
|
|
||||||
objects = MatmatManager()
|
objects = TrombiManager()
|
||||||
availables = AvailableMatmatManager()
|
availables = AvailableTrombiManager()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return str(self.club.name)
|
return str(self.club.name)
|
||||||
@ -72,7 +72,7 @@ class Matmat(models.Model):
|
|||||||
"comments is definitively not a good idea."))
|
"comments is definitively not a good idea."))
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse('matmat:detail', kwargs={'matmat_id': self.id})
|
return reverse('trombi:detail', kwargs={'trombi_id': self.id})
|
||||||
|
|
||||||
def is_owned_by(self, user):
|
def is_owned_by(self, user):
|
||||||
return user.is_owner(self.club)
|
return user.is_owner(self.club)
|
||||||
@ -83,25 +83,25 @@ class Matmat(models.Model):
|
|||||||
def can_be_viewed_by(self, user):
|
def can_be_viewed_by(self, user):
|
||||||
return user.id in [u.user.id for u in self.users.all()]
|
return user.id in [u.user.id for u in self.users.all()]
|
||||||
|
|
||||||
class MatmatUser(models.Model):
|
class TrombiUser(models.Model):
|
||||||
"""
|
"""
|
||||||
This class is only here to avoid cross references between the core, club,
|
This class is only here to avoid cross references between the core, club,
|
||||||
and matmat modules. It binds a User to a Matmat without needing to import
|
and trombi modules. It binds a User to a Trombi without needing to import
|
||||||
Matmat into the core.
|
Trombi into the core.
|
||||||
"""
|
"""
|
||||||
user = models.OneToOneField(User, verbose_name=_("matmat user"), related_name='matmat_user')
|
user = models.OneToOneField(User, verbose_name=_("trombi user"), related_name='trombi_user')
|
||||||
matmat = models.ForeignKey(Matmat, verbose_name=_("matmat"), related_name='users', blank=True, null=True, on_delete=models.SET_NULL)
|
trombi = models.ForeignKey(Trombi, verbose_name=_("trombi"), related_name='users', blank=True, null=True, on_delete=models.SET_NULL)
|
||||||
|
|
||||||
class MatmatComment(models.Model):
|
class TrombiComment(models.Model):
|
||||||
"""
|
"""
|
||||||
This represent a comment given by someone to someone else in the same Matmat
|
This represent a comment given by someone to someone else in the same Trombi
|
||||||
instance.
|
instance.
|
||||||
"""
|
"""
|
||||||
author = models.ForeignKey(MatmatUser, verbose_name=_("author"), related_name='given_comments')
|
author = models.ForeignKey(TrombiUser, verbose_name=_("author"), related_name='given_comments')
|
||||||
target = models.ForeignKey(MatmatUser, verbose_name=_("target"), related_name='received_comments')
|
target = models.ForeignKey(TrombiUser, verbose_name=_("target"), related_name='received_comments')
|
||||||
content = models.TextField(_("content"), default="")
|
content = models.TextField(_("content"), default="")
|
||||||
|
|
||||||
def can_be_viewed_by(self, user):
|
def can_be_viewed_by(self, user):
|
||||||
if user.id == self.target.user.id:
|
if user.id == self.target.user.id:
|
||||||
return False
|
return False
|
||||||
return user.id == self.author.user.id or user.can_edit(self.author.matmat)
|
return user.id == self.author.user.id or user.can_edit(self.author.trombi)
|
@ -1,19 +1,19 @@
|
|||||||
{% extends 'core/base.jinja' %}
|
{% extends 'core/base.jinja' %}
|
||||||
|
|
||||||
{% block title %}
|
{% block title %}
|
||||||
{% trans club=object.club %}{{ club }}'s Matmatronch{% endtrans %}
|
{% trans club=object.club %}{{ club }}'s Trombi{% endtrans %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h2>{% trans club=object.club %}{{ club }}'s Matmatronch{% endtrans %}</h2>
|
<h2>{% trans club=object.club %}{{ club }}'s Trombi{% endtrans %}</h2>
|
||||||
<a href="{{ url('matmat:edit', matmat_id=object.id) }}">Edit</a>
|
<a href="{{ url('trombi:edit', trombi_id=object.id) }}">Edit</a>
|
||||||
<p>Subscription deadline: {{ object.subscription_deadline|date(DATETIME_FORMAT) }}</p>
|
<p>Subscription deadline: {{ object.subscription_deadline|date(DATETIME_FORMAT) }}</p>
|
||||||
<p>Comment deadline: {{ object.comments_deadline|date(DATETIME_FORMAT) }}</p>
|
<p>Comment deadline: {{ object.comments_deadline|date(DATETIME_FORMAT) }}</p>
|
||||||
<a href="#">Export</a>
|
<a href="#">Export</a>
|
||||||
<p>People:</p>
|
<p>People:</p>
|
||||||
<ul>
|
<ul>
|
||||||
{% for u in object.users.all() %}
|
{% for u in object.users.all() %}
|
||||||
<li>{{ u.user.get_display_name() }} - <a href="{{ url('matmat:delete_user', matmat_id=object.id, user_id=u.id) }}">Delete</a></li>
|
<li>{{ u.user.get_display_name() }} - <a href="{{ url('trombi:delete_user', trombi_id=object.id, user_id=u.id) }}">Delete</a></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -1,11 +1,11 @@
|
|||||||
{% extends "core/base.jinja" %}
|
{% extends "core/base.jinja" %}
|
||||||
|
|
||||||
{% block title %}
|
{% block title %}
|
||||||
{% trans user_name=user.get_display_name() %}{{ user_name }}'s Matmat{% endtrans %}
|
{% trans user_name=user.get_display_name() %}{{ user_name }}'s Trombi{% endtrans %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h3>{% trans%}Matmatronch'{% endtrans %}</h3>
|
<h3>{% trans%}Trombi'{% endtrans %}</h3>
|
||||||
{% if subscribe_form %}
|
{% if subscribe_form %}
|
||||||
<form action="" method="post">
|
<form action="" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
@ -13,18 +13,18 @@
|
|||||||
<p><input type="submit" value="{% trans %}Save{% endtrans %}" /></p>
|
<p><input type="submit" value="{% trans %}Save{% endtrans %}" /></p>
|
||||||
</form>
|
</form>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>{% trans matmat = user.matmat_user.matmat %}You are subscribed to the Matmatronch {{ matmat }}{% endtrans %}</p>
|
<p>{% trans trombi = user.trombi_user.trombi %}You are subscribed to the Trombi {{ trombi }}{% endtrans %}</p>
|
||||||
<p><a href="{{ url("matmat:profile") }}">Edit my profile</a></p>
|
<p><a href="{{ url("trombi:profile") }}">Edit my profile</a></p>
|
||||||
<hr>
|
<hr>
|
||||||
<div>
|
<div>
|
||||||
{% for u in user.matmat_user.matmat.users.exclude(id=user.matmat_user.id) %}
|
{% for u in user.trombi_user.trombi.users.exclude(id=user.trombi_user.id) %}
|
||||||
<div class="ib">
|
<div class="ib">
|
||||||
<div>{{ u.user.get_display_name() }}</div>
|
<div>{{ u.user.get_display_name() }}</div>
|
||||||
{% set comment = u.received_comments.filter(author__id=user.matmat_user.id).first() %}
|
{% set comment = u.received_comments.filter(author__id=user.trombi_user.id).first() %}
|
||||||
{% if comment %}
|
{% if comment %}
|
||||||
<a href="{{ url("matmat:edit_comment", comment_id=comment.id) }}">Edit comment</a>
|
<a href="{{ url("trombi:edit_comment", comment_id=comment.id) }}">Edit comment</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="{{ url("matmat:new_comment", user_id=u.id) }}">Comment</a>
|
<a href="{{ url("trombi:new_comment", user_id=u.id) }}">Comment</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
@ -24,16 +24,16 @@
|
|||||||
|
|
||||||
from django.conf.urls import url, include
|
from django.conf.urls import url, include
|
||||||
|
|
||||||
from matmat.views import *
|
from trombi.views import *
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^(?P<club_id>[0-9]+)/new$', MatmatCreateView.as_view(), name='create'),
|
url(r'^(?P<club_id>[0-9]+)/new$', TrombiCreateView.as_view(), name='create'),
|
||||||
url(r'^(?P<matmat_id>[0-9]+)/edit$', MatmatEditView.as_view(), name='edit'),
|
url(r'^(?P<trombi_id>[0-9]+)/edit$', TrombiEditView.as_view(), name='edit'),
|
||||||
url(r'^(?P<matmat_id>[0-9]+)/delete/(?P<user_id>[0-9]+)$', MatmatDeleteUserView.as_view(), name='delete_user'),
|
url(r'^(?P<trombi_id>[0-9]+)/delete/(?P<user_id>[0-9]+)$', TrombiDeleteUserView.as_view(), name='delete_user'),
|
||||||
url(r'^(?P<matmat_id>[0-9]+)$', MatmatDetailView.as_view(), name='detail'),
|
url(r'^(?P<trombi_id>[0-9]+)$', TrombiDetailView.as_view(), name='detail'),
|
||||||
url(r'^(?P<user_id>[0-9]+)/new_comment$', MatmatCommentCreateView.as_view(), name='new_comment'),
|
url(r'^(?P<user_id>[0-9]+)/new_comment$', TrombiCommentCreateView.as_view(), name='new_comment'),
|
||||||
url(r'^comment/(?P<comment_id>[0-9]+)/edit$', MatmatCommentEditView.as_view(), name='edit_comment'),
|
url(r'^comment/(?P<comment_id>[0-9]+)/edit$', TrombiCommentEditView.as_view(), name='edit_comment'),
|
||||||
url(r'^tools$', UserMatmatToolsView.as_view(), name='user_tools'),
|
url(r'^tools$', UserTrombiToolsView.as_view(), name='user_tools'),
|
||||||
url(r'^profile$', UserMatmatEditProfileView.as_view(), name='profile'),
|
url(r'^profile$', UserTrombiEditProfileView.as_view(), name='profile'),
|
||||||
]
|
]
|
||||||
|
|
@ -30,27 +30,27 @@ from django.utils.translation import ugettext_lazy as _
|
|||||||
from django import forms
|
from django import forms
|
||||||
from django.forms.models import modelform_factory
|
from django.forms.models import modelform_factory
|
||||||
|
|
||||||
from matmat.models import Matmat, MatmatUser, MatmatComment
|
from trombi.models import Trombi, TrombiUser, TrombiComment
|
||||||
from core.views.forms import SelectFile, SelectDate
|
from core.views.forms import SelectFile, SelectDate
|
||||||
from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin, TabedViewMixin, CanCreateMixin, QuickNotifMixin
|
from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin, TabedViewMixin, CanCreateMixin, QuickNotifMixin
|
||||||
from core.models import User
|
from core.models import User
|
||||||
from club.models import Club
|
from club.models import Club
|
||||||
|
|
||||||
class MatmatForm(forms.ModelForm):
|
class TrombiForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Matmat
|
model = Trombi
|
||||||
fields = ['subscription_deadline', 'comments_deadline', 'max_chars']
|
fields = ['subscription_deadline', 'comments_deadline', 'max_chars']
|
||||||
widgets = {
|
widgets = {
|
||||||
'subscription_deadline': SelectDate,
|
'subscription_deadline': SelectDate,
|
||||||
'comments_deadline': SelectDate,
|
'comments_deadline': SelectDate,
|
||||||
}
|
}
|
||||||
|
|
||||||
class MatmatCreateView(CanEditPropMixin, CreateView):
|
class TrombiCreateView(CanEditPropMixin, CreateView):
|
||||||
"""
|
"""
|
||||||
Create a matmat for a club
|
Create a trombi for a club
|
||||||
"""
|
"""
|
||||||
model = Matmat
|
model = Trombi
|
||||||
form_class = MatmatForm
|
form_class = TrombiForm
|
||||||
template_name = 'core/create.jinja'
|
template_name = 'core/create.jinja'
|
||||||
|
|
||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
@ -66,59 +66,59 @@ class MatmatCreateView(CanEditPropMixin, CreateView):
|
|||||||
else:
|
else:
|
||||||
return self.form_invalid(form)
|
return self.form_invalid(form)
|
||||||
|
|
||||||
class MatmatEditView(CanEditPropMixin, UpdateView):
|
class TrombiEditView(CanEditPropMixin, UpdateView):
|
||||||
model = Matmat
|
model = Trombi
|
||||||
form_class = MatmatForm
|
form_class = TrombiForm
|
||||||
template_name = 'core/edit.jinja'
|
template_name = 'core/edit.jinja'
|
||||||
pk_url_kwarg = 'matmat_id'
|
pk_url_kwarg = 'trombi_id'
|
||||||
|
|
||||||
class MatmatDetailView(CanEditMixin, DetailView):
|
class TrombiDetailView(CanEditMixin, DetailView):
|
||||||
model = Matmat
|
model = Trombi
|
||||||
template_name = 'matmat/detail.jinja'
|
template_name = 'trombi/detail.jinja'
|
||||||
pk_url_kwarg = 'matmat_id'
|
pk_url_kwarg = 'trombi_id'
|
||||||
|
|
||||||
class MatmatDeleteUserView(CanEditPropMixin, SingleObjectMixin, RedirectView):
|
class TrombiDeleteUserView(CanEditPropMixin, SingleObjectMixin, RedirectView):
|
||||||
model = Matmat
|
model = Trombi
|
||||||
pk_url_kwarg = 'matmat_id'
|
pk_url_kwarg = 'trombi_id'
|
||||||
permanent = False
|
permanent = False
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
self.object = self.get_object()
|
self.object = self.get_object()
|
||||||
user = get_object_or_404(MatmatUser, id=self.kwargs['user_id'])
|
user = get_object_or_404(TrombiUser, id=self.kwargs['user_id'])
|
||||||
user.delete()
|
user.delete()
|
||||||
# See if we need to also delete the comments on the user, or if we keep them
|
# See if we need to also delete the comments on the user, or if we keep them
|
||||||
return redirect(self.object.get_absolute_url())
|
return redirect(self.object.get_absolute_url())
|
||||||
|
|
||||||
# User side
|
# User side
|
||||||
class UserMatmatForm(forms.Form):
|
class UserTrombiForm(forms.Form):
|
||||||
matmat = forms.ModelChoiceField(Matmat.availables.all(), required=False, label=_("Select matmatronch"),
|
trombi = forms.ModelChoiceField(Trombi.availables.all(), required=False, label=_("Select trombi"),
|
||||||
help_text=_("This allows you to subscribe to a Matmatronch. "
|
help_text=_("This allows you to subscribe to a Trombi. "
|
||||||
"Be aware that you can subscribe only once, so don't play with that, "
|
"Be aware that you can subscribe only once, so don't play with that, "
|
||||||
"or you will expose yourself to the admins' wrath!"))
|
"or you will expose yourself to the admins' wrath!"))
|
||||||
|
|
||||||
class UserMatmatToolsView(QuickNotifMixin, TemplateView):
|
class UserTrombiToolsView(QuickNotifMixin, TemplateView):
|
||||||
"""
|
"""
|
||||||
Display a user's matmat tools
|
Display a user's trombi tools
|
||||||
"""
|
"""
|
||||||
template_name = "matmat/user_tools.jinja"
|
template_name = "trombi/user_tools.jinja"
|
||||||
|
|
||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
self.form = UserMatmatForm(request.POST)
|
self.form = UserTrombiForm(request.POST)
|
||||||
if self.form.is_valid():
|
if self.form.is_valid():
|
||||||
matmat_user = MatmatUser(user=request.user,
|
trombi_user = TrombiUser(user=request.user,
|
||||||
matmat=self.form.cleaned_data['matmat'])
|
trombi=self.form.cleaned_data['trombi'])
|
||||||
matmat_user.save()
|
trombi_user.save()
|
||||||
self.quick_notif_list += ['qn_success']
|
self.quick_notif_list += ['qn_success']
|
||||||
return super(UserMatmatToolsView, self).get(request, *args, **kwargs)
|
return super(UserTrombiToolsView, self).get(request, *args, **kwargs)
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
kwargs = super(UserMatmatToolsView, self).get_context_data(**kwargs)
|
kwargs = super(UserTrombiToolsView, self).get_context_data(**kwargs)
|
||||||
kwargs['user'] = self.request.user
|
kwargs['user'] = self.request.user
|
||||||
if not hasattr(self.request.user, 'matmat_user'):
|
if not hasattr(self.request.user, 'trombi_user'):
|
||||||
kwargs['subscribe_form'] = UserMatmatForm()
|
kwargs['subscribe_form'] = UserTrombiForm()
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
class UserMatmatEditProfileView(UpdateView):
|
class UserTrombiEditProfileView(UpdateView):
|
||||||
model = User
|
model = User
|
||||||
form_class = modelform_factory(User,
|
form_class = modelform_factory(User,
|
||||||
fields=['second_email', 'phone', 'department', 'dpt_option',
|
fields=['second_email', 'phone', 'department', 'dpt_option',
|
||||||
@ -129,41 +129,41 @@ class UserMatmatEditProfileView(UpdateView):
|
|||||||
'parent_address': _("Native town"),
|
'parent_address': _("Native town"),
|
||||||
})
|
})
|
||||||
template_name = "core/edit.jinja"
|
template_name = "core/edit.jinja"
|
||||||
success_url = reverse_lazy('matmat:user_tools')
|
success_url = reverse_lazy('trombi:user_tools')
|
||||||
|
|
||||||
def get_object(self):
|
def get_object(self):
|
||||||
return self.request.user
|
return self.request.user
|
||||||
|
|
||||||
class MatmatCommentFormView():
|
class TrombiCommentFormView():
|
||||||
"""
|
"""
|
||||||
Create/edit a matmat comment
|
Create/edit a trombi comment
|
||||||
"""
|
"""
|
||||||
model = MatmatComment
|
model = TrombiComment
|
||||||
fields = ['content']
|
fields = ['content']
|
||||||
|
|
||||||
def get_form_class(self):
|
def get_form_class(self):
|
||||||
self.matmat = self.request.user.matmat_user.matmat
|
self.trombi = self.request.user.trombi_user.trombi
|
||||||
return modelform_factory(self.model, fields=self.fields,
|
return modelform_factory(self.model, fields=self.fields,
|
||||||
widgets={
|
widgets={
|
||||||
'content': forms.widgets.Textarea(attrs={'maxlength': self.matmat.max_chars})
|
'content': forms.widgets.Textarea(attrs={'maxlength': self.trombi.max_chars})
|
||||||
},
|
},
|
||||||
help_texts={
|
help_texts={
|
||||||
'content': _("Maximum characters: %(max_length)s") % {'max_length': self.matmat.max_chars}
|
'content': _("Maximum characters: %(max_length)s") % {'max_length': self.trombi.max_chars}
|
||||||
})
|
})
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
return reverse('matmat:user_tools')
|
return reverse('trombi:user_tools')
|
||||||
|
|
||||||
class MatmatCommentCreateView(MatmatCommentFormView, CreateView):
|
class TrombiCommentCreateView(TrombiCommentFormView, CreateView):
|
||||||
template_name = 'core/create.jinja'
|
template_name = 'core/create.jinja'
|
||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
target = get_object_or_404(MatmatUser, id=self.kwargs['user_id'])
|
target = get_object_or_404(TrombiUser, id=self.kwargs['user_id'])
|
||||||
form.instance.author = self.request.user.matmat_user
|
form.instance.author = self.request.user.trombi_user
|
||||||
form.instance.target = target
|
form.instance.target = target
|
||||||
return super(MatmatCommentCreateView, self).form_valid(form)
|
return super(TrombiCommentCreateView, self).form_valid(form)
|
||||||
|
|
||||||
class MatmatCommentEditView(MatmatCommentFormView, CanViewMixin, UpdateView):
|
class TrombiCommentEditView(TrombiCommentFormView, CanViewMixin, UpdateView):
|
||||||
pk_url_kwarg = "comment_id"
|
pk_url_kwarg = "comment_id"
|
||||||
template_name = 'core/edit.jinja'
|
template_name = 'core/edit.jinja'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user