Skip to content
This repository was archived by the owner on Aug 26, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gsoc/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ def author(self, obj):
def article_link(self, obj):
url = reverse('{}:article-detail'.format(obj.article.app_config.namespace),
args=[obj.article.slug])
return mark_safe('<a href="{}">Goto Article</a>'.format(url))
return mark_safe('<a href="{}" target="_blank">Goto Article</a>'.format(url))

def has_add_permission(self, request, obj=None):
return False
Expand Down
19 changes: 10 additions & 9 deletions gsoc/management/commands/runcron.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,16 @@ def build_items(self, options):
if len(builders) is 0:
self.stdout.write(self.style.SUCCESS('No build tasks'), ending='\n')
else:
self.stdout.write('Running build task {}:{}'
.format(builder.category, builder.pk), ending='\n')
getattr(build_tasks, builder.category)(builder)
self.stdout.write(self.style
.SUCCESS('Finished build task {}:{}'
.format(builder.category, builder.pk)),
ending='\n')
builder.built = True
builder.save()
for builder in builders:
self.stdout.write('Running build task {}:{}'
.format(builder.category, builder.pk), ending='\n')
getattr(build_tasks, builder.category)(builder)
self.stdout.write(self.style
.SUCCESS('Finished build task {}:{}'
.format(builder.category, builder.pk)),
ending='\n')
builder.built = True
builder.save()

def handle_process(self, scheduler):
self.stdout.write('Running command {}:{}'
Expand Down
18 changes: 18 additions & 0 deletions gsoc/migrations/0023_auto_20190604_1310.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.1.8 on 2019-06-04 13:10

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('gsoc', '0022_articlereview'),
]

operations = [
migrations.AlterField(
model_name='comment',
name='content',
field=models.CharField(max_length=255),
),
]
33 changes: 32 additions & 1 deletion gsoc/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,12 +524,38 @@ class Comment(models.Model):
username = models.CharField(max_length=50)
user = models.ForeignKey(User, null=True, on_delete=models.CASCADE)
article = models.ForeignKey(Article, on_delete=models.CASCADE)
content = models.TextField()
content = models.CharField(max_length=255)
parent = models.ForeignKey('self', null=True,
on_delete=models.CASCADE,
related_name='replies')
created_at = models.DateTimeField(auto_now_add=True)

def send_notifications(self):
article_link = self.article.get_absolute_url()
comment_link = '{}#comment-{}'.format(article_link, self.pk)
template_data = {
'article': self.article.title,
'created_at': self.created_at.strftime('%I:%M %p, %d %B %Y'),
'username': self.username,
'link': comment_link,
}
scheduler_data = build_send_mail_json(self.article.owner.email,
template='comment_notification.html',
subject='{} commented on your article'.
format(self.username),
template_data=template_data)
Scheduler.objects.create(command='send_email',
data=scheduler_data)

if self.parent and self.parent.user:
scheduler_data = build_send_mail_json(self.parent.user.email,
template='comment_reply_notification.html',
subject='{} replied to your comment'.
format(self.username),
template_data=template_data)
Scheduler.objects.create(command='send_email',
data=scheduler_data)


def get_root_comments(self):
return self.comment_set.filter(parent=None).all()
Expand All @@ -538,6 +564,11 @@ def get_root_comments(self):
Article.add_to_class('get_root_comments', get_root_comments)


@receiver(models.signals.post_save, sender=Comment)
def send_comment_notification(sender, instance, **kwargs):
instance.send_notifications()


@receiver(models.signals.post_save, sender=Article)
def decrease_blog_counter(sender, instance, **kwargs):
section = instance.app_config
Expand Down
25 changes: 22 additions & 3 deletions gsoc/templates/admin/article_review_change_form.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
{% extends "admin/change_form.html" %}
{% load static %}

{% block extrastyle %}
{{ block.super }}
<link rel="stylesheet" type="text/css" href="{% static 'admin/css/forms.css' %}" />
<style>
.submit-row .closelink {
background-color: #00BBFF !important;
}

.submit-row .closelink:hover {
background-color: #447e9b !important;
color: white !important;
}
</style>
{% endblock %}


{% block submit_buttons_bottom %}
<div class="submit-row">
<a href="{% url 'review_article' article_id=original.article.id %}?admin=true" class="closelink">Mark Reviewed</a>
</div>
{% if not original.is_reviewed %}
<div class="submit-row">
<a href="{% url 'review_article' article_id=original.article.id %}?admin=true" class="closelink">Mark Reviewed</a>
</div>
{% endif %}
{% endblock %}
2 changes: 1 addition & 1 deletion gsoc/templates/aldryn_newsblog/includes/author.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<img src="{{ author_image.url }}" width="50" height="50" alt="{{ author.name }}">
{% endif %}
</a>
{{ owner.username }}
{{ owner.username }}, {{ article.publishing_date|date:'d M Y' }}
</p>
{% if author.function %}<p>{{ author.function }}</p>{% endif %}
{% if author.article_count %}<p>{{ author.article_count }}</p>{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion gsoc/templates/aldryn_newsblog/includes/comments.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{{ comment.username }}
</div>
<div class="c-content">
{{ comment.content }}
{{ comment.content|linebreaksbr }}
</div>
</div>
<div class="c-actions">
Expand Down
4 changes: 4 additions & 0 deletions gsoc/templates/email/comment_notification.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{{ article }}
{{ created_at }}
{{ username }}
{{ link }}
4 changes: 4 additions & 0 deletions gsoc/templates/email/comment_reply_notification.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{{ article }}
{{ created_at }}
{{ username }}
{{ link }}
Binary file modified project.db
Binary file not shown.