From cfbe017711ddf91fdfa31899ca0f2321a59b1fb8 Mon Sep 17 00:00:00 2001 From: Sanj Date: Wed, 11 May 2011 01:47:48 +0530 Subject: [PATCH] articles list on /edit/ --- edgware/editor/urls.py | 2 +- edgware/editor/views.py | 4 ++++ edgware/files/file_utils.py | 21 +++++++++++++++++---- edgware/templates/article_list.html | 3 +-- edgware/templates/product_list.html | 2 +- 5 files changed, 24 insertions(+), 8 deletions(-) diff --git a/edgware/editor/urls.py b/edgware/editor/urls.py index a70d42f..0bd8176 100644 --- a/edgware/editor/urls.py +++ b/edgware/editor/urls.py @@ -31,5 +31,5 @@ urlpatterns = patterns('', (r'^page_pdf/', views.page_pdf), (r'^product_pdf/', views.product_pdf), (r'^poll_changes/', views.poll_changes), - (r'', views.product_list), + (r'', views.article_list), ) diff --git a/edgware/editor/views.py b/edgware/editor/views.py index 4d9c377..043891e 100644 --- a/edgware/editor/views.py +++ b/edgware/editor/views.py @@ -665,6 +665,10 @@ def product_list(request): products = Product.objects.all() return render_to_response("product_list.html", {'products': products}) +def article_list(request): + articles = Article.objects.all() + return render_to_response("article_list.html", {'articles': articles}) + def new_issue(request): name = request.GET['issueName'] last_issue_no = Issue.objects.all().order_by('-issue_no')[0].issue_no diff --git a/edgware/files/file_utils.py b/edgware/files/file_utils.py index ecae4d6..6ab2bfa 100644 --- a/edgware/files/file_utils.py +++ b/edgware/files/file_utils.py @@ -1,5 +1,9 @@ from models import File import os +try: + import json +except: + import simplejson as json def clean_nulls(): x = [] @@ -33,10 +37,19 @@ def file_exists(): def manage_types(): - videos = 0 - audios = 0 - images = 0 + wooga = {} + types = ['image', 'audio', 'text', 'video', 'other'] + for t in types: + wooga[t] = 0 for f in File.objects.all(): typ = f.type - + try: + wooga[typ] += 1 + except KeyError: + print typ + print json.dumps(wooga, indent=4) + +def correct_types(): + types = ['image', 'audio', 'text', 'video', 'other'] + diff --git a/edgware/templates/article_list.html b/edgware/templates/article_list.html index 42179f0..eb032dc 100644 --- a/edgware/templates/article_list.html +++ b/edgware/templates/article_list.html @@ -1,7 +1,6 @@ {% extends 'base.html' %} -{% block content %} - {{ p.title }} +{% block body %} {% for a in articles %} {{ a.name }}
{% endfor %} diff --git a/edgware/templates/product_list.html b/edgware/templates/product_list.html index 13b633b..32ac319 100644 --- a/edgware/templates/product_list.html +++ b/edgware/templates/product_list.html @@ -1,6 +1,6 @@ {% extends 'base.html' %} -{% block content %} +{% block body %} {% for p in products %} {{ p.title }}
{% endfor %}