|
Posted by pigletto |
|
|
In my message board I've created a template tag that displays active monitors for user and allows him to switch them off. I've used this tag in profile edit page, template: community/profile_edit.html:
{% show_active_monitors user %}
I wonder if something like that should be added to SCT? It might be template_tag like mine, or something that uses signals for profiles. What do you think? My code is: common_utils_tags.py
def show_active_monitors(context, profile_user):
user = context['user']
if user==profile_user:
monitors = Monitor.objects.filter(Q(thread=None)|Q(thread__is_hidden=0),
user = profile_user,
group = get_current_group()
)
else:
monitors = Monitor.objects.none()
return {'monitors':monitors}
register.inclusion_tag('common_utils/_show_active_monitors.html', takes_context=True)(show_active_monitors)
Template _show_active_monitors.html:
{% load i18n %}
<h4 class="small_title">{% trans "Forum monitoring - e-mail notifications" %}</h4>
<table class="formatted-table">
{% for monitor in monitors %}
<tr>
<td>{{ forloop.counter }}</td>
<td>{% if monitor.thread %}
<b>{% trans "Thread" %}</b>: {{ monitor.thread }}
{% else %}
{% if monitor.category %}
<b>{% trans "Category" %}</b>: {{ monitor.category }}
{% else %}
{% trans "Whole board monitoring" %}
{% endif %}
{% endif %}
</td>
<td>
{% if monitor.thread %}
<a href="{% url sphboard_toggle_monitor "thread" monitor.thread.pk %}">{% trans "disable" %}</a>
{% else %}
{% if monitor.category %}
<a href="{% url sphboard_toggle_monitor "category" monitor.category.pk %}">{% trans "disable" %}</a>
{% else %}
<a href="{% url sphboard_toggle_monitor "group" 0 %}">{% trans "disable" %}</a>
{% endif %}
{% endif %}
</td>
</tr>
{% empty %}
<tr>
<td>{% trans "You're not monitoring any thread yet" %}</td>
</tr>
{% endfor %}
</table>
|
|
|
Posted by Herbert Poul ![]() |
|
|
that would be a really cool feature to have in the profile.. although i'm not sure if it's better to use signals to embed it right into it, or just create a second view? Hey, we have Signatures !!! Great, isn't it ? ;) |
|
|
Posted by pigletto |
|
So what about just putting a {% show_active_monitors ... %} templateTag into profile_edit.html like I did at ekrawiectwo.net?
IMO this is very good place to display this information (better than another view) and also it is easy for developers to put this tag elsewhere. |
Please login to post a reply.



