ken cochrane avatar ken cochrane committed 80562e2

initial checkin

Comments (0)

Files changed (14)

+syntax: glob
+*.pyc
+dist
+MANIFEST
+_build
+_static
+.DS_Store
+Requirements
+------------
+Django 1.1 or newer (http://djangoproject.com)
+
+----------------
+Settings
+----------------
+
+Add feature_request to your INSTALLED_APPS variable in settings.
+
+Urls
+====
+add "(r'^feature-request/', include('feature_request.urls'))," to your base urls.py file
+
+Sync Tables
+===========
+Run ./manage.py syncdb to load up the tables in your database.
+Copyright (c) 2010, Ken Cochrane
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials provided
+      with the distribution.
+    * Neither the name of the author nor the names of other
+      contributors may be used to endorse or promote products derived
+      from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+Django feature-request is a very simple app that allows you to add feature request to your django project. 
+
+It will list the current feature requests, and their status. 
+
+Future features that are on the list to add, are voting, categories, and sorting the list. 
+
+This is very raw so feel free to extend how you see fit.
+
+Enjoy,
+Ken Cochrane
Add a comment to this file

feature_request/__init__.py

Empty file added.

feature_request/forms.py

+from django import forms
+
+from feature_request.models import FeatureRequest
+
+class FeatureRequestForm(forms.ModelForm):
+
+    class Meta:
+        model = FeatureRequest
+        exclude = ('member','create_date','last_update')
+        
+    def save(self, member):
+        fit_log= super(FeatureRequestForm, self).save(commit=False)
+        fit_log.member = member       
+        fit_log.save() 
+        return fit_log  

feature_request/models.py

+from django.db import models
+from django.contrib.auth.models import User
+
+class FeatureRequestManager(models.Manager):
+    def get_features(self):
+        return self.all().order_by("is_complete")
+    
+class FeatureRequest(models.Model):
+    member = models.ForeignKey(User)
+    create_date = models.DateTimeField(auto_now_add=True)
+    last_update = models.DateTimeField(auto_now=True)
+    request = models.TextField(max_length=5000,blank=True)
+    is_complete = models.BooleanField()
+    complete_date = models.DateField(blank=True)
+    complete_comments = models.TextField(max_length=100,blank=True)
+    objects = FeatureRequestManager()

feature_request/templates/feature_request/add.html

+{% extends "base.html" %}
+
+{% block body %}
+
+<h1>Request a Feature</h1>
+<form method="post" action=".">
+<table>
+    {{form}}
+<tr><td colspan='2'><input type="submit" value="Save" /></td></tr>
+</table>
+</form>
+
+{% endblock body %}

feature_request/templates/feature_request/tags/list_requests.html

+<h2>Requested Features</h2> <a href='{% url feature_request_add %}'>Add a Request</a>
+
+    <table border='1' width='90%'>
+        <thead><tr><th>Date Requested</th><th>Member</th><th>Requested Feature</th><th>Status</th></tr></thead>
+        <tbody>
+    {% for feature in feature_requests %}
+        <tr><td>{{feature.create_date|date:"M dS Y"}}</td><td>{{feature.member}}</td><td>{{feature.request|linebreaksbr}}</td>
+        <td>{% if feature.is_complete %}Complete 
+                {% if feature.complete_date %}({{feature.complete_date}}){% endif %}
+                {% if feature.complete_comments %}<br />{{feature.complete_comments|linebreaksbr}}{% endif %}
+            {% else %}Open{% endif %}</td></tr>
+    {% endfor %}
+        </tbody>
+    </table>

feature_request/templates/feature_request/view_all.html

+{% extends "base.html" %}
+{% load feature_request_tags %}
+{% block body %}
+
+{% list_feature_requests %}
+    
+{% endblock body %}

feature_request/templatetags/__init__.py

+

feature_request/templatetags/feature_request_tags.py

+from django.template import Library
+
+from feature_request.models import FeatureRequest
+
+register = Library()
+
+@register.inclusion_tag('feature_request/tags/list_requests.html')
+def list_feature_requests():
+    feature_requests = FeatureRequest.objects.get_features()   
+    return { 'feature_requests' : feature_requests, }

feature_request/urls.py

+from django.conf.urls.defaults import *
+
+from feature_request import views
+
+urlpatterns = patterns('',
+     url(r'^add/$', views.add, name="feature_request_add"),
+     url(r'^$', views.view_all, name="feature_request_home"),
+)

feature_request/views.py

+from django.contrib.auth.decorators import login_required
+from django.http import HttpResponseRedirect, HttpResponse, Http404
+from django.core.urlresolvers import reverse
+
+from feature_request.forms import FeatureRequestForm
+
+def render_response(request, template_name, template_params={}):
+    return render_to_response(template_name, 
+        context_instance=RequestContext(request, template_params))
+
+@login_required
+def add(request):
+    
+    user = request.user
+        
+    if request.method == 'POST':
+        form = FeatureRequestForm(request.POST)
+        if form.is_valid():
+            form.save(user)
+            return HttpResponseRedirect(reverse('feature_request_home'))
+    else :
+        form = FeatureRequestForm()             
+    return render_response(request, 'feature_request/add.html', {'form':form,})
+
+def view_all(request):
+    feature_requests = FeatureRequest.objects.get_features()
+    return render_response(request, 'feature_request/view_all.html', {'feature_requests':feature_requests})
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.