Author: floguy
Date: Sun Sep 21 01:04:13 2008
New Revision: 915

Added:
    trunk/local_apps/projects/thing.py
    trunk/pinax/templates/projects/create.html
    trunk/pinax/templates/things/
    trunk/pinax/templates/things/ordering.html
    trunk/pinax/templates/things/search.html
    trunk/pinax/templates/tribes/create.html
Modified:
    trunk/local_apps/projects/templatetags/project_tags.py
    trunk/local_apps/projects/urls.py
    trunk/local_apps/projects/views.py
    trunk/local_apps/tribes/thing.py
    trunk/local_apps/tribes/urls.py
    trunk/local_apps/tribes/views.py
    trunk/pinax/templates/projects/base.html
    trunk/pinax/templates/projects/projects.html
    trunk/pinax/templates/site_base.html
    trunk/pinax/templates/tribes/tribes.html

Log:
Added searching and sorting to tribes and projects, by way of integrating  
django-things.  This should fix #35.

Modified: trunk/local_apps/projects/templatetags/project_tags.py
==============================================================================
--- trunk/local_apps/projects/templatetags/project_tags.py      (original)
+++ trunk/local_apps/projects/templatetags/project_tags.py      Sun Sep 21  
01:04:13 2008
@@ -1,15 +1,33 @@
-from django.template import Library
+from django import template
+from projects.forms import ProjectForm

-register = Library()
+register = template.Library()

[EMAIL PROTECTED]("projects/topic_item.html")
  def show_project_topic(topic):
      return {"topic": topic}
+register.inclusion_tag("projects/topic_item.html")(show_project_topic)

[EMAIL PROTECTED]("projects/project_item.html")
  def show_project(project):
      return {"project": project}
+register.inclusion_tag("projects/project_item.html")(show_project)

[EMAIL PROTECTED]("projects/task_item.html")
  def show_task(task):
-    return {"task": task}
\ No newline at end of file
+    return {"task": task}
+register.inclusion_tag("projects/task_item.html")(show_task)
+
+def do_get_project_form(parser, token):
+    try:
+        tag_name, as_, context_name = token.split_contents()
+    except ValueError:
+        tagname = token.contents.split()[0]
+        raise template.TemplateSyntaxError, "%(tagname)r tag syntax is as  
follows: {%% %(tagname)r as VARIABLE %%}" % locals()
+    return ProjectFormNode(context_name)
+
+class ProjectFormNode(template.Node):
+    def __init__(self, context_name):
+        self.context_name = context_name
+    def render(self, context):
+        context[self.context_name] = ProjectForm()
+        return ''
+
+register.tag('get_project_form', do_get_project_form)
\ No newline at end of file

Added: trunk/local_apps/projects/thing.py
==============================================================================
--- (empty file)
+++ trunk/local_apps/projects/thing.py  Sun Sep 21 01:04:13 2008
@@ -0,0 +1,13 @@
+import things
+
+class ProjectThing(things.ModelThing):
+    created = things.OrderField(verbose_name_asc='Oldest',
+        verbose_name_desc='Newest', url_asc='oldest', url_desc='newest',
+        field_url='date')
+    name = things.OrderField()
+    member_users = things.OrderField(verbose_name_asc='Largest',
+        verbose_name_desc='Smallest', url_asc='largest',  
url_desc='smallest',
+        field_url='size')
+    search = ('name', 'description')
+    template_dir = 'projects'
+    list_template_name = 'projects.html'
\ No newline at end of file

Modified: trunk/local_apps/projects/urls.py
==============================================================================
--- trunk/local_apps/projects/urls.py   (original)
+++ trunk/local_apps/projects/urls.py   Sun Sep 21 01:04:13 2008
@@ -3,6 +3,8 @@
  from projects.models import Project
  from wiki import models as wiki_models

+from projects.thing import ProjectThing
+pt = ProjectThing(Project)

  wiki_args = {
      'group_slug_field': 'slug',
@@ -10,23 +12,23 @@
  }


