{% load snipt_tags team_tags %}

{% if user.profile.is_a_team %}
  <div class="profile group">
      <a href="/{{ user.username }}/">
          <img src="https://secure.gravatar.com/avatar/{{ user.email|md5 }}?s=300" alt="{{ user.username }}" title="{{ user.username }}" />
      </a>
      <div class="meta">
          <div class="username" title="{{ user.username }}">
              <a href="">
                  {{ user.username }}
              </a>
          </div>
          <div class="member-since">Team since {{ user.date_joined|date:"Y" }}</div>
          {% if user.profile.get_blog_posts %}
              <div class="urls">
                  Siftie Snippets Blog:
                  <a href="{{ user.profile.get_user_profile_url }}">
                      {{ user.profile.get_user_profile_url }}
                  </a>
              </div>
          {% endif %}
          <div class="member-since">
            {% if user.team|user_is_member:request.user %}
              <a href="/{{ user.username }}/members/">
                {{ user.team.member_count }} member{{ user.team.member_count|pluralize }}
              </a>
            {% else %}
              {{ user.team.member_count }} members
            {% endif %}
          </div>
      </div>
  </div>
  {% if user.team|user_is_member:request.user %}
    <div class="profile team-settings group">
      <div class="team-search">
        <form action="/search/" method="get">
          <input type="text" class="text" value="" name="q" placeholder="Search team snipts...">
          <input type="hidden" class="text" value="{{ user.username }}" name="author">
        </form>
      </div>
    </div>
  {% endif %}
  {% if user.team.owner == request.user %}
    <div class="profile team-settings group">
      <div class="meta">
        <span class="title">Team settings</span>
        <a href="/{{ user.username }}/members/">Members &raquo;</a>
      </div>
    </div>
  {% endif %}
{% else %}
  <div class="profile group">
      <a href="/{{ user.username }}/">
          <img src="https://secure.gravatar.com/avatar/{{ user.email|md5 }}?s=300" alt="{{ user.username }}" title="{{ user.username }}" />
      </a>
      <div class="meta">
          <div class="username" title="{{ user.username }}">
              <a href="">
                  {{ user.username }}
              </a>
          </div>
          {% if user.username == 'nick' %}
              <div class="member-since">Snippets Founder in {{ user.date_joined|date:"Y" }}</div>
          {% else %}
              <div class="member-since">Member since {{ user.date_joined|date:"Y" }}</div>
          {% endif %}
          {% if user.profile.get_blog_posts %}
              <div class="urls">
                  Snippets Blog:
                  <a href="{{ user.profile.get_user_profile_url }}">
                      {{ user.profile.get_user_profile_url }}
                  </a>
              </div>
          {% endif %}
      </div>
  </div>
{% endif %}
