differentiate template articles; add ArticleTheme to admin

This commit is contained in:
Sanj 2011-07-09 22:37:56 +05:30
parent 6ed60fc123
commit a057999dcc
6 changed files with 40 additions and 19 deletions

View File

@ -24,4 +24,4 @@ admin.site.register(Video)
admin.site.register(Audio)
admin.site.register(Srt)
admin.site.register(SliderImage)
admin.site.register(ArticleTheme)

View File

@ -260,11 +260,16 @@ class Article(models.Model):
def get_published_list(kls, user, qset=False):
if not qset:
qset = kls.objects.all()
return qset.filter(published=True).exclude(Q(owner=user) | Q(users=user))
return qset.filter(published=True).exclude(Q(owner=user) | Q(users=user)).exclude(name__istartswith="template")
@classmethod
def get_template_list(kls):
qset = Article.objects.all()
return qset.filter(published=True).filter(name__istartswith="template")
@classmethod
def get_theme_list(kls, theme_id):
qset = Article.objects.filter(published=True)
qset = Article.objects.filter(published=True).exclude(name__istartswith="template")
try:
theme = ArticleTheme.objects.get(pk=theme_id)
qset = qset.filter(theme=theme)

View File

@ -25,16 +25,20 @@ def publish(request):
user = request.user
can_edit_list = Article.get_can_edit_list(user)
published_list = Article.get_published_list(user)
template_list = Article.get_template_list()
own_list = []
pub_list = []
tmpl_list = []
for c in can_edit_list:
own_list.append(c.get_list_dict(user))
for p in published_list:
pub_list.append(p.get_list_dict(user))
for t in template_list:
tmpl_list.append(t.get_list_dict(user))
context = RequestContext(request, {
'own_list': own_list,
'pub_list': pub_list
'pub_list': pub_list,
'tmpl_list': tmpl_list
})
return render_to_response("main/publish.html", context)

View File

@ -27,5 +27,6 @@ h5 {
#iframePreview {
overflow-x: hidden;
overflow-y: scroll;
border: 0;
}

View File

@ -1654,13 +1654,14 @@ $(".box").live("click", function(e){
$(".delete_box").bind("click", function(e){
e.preventDefault();
if (confirm("are you sure you wish to permanently delete this box?")) {
if (confirm("are you sure you wish to permanently delete this box from this page?")) {
$(".properties").remove();
boxObj.deleteme();
}
});
});
$(".canvas").live("mousemove", function(e){
var left = parseInt($(this).position().left) + parseInt($(this).css('margin-left'));

View File

@ -15,14 +15,16 @@ $(function() {
var articleTitle = prompt("Give your new article a name:");
// alert(articleId);
var url = "/edit/create_article/";
if (articleTitle) {
$.post(url, {
'article_id': articleId,
'article_name': articleTitle
}, function(url) {
window.location = url;
// $this.attr("href", url);
// $this.unbind("click");
// $this.attr("href", url);
// $this.unbind("click");
});
}
});
});
@ -51,9 +53,6 @@ If you are a participant looking to open a new account, please write to contact@
</div>
<div id="publishBlockright">
<p>
Tool link
</p> <br/>
<p>
Search for an existing article you were working on</p> <br/>
<ul id="ownList">
{% for o in own_list %}
@ -67,11 +66,22 @@ Search for an existing article you were working on</p> <br/>
</ul>
Or <br/>
Create a new one
<ul id="templateList">
{% for t in tmpl_list %}
<li data-id="{{ t.id }}">
<span class="articleTitle">{{ o.title }}</span>
{% if o.is_locked %} {% else %} <a href="{{ t.edit_url }}" title="Edit Article" target="_blank">edit</a> {% endif %}
<a href="{{ t.web_url }}" title="View as Webpage" target="_blank">web</a>
<a href="#" class="createCopy">copy</a>
</li>
{% endfor %}
</ul>
<ul id="publishedList">
{% for p in pub_list %}
<li>
<li data-id="{{ p.id }}">
<span class="articleTitle">{{ p.title }}</span>
<a href="{{ o.web_url }}" title="View as Webpage" target="_blank">web</a>
<a href="{{ p.web_url }}" title="View as Webpage" target="_blank">web</a>
<a href="#" class="createCopy">copy</a>
</li>
{% endfor %}