basic functionality for browse page

This commit is contained in:
Sanj 2011-07-10 06:35:49 +05:30
parent 53f7781c16
commit 7c51f54242
6 changed files with 60 additions and 11 deletions

View File

@ -30,6 +30,7 @@ urlpatterns = patterns('',
(r'^article_frontend/(?P<product_id>\d+)/(?P<article_order>\d+)/$', views.article_frontend), (r'^article_frontend/(?P<product_id>\d+)/(?P<article_order>\d+)/$', views.article_frontend),
(r'^article_web/(?P<article_id>\d+)/', views.article_webalone), (r'^article_web/(?P<article_id>\d+)/', views.article_webalone),
(r'^articlesByTheme/', views.articlesByTheme), (r'^articlesByTheme/', views.articlesByTheme),
(r'^addArticleToTheme/', views.addArticleToTheme),
(r'^articleTitle/$', views.articleTitle), (r'^articleTitle/$', views.articleTitle),
(r'^lockArticle/$', views.lockArticle), (r'^lockArticle/$', views.lockArticle),
(r'^publishArticle/$', views.publishArticle), (r'^publishArticle/$', views.publishArticle),

View File

@ -613,6 +613,18 @@ def articlesByTheme(request):
return HttpResponse(json.dumps(articles), mimetype="application/javascript") 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): def article_frontend(request, product_id, article_order):
product = Product.objects.get(pk=product_id) product = Product.objects.get(pk=product_id)
article = Article.objects.filter(product=product, order=article_order)[0] article = Article.objects.filter(product=product, order=article_order)[0]
@ -642,6 +654,11 @@ def article_webalone(request, article_id):
pages = article.get_dict() pages = article.get_dict()
articles_before = [] articles_before = []
articles_after = [] articles_after = []
themes = ArticleTheme.objects.all()
if article.theme is not None:
theme_id = article.theme.id
else:
theme_id = 0
d = { d = {
'pages': pages, 'pages': pages,
'height': height, 'height': height,
@ -651,6 +668,8 @@ def article_webalone(request, article_id):
'published': article.published, 'published': article.published,
'is_owner': article.is_owner(user), 'is_owner': article.is_owner(user),
'article': article, 'article': article,
'themes': themes,
'theme_id': theme_id,
'articles_before': [], 'articles_before': [],
'articles_after': [] 'articles_after': []
} }

View File

@ -30,3 +30,11 @@ h5 {
overflow-y: scroll; overflow-y: scroll;
border: 0; border: 0;
} }
.articleItem {
cursor: pointer;
}
.selectedArticle {
background-color: #f4f3ba;
}

View File

@ -113,7 +113,18 @@ $(document).ready(function() {
}, function(response) { }, function(response) {
alert(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);
});
}); });
}); });

View File

@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Edgwareroad.org {{article.title}}</title> <title>Edgwareroad.org: {{article.title}}</title>
<link rel="stylesheet" type="text/css" href="/static/css/colorbox.css" /> <link rel="stylesheet" type="text/css" href="/static/css/colorbox.css" />
<link rel="stylesheet" type="text/css" href="/static/css/fonts.css" /> <link rel="stylesheet" type="text/css" href="/static/css/fonts.css" />
<link rel="stylesheet" type="text/css" href="/static/css/jquery.tooltip.css" /> <link rel="stylesheet" type="text/css" href="/static/css/jquery.tooltip.css" />
@ -261,7 +261,17 @@ p {
</p> </p>
<p> <p>
Select Article Theme:
<select id="articleTheme">
<option value="0" {% ifequal theme_id 0 %} selected="selected" {% endifequal %}>Please pick a theme...</option>
{% for t in themes %}
<option value="{{ t.id }}" {% ifequal theme_id t.id %} selected="selected" {% endifequal %}>{{ t.name }}</option>
{% endfor %}
</select>
<p>
<p>
</p> </p>
</div> </div>
</div> </div>

View File

@ -6,6 +6,7 @@
{% block extra_head %} {% block extra_head %}
<link rel="stylesheet" href="/static/css/files/browse.css" /> <link rel="stylesheet" href="/static/css/files/browse.css" />
<script type="text/javascript" src="/static/js/browse_publications.js"></script>
{% endblock %} {% endblock %}
{% block pageTitle %} {% block pageTitle %}
@ -21,15 +22,8 @@ Browse Publications
<!-- <img src="http://camputer.org/ftp/public/Issue00.jpg"></a> --> <!-- <img src="http://camputer.org/ftp/public/Issue00.jpg"></a> -->
<p> <p>
Issue 00:<em>Instructions for printing</em> July 2011 <a id="articleLink" href="first_article.web_url" title="View as Webpage!">{{ first_article.title }}</a>
</p><br/>
<p>
Issue -1:<em>Collecting Materials</em> January 2011
</p><br/>
<p>
And so on....
</p> </p>
<br/>
</div> </div>
@ -37,7 +31,7 @@ Browse Publications
<h5>Published or in-progress articles by type of Study:</h5> <h5>Published or in-progress articles by type of Study:</h5>
<p> <p>
<select name="articleThemes" id="articleThemes"> <select name="articleThemes" id="articleThemes">
<option value="0">All Themes</option> <option value="0">All</option>
{% for t in themes %} {% for t in themes %}
<option value="{{ t.id }}">{{ t.name }}</option> <option value="{{ t.id }}">{{ t.name }}</option>
{% endfor %} {% endfor %}
@ -50,7 +44,13 @@ Browse Publications
--> -->
</select> </select>
</p> </p>
<p>
<ul id="articleList">
</ul>
</p>
</div> </div>
</div> </div>
{% endblock %} {% endblock %}