-urlpatterns = patterns('',
-    url(r'^$', 'projects.views.projects', name="projects_list"),
+urlpatterns = pt.urls(url_prefix='', name_prefix='project_thing') +  
patterns('',
+    url(r'^create/$', 'projects.views.create', name="project_create"),
      # @@@ what to do about clash with project with slug 'your_projects'?
      url(r'^your_projects/$', 'projects.views.your_projects',  
name="your_projects"),
-    url(r'^(\w+)/$', 'projects.views.project', name="project_detail"),
+    url(r'^project/(\w+)/$', 'projects.views.project',  
name="project_detail"),

-    url(r'^(\w+)/members_status/$', 'projects.views.members_status',  
name="project_members_status"),
+     
url(r'^project/(\w+)/members_status/$', 'projects.views.members_status',  
name="project_members_status"),

      # topics
-    url(r'^(\w+)/topics/$', 'projects.views.topics',  
name="project_topics"),
+    url(r'^project/(\w+)/topics/$', 'projects.views.topics',  
name="project_topics"),
      url(r'^topic/(\d+)/$', 'projects.views.topic', name="project_topic"),

      # tasks
-    url(r'^(\w+)/tasks/$', 'projects.views.tasks', name="project_tasks"),
+    url(r'^project/(\w+)/tasks/$', 'projects.views.tasks',  
name="project_tasks"),
      url(r'^task/(\d+)/$', 'projects.views.task', name="project_task"),
      url(r'^tasks/(\w+)/$', 'projects.views.user_tasks',  
name="project_user_tasks"),

      # wiki
-    url(r'^(?P<group_slug>\w+)/wiki/', include('wiki.urls'),  
kwargs=wiki_args),
+    url(r'^project/(?P<group_slug>\w+)/wiki/', include('wiki.urls'),  
kwargs=wiki_args),
  )

Modified: trunk/local_apps/projects/views.py
==============================================================================
--- trunk/local_apps/projects/views.py  (original)
+++ trunk/local_apps/projects/views.py  Sun Sep 21 01:04:13 2008
@@ -1,5 +1,6 @@
  from django.shortcuts import render_to_response, get_object_or_404
  from django.template import RequestContext
+from django.http import HttpResponseRedirect

  from django.contrib.auth.decorators import login_required
  from django.contrib.auth.models import User
@@ -34,7 +35,7 @@
  # from zwitschern.models import TweetInstance


-def projects(request):
+def create(request):
      if request.user.is_authenticated() and request.method == "POST":
          if request.POST["action"] == "create":
              project_form = ProjectForm(request.POST)
@@ -46,14 +47,14 @@
                  project.members.add(project_member)
                  project_member.save()
                  project_form = ProjectForm()
+                return HttpResponseRedirect(project.get_absolute_url())
          else:
              project_form = ProjectForm()
      else:
          project_form = ProjectForm()

-    return render_to_response("projects/projects.html", {
+    return render_to_response("projects/create.html", {
          "project_form": project_form,
-        "projects": Project.objects.all().order_by("-created"),
      }, context_instance=RequestContext(request))

  @login_required

Modified: trunk/local_apps/tribes/thing.py
==============================================================================
--- trunk/local_apps/tribes/thing.py    (original)
+++ trunk/local_apps/tribes/thing.py    Sun Sep 21 01:04:13 2008
@@ -1,9 +1,8 @@
  import things
-from tribes.models import Tribe

  class TribeThing(things.ModelThing):
-    created = things.OrderField(verbose_name_asc='Newest',
-        verbose_name_desc='Oldest', url_asc='newest', url_desc='oldest',
+    created = things.OrderField(verbose_name_asc='Oldest',
+        verbose_name_desc='Newest', url_asc='oldest', url_desc='newest',
          field_url='date')
      name = things.OrderField()
      members = things.OrderField(verbose_name_asc='Largest',

Modified: trunk/local_apps/tribes/urls.py
==============================================================================
--- trunk/local_apps/tribes/urls.py     (original)
+++ trunk/local_apps/tribes/urls.py     Sun Sep 21 01:04:13 2008
@@ -11,7 +11,7 @@


  urlpatterns = tt.urls(url_prefix='', name_prefix='tribe_thing') +  
patterns('',
-    url(r'^$', 'tribes.views.tribes', name="tribes_list"),
+    url(r'^create/$', 'tribes.views.create', name="tribe_create"),
      url(r'^your_tribes/$', 'tribes.views.your_tribes', name="your_tribes"),
      url(r'^tribe/(\w+)/$', 'tribes.views.tribe', name="tribe_detail"),


Modified: trunk/local_apps/tribes/views.py
==============================================================================
--- trunk/local_apps/tribes/views.py    (original)
+++ trunk/local_apps/tribes/views.py    Sun Sep 21 01:04:13 2008
@@ -36,7 +36,7 @@
  from zwitschern.models import TweetInstance


-def tribes(request):
+def create(request):
      if request.user.is_authenticated() and request.method == "POST":
          if request.POST["action"] == "create":
              tribe_form = TribeForm(request.POST)
@@ -59,12 +59,8 @@
      else:
          tribe_form = TribeForm()

-    order_by = request.GET.get("order_by")
-
-    return render_to_response("tribes/tribes.html", {
+    return render_to_response("tribes/create.html", {
          "tribe_form": tribe_form,
-        "tribes": Tribe.objects.all(),
-        "order_by": order_by,
      }, context_instance=RequestContext(request))

  def your_tribes(request):

Modified: trunk/pinax/templates/projects/base.html
==============================================================================
--- trunk/pinax/templates/projects/base.html    (original)
+++ trunk/pinax/templates/projects/base.html    Sun Sep 21 01:04:13 2008
@@ -9,7 +9,7 @@
          <ul>
              <li><a href="{% url projects.views.user_tasks  
user.username %}">{% trans "Your Tasks" %}</a></li>
              <li><a href="{% url your_projects %} ">{% trans "Your  
Projects" %}</a></li>
-            <li><a href="{% url projects.views.projects %}">{% trans "All  
Projects" %}</a></li>
+            <li><a href="{% url project_thing_list "" %}">{% trans "All  
Projects" %}</a></li>
          </ul>
      {% else %}
          &nbsp;

Added: trunk/pinax/templates/projects/create.html
==============================================================================
--- (empty file)
+++ trunk/pinax/templates/projects/create.html  Sun Sep 21 01:04:13 2008
@@ -0,0 +1,31 @@
+{% extends "projects/base.html" %}
+
+{% load i18n %}
+{% load humanize %}
+{% load pagination_tags %}
+{% load project_tags %}
+
+{% block head_title %}{% blocktrans %}Create Project{% endblocktrans %}{%  
endblock %}
+
+{% block body %}
+    <p><span class="warning">Note</span>: this is an <b>experimental</b>  
feature that is subject to massive change at any time.</p>
+
+
+    <h1>{% trans "Create Project" %}</h1>
+
+    <p>A <b>project</b> is a place to manage a group of people working on  
a common set of tasks. It is similar to a tribe in providing a wiki and  
threaded discussion but is invitation only and adds issue tracking.</p>
+
+    {% if user.is_authenticated %}
+        <form id="project_form" method="POST" action="{% url  
project_create %}">
+            <table>
+                {{ project_form }}
+                <tr><td></td><td><input type="hidden" name="action"  
value="create" /><input type="submit" value="{%  
trans 'create' %}"/></td></tr>
+            </table>
+        </form>
+    {% 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 create your own project or join an  
existing one.{% endblocktrans %}</p>
+    {% endif %}
+
+{% endblock %}
\ No newline at end of file

Modified: trunk/pinax/templates/projects/projects.html
==============================================================================
--- trunk/pinax/templates/projects/projects.html        (original)
+++ trunk/pinax/templates/projects/projects.html        Sun Sep 21 01:04:13 2008
@@ -4,6 +4,7 @@
  {% load humanize %}
  {% load pagination_tags %}
  {% load project_tags %}
+{% load things_tags %}

  {% block head_title %}{% blocktrans %}Projects{% endblocktrans %}{%  
endblock %}

@@ -18,7 +19,8 @@
      {% if user.is_authenticated %}
          <p><a href="#" onclick="$('#project_form').toggle(); return  
false;">{% trans "Start your own project" %}</a></p>

-        <form id="project_form" method="POST" action="" style="display:  
none;">
+        <form id="project_form" method="POST" action="{% url  
project_create %}" style="display: none;">
+            {% get_project_form as project_form %}
              <table>
                  {{ project_form }}
                  <tr><td></td><td><input type="hidden" name="action"  
value="create" /><input type="submit" value="{%  
trans 'create' %}"/></td></tr>
@@ -30,20 +32,26 @@
          <p>{% blocktrans %}<a href="{{ signup_url }}">Sign up</a> and <a  
href="{{ login_url }}">log in </a> to create your own project or join an  
existing one.{% endblocktrans %}</p>
      {% endif %}

-    {% autopaginate projects %}
+    {% if objects %}
+        {% display_search %}
+        {% display_ordering %}
+        {% autopaginate objects %}
+
+        {% regroup objects by created.date as projects_by_created %}
+
+        {% for date in projects_by_created %}
+            <h2 class="creation_date">{{ date.grouper| 
naturalday:_("MONTH_DAY_FORMAT")|capfirst }}</h2>
+            <dl>
+                {% for project in date.list %}
+                    {% show_project project %}
+                {% endfor %}
+            </dl>
+        {% endfor %}

-    {% regroup projects by created.date as projects_by_created %}
-
-    {% for date in projects_by_created %}
-        <h2 class="creation_date">{{ date.grouper| 
naturalday:_("MONTH_DAY_FORMAT")|capfirst }}</h2>
-        <dl>
-            {% for project in date.list %}
-                {% show_project project %}
-            {% endfor %}
-        </dl>
-    {% endfor %}
-
-    {% paginate %}
+        {% paginate %}
+    {% else %}
+        <p>No projects have been created yet.</p>
+    {% endif %}

  {% endblock %}


Modified: trunk/pinax/templates/site_base.html
==============================================================================
--- trunk/pinax/templates/site_base.html        (original)
+++ trunk/pinax/templates/site_base.html        Sun Sep 21 01:04:13 2008
@@ -44,8 +44,8 @@
                  <td class="tab rtab_photos"><div><a href="{% url  
photos.views.photos %}">{% trans "Photos" %}</a></div></td>
                  <td class="tab rtab_games"><div><a href="{% url  
games_index %}">{% trans "Games" %}</a></div></td>
                  <td class="tab rtab_blogs"><div><a href="{% url  
blog.views.blogs %}">{% trans "Blogs" %}</a></div></td>
-                <td class="tab rtab_projects"><div><a href="{% url  
projects.views.projects %}">{% trans "Projects" %}</a></div></td>
-                <td class="tab rtab_tribes"><div><a href="{% url  
tribes.views.tribes %}">{% trans "Tribes" %}</a></div></td>
+                <td class="tab rtab_projects"><div><a href="{% url  
project_thing_list "" %}">{% trans "Projects" %}</a></div></td>
+                <td class="tab rtab_tribes"><div><a href="{% url  
tribe_thing_list "" %}">{% trans "Tribes" %}</a></div></td>
                  <td class="tab rtab_tweets"><div><a href="{% url  
