1. Rufus Pollock
  2. community-pinax

Source

community-pinax / apps / basic_groups / templates / basic_groups / group.html

{% extends "basic_groups/base.html" %}

{% load i18n %}
{# load avatar_tags #}
{% load extra_tagging_tags %}
{% load group_tags %}
{% load basic_group_tags %}
{% load theme_tags %}

{% block head_title %}{{ group.name }}{% endblock %}

{% block body %}

    {% if user.is_authenticated %}
        <div class="right_panel">
            <div class="members">
                <h2>{% trans "Members" %}</h2>
                <table width="100%">
                    {% for member in group.members.all %}
                        {% if forloop.counter0|divisibleby:"3" %}<tr>{% endif %}
                        <td>
                            <div class="avatar">{# avatar member 40 #}</div>
                            <div class="details"><a href="{% url profile_detail member.username %}" title="{{ member.username }}">{{ member.username }}</a></div>
                        </td>
                        {% if forloop.counter0|add:"1"|divisibleby:"3" %}</tr>{% endif %}
                    {% endfor %}
                    {% if group.members.all|length|divisibleby:"3" %}{% else %}</tr>{% endif %}
                </table>
            </div>
        </div>
    {% endif %}
    
    <div style="width: 550px;">
        
        <h1>{% trans "Group" %} {{ group.name }}</h1>
        
        <p>
            {% trans "Slug:" %} <tt>{{ group.slug }}</tt><br />
            {% trans "Creator:" %} <a href="{% url profile_detail group.creator.username %}">{{ group.creator }}</a><br />
            {% trans "Created:" %} {{ group.created|date }}
            <br />
            {% show_tags_for group %}
        </p>
        
        <p>{{ group.description }}</p>
        
        {% ifequal user group.creator %}
            <div class="form-toggle">
                <p><span id="edit-group-toggle">{% trans "Edit details" %}</span></p>
                
                <form id="edit-group" method="POST" action="">
                    <table>
                        {{ group_form }}
                        <tr><td></td><td><input type="hidden" name="action" value="update" /><input type="submit" value="{% trans 'update' %}"/></td></tr>
                    </table>
                </form>
            </div>
            
            {% ifequal group.members.all.count 1 %}
                <p>{% silk "delete" %} <a href="#" onclick="$('#delete_group_form').toggle(); return false;">{% trans "Delete Group" %}</a><p>
                 <form class="delete_form" id="delete_group_form" action="{% url group_delete group.slug %}" method="POST" style="display: none;">
                     <input type="submit" value="{% trans "Delete Group" %}" /> (all content will be removed)
                </form>
            {% else %}
                <p>{% trans "You are not the only member of the group so you cannot delete the group." %}</p>
            {% endifequal %}
            
        {% endifequal %}
        
        {% if user.is_authenticated %}
            <div>
                <form method="POST" action="">
                    {% if is_member %}
                        {% ifequal user group.creator %}
                            <p>{% trans "You are the creator of this group so can't leave (yet)." %}</p>
                        {% else %}
                            <input type="hidden" name="action" value="leave" />
                            <input type="submit" value="{% trans "leave" %}"/>
                        {% endifequal %}
                    {% else %}
                        <input type="hidden" name="action" value="join" />
                        <input type="submit" value="{% trans "join group" %}"/>
                    {% endif %}
                </form>
            </div>
        {% else %}
            {% url acct_signup as signup_url %}
            {% url acct_login as login_url %}
            <p>{% blocktrans %}<a href="{{ signup_url }}">Sign up</a> and <a href="{{ login_url }}">log in </a> to join this group.{% endblocktrans %}</p>
        {% endif %}
    </div>

{% endblock %}

{% block extra_body %}
    <script type="text/javascript">
        $(document).ready(function() {
            $('#edit-group').hide();
            $('#edit-group-toggle').click(function() {
                $('#edit-group').slideToggle();
                $('#edit-group').autoscroll();
                return false;
            });
            if ($('#edit-group ul.errorlist').length) {
                $('#edit-group').show();
                $('#edit-group ul.errorlist').autoscroll();
            }
        });
    </script>
    
{% endblock %}