mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-25 18:44:23 +00:00
Add profiles to Trombi
This commit is contained in:
parent
d88ffae51b
commit
adeda41b52
19
trombi/migrations/0002_trombi_show_profiles.py
Normal file
19
trombi/migrations/0002_trombi_show_profiles.py
Normal file
@ -0,0 +1,19 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('trombi', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='trombi',
|
||||
name='show_profiles',
|
||||
field=models.BooleanField(default=True, verbose_name='show users profiles to each other'),
|
||||
),
|
||||
]
|
@ -57,6 +57,7 @@ class Trombi(models.Model):
|
||||
"able to make comments anymore."))
|
||||
max_chars = models.IntegerField(_('maximum characters'), default=400,
|
||||
help_text=_('Maximum number of characters allowed in a comment.'))
|
||||
show_profiles = models.BooleanField(_("show users profiles to each other"), default=True)
|
||||
club = models.OneToOneField(Club, related_name='trombi')
|
||||
|
||||
objects = TrombiManager()
|
||||
|
35
trombi/templates/trombi/user_profile.jinja
Normal file
35
trombi/templates/trombi/user_profile.jinja
Normal file
@ -0,0 +1,35 @@
|
||||
{% extends "core/base.jinja" %}
|
||||
|
||||
{% block title %}
|
||||
{% trans user_name=trombi_user.user.get_display_name() %}{{ user_name }}'s Trombi profile{% endtrans %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h3>{% trans user_name=trombi_user.user.get_display_name() %}{{ user_name }}'s Trombi profile{% endtrans %}</h3>
|
||||
<p> <a href="{{ url('trombi:user_tools') }}">{% trans %}Back to tools{% endtrans %}</a></p>
|
||||
<div>
|
||||
{% set profile_file = None %}
|
||||
{% set scrub_file = None %}
|
||||
{% if trombi_user.profile_pict %}
|
||||
{% set profile_file = trombi_user.profile_pict.url %}
|
||||
{% else %}
|
||||
{% set profile_file = static('core/img/na.gif') %}
|
||||
{% endif %}
|
||||
{% if trombi_user.scrub_pict %}
|
||||
{% set scrub_file = trombi_user.scrub_pict.url %}
|
||||
{% else %}
|
||||
{% set scrub_file = static('core/img/na.gif') %}
|
||||
{% endif %}
|
||||
<div style="max-width: 410px; margin: auto;">
|
||||
<img src="{{ profile_file }}" alt="" style="max-width: 200px">
|
||||
<img src="{{ scrub_file }}" alt="" style="max-width: 200px">
|
||||
</div>
|
||||
<dl>
|
||||
{% for c in trombi_user.received_comments.all() %}
|
||||
<dt style="font-weight: bold; font-size: 110%">{{ c.author.user.get_display_name() }}</dt>
|
||||
<dd>{{ c.content}}</dd>
|
||||
{% endfor %}
|
||||
</dl>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
@ -38,6 +38,12 @@
|
||||
<img src="{{ file }}" alt="" style="max-width: 100px">
|
||||
</div>
|
||||
<div>{{ u.user.get_display_name() }}</div>
|
||||
{% if trombi.show_profiles %}
|
||||
<div>
|
||||
<a href="{{ url("trombi:user_profile", user_id=u.id) }}">{% trans %}Profile{% endtrans %}</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div>
|
||||
{% if can_comment %}
|
||||
{% set comment = u.received_comments.filter(author__id=user.trombi_user.id).first() %}
|
||||
{% if comment %}
|
||||
@ -47,6 +53,7 @@
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
@ -32,6 +32,7 @@ urlpatterns = [
|
||||
url(r'^(?P<trombi_id>[0-9]+)/delete/(?P<user_id>[0-9]+)$', TrombiDeleteUserView.as_view(), name='delete_user'),
|
||||
url(r'^(?P<trombi_id>[0-9]+)$', TrombiDetailView.as_view(), name='detail'),
|
||||
url(r'^(?P<user_id>[0-9]+)/new_comment$', TrombiCommentCreateView.as_view(), name='new_comment'),
|
||||
url(r'^(?P<user_id>[0-9]+)/profile$', UserTrombiProfileView.as_view(), name='user_profile'),
|
||||
url(r'^comment/(?P<comment_id>[0-9]+)/edit$', TrombiCommentEditView.as_view(), name='edit_comment'),
|
||||
url(r'^tools$', UserTrombiToolsView.as_view(), name='user_tools'),
|
||||
url(r'^profile$', UserTrombiEditProfileView.as_view(), name='profile'),
|
||||
|
@ -42,7 +42,7 @@ from club.models import Club
|
||||
class TrombiForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Trombi
|
||||
fields = ['subscription_deadline', 'comments_deadline', 'max_chars']
|
||||
fields = ['subscription_deadline', 'comments_deadline', 'max_chars', 'show_profiles']
|
||||
widgets = {
|
||||
'subscription_deadline': SelectDate,
|
||||
'comments_deadline': SelectDate,
|
||||
@ -160,6 +160,20 @@ class UserTrombiEditProfileView(UpdateView):
|
||||
def get_success_url(self):
|
||||
return reverse('trombi:user_tools')+"?qn_success"
|
||||
|
||||
class UserTrombiProfileView(DetailView):
|
||||
model = TrombiUser
|
||||
pk_url_kwarg = "user_id"
|
||||
template_name = "trombi/user_profile.jinja"
|
||||
context_object_name = "trombi_user"
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
self.object = self.get_object()
|
||||
if (self.object.trombi.id != request.user.trombi_user.trombi.id or
|
||||
self.object.user.id == request.user.id or
|
||||
not self.object.trombi.show_profiles):
|
||||
raise Http404()
|
||||
return super(UserTrombiProfileView, self).get(request, *args, **kwargs)
|
||||
|
||||
class TrombiCommentFormView():
|
||||
"""
|
||||
Create/edit a trombi comment
|
||||
|
Loading…
Reference in New Issue
Block a user