zwitschern.views.personal %}">{% trans "Tweets" %}</a></div></td>
                  <td class="tab rtab_bookmarks"><div><a href="{% url  
bookmarks.views.bookmarks %}">{% trans "Bookmarks" %}</a></div></td>
                  <td class="tab rtab_swaps"><div><a href="{% url  
swaps.views.offers %}">{% trans "Swaps" %}</a></div></td>

Added: trunk/pinax/templates/things/ordering.html
==============================================================================
--- (empty file)
+++ trunk/pinax/templates/things/ordering.html  Sun Sep 21 01:04:13 2008
@@ -0,0 +1,17 @@
+<p>Order by:
+    {% for f in fields %}
+        {% ifequal f field %}
+            {% if descending %}
+                <a href="{{ f.full_url_asc }}">{{ f.verbose_name_asc  
}}</a> or
+                <b>{{ f.verbose_name_desc }}</b>
+            {% else %}
+                <b>{{ f.verbose_name_asc }}</b> or
+                <a href="{{ f.full_url_desc }}">{{ f.verbose_name_desc  
}}</a>
+            {% endif %}
+        {% else %}
+            <a href="{{ f.full_url_asc }}">{{ f.verbose_name_asc }}</a> or
+            <a href="{{ f.full_url_desc }}">{{ f.verbose_name_desc }}</a>
+        {% endifequal %}
+        {% if not forloop.last %}, {% endif %}
+    {% endfor %}
+</p>
\ No newline at end of file

