From 6e76a8dd3cb966d39e3d954f362d82dd88e39b44 Mon Sep 17 00:00:00 2001 From: sanj Date: Thu, 29 Jul 2010 01:03:47 +0530 Subject: [PATCH] product list and article list --- edgware/editor/urls.py | 3 ++- edgware/editor/views.py | 10 +++++++--- edgware/templates/article_list.html | 9 +++++++++ edgware/templates/base.html | 3 +++ edgware/templates/product_list.html | 8 ++++++++ 5 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 edgware/templates/article_list.html create mode 100644 edgware/templates/product_list.html diff --git a/edgware/editor/urls.py b/edgware/editor/urls.py index 77473c8..70c94b6 100644 --- a/edgware/editor/urls.py +++ b/edgware/editor/urls.py @@ -25,9 +25,10 @@ urlpatterns = patterns('', (r'^print_article/$', views.article_pdf), (r'^article_frontend/(?P\d+)/(?P\d+)/$', views.article_frontend), (r'^issue/(?P\d+)/$', views.edit_issue), - (r'^issue_list/', views.issue_list), + (r'^product/(?P\d+)/$', views.edit_product), (r'^new_issue/', views.new_issue), (r'^page_pdf/', views.page_pdf), (r'^product_pdf/', views.product_pdf), (r'^poll_changes/', views.poll_changes), + (r'', views.product_list), ) diff --git a/edgware/editor/views.py b/edgware/editor/views.py index 6ac8108..35d63b7 100644 --- a/edgware/editor/views.py +++ b/edgware/editor/views.py @@ -644,9 +644,9 @@ def delete_page(request): } return HttpResponse(json.dumps(r), mimetype="application/json") -def issue_list(request): - issues = Issue.objects.all().order_by('issue_no') - return render_to_response("issue_list.html", {'issues': issues}) +def product_list(request): + products = Product.objects.all() + return render_to_response("product_list.html", {'products': products}) def new_issue(request): name = request.GET['issueName'] @@ -660,6 +660,10 @@ def edit_issue(request, id): i = Issue.objects.get(pk=id) return render_to_response +def edit_product(request, id): + p = Product.objects.get(pk=id) + articles = Article.objects.filter(product=p) + return render_to_response("article_list.html", {'product': p, 'articles': articles}) """ These are some views that I could think of that need to be created. Please add more. diff --git a/edgware/templates/article_list.html b/edgware/templates/article_list.html new file mode 100644 index 0000000..42179f0 --- /dev/null +++ b/edgware/templates/article_list.html @@ -0,0 +1,9 @@ +{% extends 'base.html' %} + +{% block content %} + {{ p.title }} + {% for a in articles %} + {{ a.name }}
+ {% endfor %} + +{% endblock %} diff --git a/edgware/templates/base.html b/edgware/templates/base.html index aff812c..f8f2181 100644 --- a/edgware/templates/base.html +++ b/edgware/templates/base.html @@ -1,5 +1,8 @@ + {% block head %} + + {% endblock %} {% block content %} diff --git a/edgware/templates/product_list.html b/edgware/templates/product_list.html new file mode 100644 index 0000000..13b633b --- /dev/null +++ b/edgware/templates/product_list.html @@ -0,0 +1,8 @@ +{% extends 'base.html' %} + +{% block content %} + {% for p in products %} + {{ p.title }}
+ {% endfor %} + +{% endblock %}