Design pending blogs in organizations (#123)

This commit is contained in:
Phuoc Anh Kha Le 2024-07-23 01:24:43 -05:00 committed by GitHub
parent 66f6212947
commit 44554d7de6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 423 additions and 306 deletions

View file

@ -0,0 +1,48 @@
<script type="text/javascript">
$(document).ready(function () {
function ajax_post(url, data, on_success) {
return $.ajax({
url: url,
type: 'POST',
data: data,
success: function (data, textStatus, jqXHR) {
if (typeof on_success !== 'undefined')
on_success();
},
error: function (data, textStatus, jqXHR) {
alert('Action failed: ' + data.responseText);
}
});
}
function removePost(postId) {
$('#post-' + postId).slideUp('normal', function () {
$(this).remove();
});
}
window.approvePost = function (url, postId, e) {
e.preventDefault();
const csrfToken = '{{ csrf_token }}';
ajax_post(url, {
id: postId,
action: 'Approve',
csrfmiddlewaretoken: csrfToken
}, function () {
removePost(postId);
});
}
window.rejectPost = function (url, postId, e) {
e.preventDefault();
const csrfToken = '{{ csrf_token }}';
ajax_post(url, {
id: postId,
action: 'Reject',
csrfmiddlewaretoken: csrfToken
}, function () {
removePost(postId);
});
}
});
</script>

View file

@ -1,28 +1,71 @@
{% extends "organization/home-base.html" %}
{% block org_js %}
{% include "organization/blog/pending-js.html" %}
{% endblock %}
{% block middle_content %}
<table class="table">
<thead>
<tr>
<th>
{{_('Blog')}}
</th>
<th>
{{_('Author')}}
</th>
<th>
{{_('Post time')}}
</th>
</tr>
</thead>
<tbody>
{% for blog in blogs %}
<tr>
<td><a href="{{url('edit_organization_blog', organization.id, organization.slug, blog.id)}}">{{blog.title}}</a></td>
<td>{{link_users(blog.authors.all())}}</td>
<td>{{- blog.publish_on|date(_("N j, Y, g:i a")) -}}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% for post in blogs %}
<section class="{% if post.sticky %}sticky {% endif %} blog-box" id="post-{{post.id}}">
{% if post.is_organization_private and show_organization_private_icon %}
<div style="margin-bottom: 1em; display: flex;">
{% for org in post.organizations.all() %}
{% include "organization/tag.html" %}
{% endfor %}
</div>
{% endif %}
<div style="margin-bottom: 0.5em">
<span class="post-content-header time">
{% with authors=post.get_authors() %}
{%- if authors -%}
<span class="user-img" style="width: 1.5em; height: 1.5em">
<img src="{{gravatar(authors[0])}}" loading="lazy">
</span>
<span class="post-authors">{{ link_users(authors) }}</span>
{%- endif -%}
{% endwith %}
&#8226;
{{ relative_time(post.publish_on) }}
{%- if post.sticky %} &#8226;
<i title="Sticky" class="fa fa-star fa-fw"></i>{% endif -%}
</span>
</div>
<h2 class="title">
<a href="{{ url('blog_post', post.id, post.slug) }}">{{ post.title }}</a>
</h2>
<div class="blog-description">
<div class="summary content-description">
{% cache 86400 'post_content' post.id %}
{{ post.content|markdown(lazy_load=True)|reference|str|safe }}
{% endcache %}
</div>
<div class="show-more"> {{_("...More")}} </div>
</div>
{% if request.profile.can_edit_organization(org) %}
<div class="actionbar-box">
<div class="actionbar {{'hide_texts_on_mobile' if hide_texts_on_mobile}}">
<span class="actionbar-block">
<a class="actionbar-button white background-green" href="#" onclick="javascript:approvePost('{{ url('edit_organization_blog', org.id , org.slug , post.id) }}', {{ post.id }}, event)">
<i class="fa fa-check" style="font-size: large;"></i>
<span class="actionbar-text">{{_("Approve")}}</span>
</a>
</span>
<span class="actionbar-block">
<a class="actionbar-button black" href="{{ url('edit_organization_blog', org.id , org.slug , post.id) }}">
<i class="fa fa-edit" style="font-size: large;"></i>
<span class="actionbar-text">{{_("Edit")}}</span>
</a>
</span>
<span class="actionbar-block">
<a class="actionbar-button white background-red" href="#" onclick="javascript:rejectPost('{{ url('edit_organization_blog', org.id , org.slug , post.id) }}', {{ post.id }}, event)">
<i class="fa fa-times" style="font-size: large;"></i>
<span class="actionbar-text">{{_("Reject")}}</span>
</a>
</span>
</div>
</div>
{% endif %}
</section>
{% endfor %}
{% include "feed/has_next.html" %}
{% endblock %}