Added: trunk/pinax/templates/things/search.html
==============================================================================
--- (empty file)
+++ trunk/pinax/templates/things/search.html    Sun Sep 21 01:04:13 2008
@@ -0,0 +1,6 @@
+{% if search_enabled %}
+    <form method="GET" action="">
+        <input type="text" name="search" value="{{ terms }}" />
+        <input type="submit" value="Search" />
+    </form>
+{% endif %}
\ No newline at end of file

Added: trunk/pinax/templates/tribes/create.html
==============================================================================
--- (empty file)
+++ trunk/pinax/templates/tribes/create.html    Sun Sep 21 01:04:13 2008
@@ -0,0 +1,29 @@
+{% extends "tribes/base.html" %}
+
+{% load i18n %}
+{% load humanize %}
+{% load pagination_tags %}
+{% load order_by %}
+{% load extra_tagging_tags %}
+{% load tribe_tags %}
+
+{% block head_title %}{% blocktrans %}Create Tribe{% endblocktrans %}{%  
endblock %}
+
+{% block body %}
+    <h1>{% trans "Create Tribe" %}</h1>
+
+    <p>{% trans "A <b>tribe</b> is a group of people with some common  
interest." %}</p>
+    {% if user.is_authenticated %}
+        <form id="tribe_form" method="POST" action="{% url  
tribe_create %}">
+            <table>
+                {{ tribe_form }}
+                <tr><td></td><td><input type="hidden" name="action"  
value="create" /><input type="submit" value="{%  
trans 'create' %}"/></td></tr>
+            </table>
+        </form>
+    {% 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 create your own tribe or join an  
existing one.{% endblocktrans %}</p>
+    {% endif %}
+
+{% endblock %}
\ No newline at end of file

Modified: trunk/pinax/templates/tribes/tribes.html
==============================================================================
--- trunk/pinax/templates/tribes/tribes.html    (original)
+++ trunk/pinax/templates/tribes/tribes.html    Sun Sep 21 01:04:13 2008
@@ -6,6 +6,7 @@
  {% load order_by %}
  {% load extra_tagging_tags %}
  {% load tribe_tags %}
+{% load things_tags %}

  {% block head_title %}{% blocktrans %}Tribes{% endblocktrans %}{%  
endblock %}

@@ -16,7 +17,7 @@
      {% if user.is_authenticated %}
          <p><a href="#" onclick="$('#tribe_form').toggle(); return  
false;">{% trans "Start your own tribe" %}</a></p>

-        <form id="tribe_form" method="POST" action="{% url tribes_list %}"  
style="display: none;">
+        <form id="tribe_form" method="POST" action="{% url  
tribe_create %}" style="display: none;">
              {% get_tribe_form as tribe_form %}
              <table>
                  {{ tribe_form }}
