From 7c51f5424242aa842c7e074bf1be93e777c25279 Mon Sep 17 00:00:00 2001 From: Sanj Date: Sun, 10 Jul 2011 06:35:49 +0530 Subject: [PATCH] basic functionality for browse page --- edgware/editor/urls.py | 1 + edgware/editor/views.py | 19 +++++++++++++++++++ edgware/static/css/files/browse.css | 8 ++++++++ edgware/static/js/articleMockup.js | 11 +++++++++++ edgware/templates/article_frontend.html | 14 ++++++++++++-- edgware/templates/main/browse.html | 18 +++++++++--------- 6 files changed, 60 insertions(+), 11 deletions(-) diff --git a/edgware/editor/urls.py b/edgware/editor/urls.py index 6376783..4bf58fb 100644 --- a/edgware/editor/urls.py +++ b/edgware/editor/urls.py @@ -30,6 +30,7 @@ urlpatterns = patterns('', (r'^article_frontend/(?P\d+)/(?P\d+)/$', views.article_frontend), (r'^article_web/(?P\d+)/', views.article_webalone), (r'^articlesByTheme/', views.articlesByTheme), + (r'^addArticleToTheme/', views.addArticleToTheme), (r'^articleTitle/$', views.articleTitle), (r'^lockArticle/$', views.lockArticle), (r'^publishArticle/$', views.publishArticle), diff --git a/edgware/editor/views.py b/edgware/editor/views.py index 5165a71..125ed74 100644 --- a/edgware/editor/views.py +++ b/edgware/editor/views.py @@ -613,6 +613,18 @@ def articlesByTheme(request): return HttpResponse(json.dumps(articles), mimetype="application/javascript") +def addArticleToTheme(request): + user = request.user + id = request.GET.get("id", "0") + theme_id = request.GET.get("theme_id", "0") + theme = ArticleTheme.objects.get(pk=theme_id) + article = Article.objects.get(pk=id) + if article.can_edit(user): + article.theme = theme + article.save() + return HttpResponse("changed article theme. thanks!") + + def article_frontend(request, product_id, article_order): product = Product.objects.get(pk=product_id) article = Article.objects.filter(product=product, order=article_order)[0] @@ -642,6 +654,11 @@ def article_webalone(request, article_id): pages = article.get_dict() articles_before = [] articles_after = [] + themes = ArticleTheme.objects.all() + if article.theme is not None: + theme_id = article.theme.id + else: + theme_id = 0 d = { 'pages': pages, 'height': height, @@ -651,6 +668,8 @@ def article_webalone(request, article_id): 'published': article.published, 'is_owner': article.is_owner(user), 'article': article, + 'themes': themes, + 'theme_id': theme_id, 'articles_before': [], 'articles_after': [] } diff --git a/edgware/static/css/files/browse.css b/edgware/static/css/files/browse.css index eed24c6..41bd5b8 100644 --- a/edgware/static/css/files/browse.css +++ b/edgware/static/css/files/browse.css @@ -30,3 +30,11 @@ h5 { overflow-y: scroll; border: 0; } + +.articleItem { + cursor: pointer; +} + +.selectedArticle { + background-color: #f4f3ba; +} diff --git a/edgware/static/js/articleMockup.js b/edgware/static/js/articleMockup.js index 7754c3e..0d3591b 100644 --- a/edgware/static/js/articleMockup.js +++ b/edgware/static/js/articleMockup.js @@ -113,7 +113,18 @@ $(document).ready(function() { }, function(response) { alert(response); }); + }); + $('#articleTheme').change(function() { + var theme_id = $(this).val(); + var article_id = $('#articleId').val(); + if (theme_id == 0) { return false; } + $.get("/edit/addArticleToTheme/", { + 'id': article_id, + 'theme_id': theme_id + }, function(response) { + alert(response); + }); }); }); diff --git a/edgware/templates/article_frontend.html b/edgware/templates/article_frontend.html index 249a62c..d52011a 100644 --- a/edgware/templates/article_frontend.html +++ b/edgware/templates/article_frontend.html @@ -3,7 +3,7 @@ -Edgwareroad.org {{article.title}} +Edgwareroad.org: {{article.title}} @@ -261,7 +261,17 @@ p {

- + Select Article Theme: + +

+

+

diff --git a/edgware/templates/main/browse.html b/edgware/templates/main/browse.html index 34eef86..d7d649b 100644 --- a/edgware/templates/main/browse.html +++ b/edgware/templates/main/browse.html @@ -6,6 +6,7 @@ {% block extra_head %} + {% endblock %} {% block pageTitle %} @@ -21,15 +22,8 @@ Browse Publications

- Issue 00:Instructions for printing July 2011 -


-

- Issue -1:Collecting Materials January 2011 -


-

- And so on.... + {{ first_article.title }}

-
@@ -37,7 +31,7 @@ Browse Publications
Published or in-progress articles by type of Study:

+

+

    + +
+

+ {% endblock %}