Skip to content

Commit

Permalink
Merge pull request #62 from MicroPyramid/featured_image
Browse files Browse the repository at this point in the history
Featured image issue #24
  • Loading branch information
chaitu210 committed May 31, 2016
2 parents 08d26fe + 71bb4bb commit becf901
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-05-31 11:55
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('django_blog_it', '0007_menu'),
]

operations = [
migrations.AddField(
model_name='post',
name='featured_image',
field=models.ImageField(blank=True, null=True, upload_to=b'static/blog/uploads/%Y/%m/%d/'),
),
]
1 change: 1 addition & 0 deletions django_blog_it/django_blog_it/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class Post(models.Model):
tags = models.ManyToManyField(Tags, related_name='rel_posts')
status = models.CharField(max_length=10, choices=STATUS_CHOICE, default='Drafted')
keywords = models.TextField(max_length=500, blank=True)
featured_image = models.ImageField(upload_to='static/blog/uploads/%Y/%m/%d/', blank=True, null=True)

def save(self, *args, **kwargs):
tempslug = slugify(self.title)
Expand Down
1 change: 0 additions & 1 deletion django_blog_it/django_blog_it/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
</div>

<footer class="my_footer">
<p align="center">Copyrights by &copy; MicroPyramid Pvt. Ltd.</p>
</footer>

</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
{% block content %}
{% endblock %}
<footer class="my_footer">
<p align="center">Copyrights by &copy; MicroPyramid Pvt. Ltd.</p>
</footer>
</div>
<!-- end div container -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ <h3 id="page_title"></h3>
<!-- end of add form div -->
{% endblock %}
{% block js_script %}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.form/3.51/jquery.form.js"></script>

<script type="text/javascript">
$(document).ready(function(){

Expand All @@ -44,21 +46,27 @@ <h3 id="page_title"></h3>
filebrowserBrowseUrl: '{% url "recent_photos" %}'
});

$('#post-form').submit(function(event){
event.preventDefault();

$('#id_content').val(CKEDITOR.instances.id_content.getData());
$.post("",$('#post-form').serialize(), function(data){
if(data.error)
$('form#post-form').ajaxForm({
beforeSerialize: function()
{
$('p.error_required').remove();
for (var key in data.response){
$('#id_'+key).after("<p class='error_required'> * "+data.response[key]+"</p>");
}
} else{
window.location='/dashboard/blog/';
}
}, "json");
$('#id_content').val(CKEDITOR.instances.id_content.getData());
},

dataType: 'json',
success: function(data){
if(data.error)
{
$('p.error_required').remove();
for (var key in data.response){
$('#id_'+key).after('<p class="error_required">'+data.response[key]+'</p>');
}
}
else
{
window.location='/dashboard/blog/';
}
}
});
// script for form submission ends here

Expand Down
4 changes: 2 additions & 2 deletions django_blog_it/django_blog_it/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def blog_add(request):
if request.POST.get('title') == '':
request.POST['title'] = 'Untitled document ' + str(Post.objects.all().count())
form = BlogPostForm(
request.POST,
request.POST, request.FILES,
is_superuser=request.user.is_superuser,
user_role=get_user_role(request.user)
)
Expand Down Expand Up @@ -140,7 +140,7 @@ def edit_blog(request, blog_slug):
if request.method == "POST":
previous_status = blog_name.status
form = BlogPostForm(
request.POST,
request.POST, request.FILES,
instance=blog_name,
is_superuser=request.user.is_superuser,
user_role=get_user_role(request.user)
Expand Down
1 change: 0 additions & 1 deletion django_blog_it/posts/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
{% endblock %}
</div>
<footer class="my_footer">
<p align="center">Copyrights by &copy; MicroPyramid Pvt. Ltd.</p>
</footer>
</div>
<!-- end div container -->
Expand Down

0 comments on commit becf901

Please sign in to comment.