@@ -28,29 +29,8 @@
          {% url acct_login as login_url %}
          <p>{% blocktrans %}<a href="{{ signup_url }}">Sign up</a> and <a  
href="{{ login_url }}">log in </a> to create your own tribe or join an  
existing one.{% endblocktrans %}</p>
      {% endif %}
-    {% if search_enabled %}
-        <form method="GET" action="">
-            <input type="text" name="search" value="{{ terms }}" />
-            <input type="submit" value="Search" />
-        </form>
-    {% endif %}
-    <p>Order by:
-        {% for f in fields %}
-            {% ifequal f field %}
-                {% if descending %}
-                    <a href="{{ f.full_url_asc }}">{{ f.verbose_name_asc  
}}</a> or
-                    <b>{{ f.verbose_name_desc }}</b>
-                {% else %}
-                    <b>{{ f.verbose_name_asc }}</b> or
-                    <a href="{{ f.full_url_desc }}">{{ f.verbose_name_desc  
}}</a>
-                {% endif %}
-            {% else %}
-                <a href="{{ f.full_url_asc }}">{{ f.verbose_name_asc  
}}</a> or
-                <a href="{{ f.full_url_desc }}">{{ f.verbose_name_desc  
}}</a>
-            {% endifequal %}
-            {% if not forloop.last %}, {% endif %}
-        {% endfor %}
-    </p>
+    {% display_search %}
+    {% display_ordering %}

      {% autopaginate objects 10 %}
      {% if objects %}

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pinax-updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pinax-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to