fix blog permissions
This commit is contained in:
parent
9f43e712d0
commit
eaa7be6ec6
3 changed files with 10 additions and 6 deletions
|
@ -99,11 +99,10 @@ class PostList(FeedView):
|
||||||
.order_by("-sticky", "-publish_on")
|
.order_by("-sticky", "-publish_on")
|
||||||
.prefetch_related("authors__user", "organizations")
|
.prefetch_related("authors__user", "organizations")
|
||||||
)
|
)
|
||||||
if not self.request.user.has_perm("judge.edit_all_post"):
|
filter = Q(is_organization_private=False)
|
||||||
filter = Q(is_organization_private=False)
|
if self.request.user.is_authenticated:
|
||||||
if self.request.user.is_authenticated:
|
filter |= Q(organizations__in=self.request.profile.organizations.all())
|
||||||
filter |= Q(organizations__in=self.request.profile.organizations.all())
|
queryset = queryset.filter(filter)
|
||||||
queryset = queryset.filter(filter)
|
|
||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
|
|
|
@ -714,6 +714,11 @@ class AddOrganizationBlog(
|
||||||
model = BlogPost
|
model = BlogPost
|
||||||
form_class = OrganizationBlogForm
|
form_class = OrganizationBlogForm
|
||||||
|
|
||||||
|
def get_form_class(self):
|
||||||
|
if self.can_edit_organization(self.organization):
|
||||||
|
return OrganizationAdminBlogForm
|
||||||
|
return OrganizationBlogForm
|
||||||
|
|
||||||
def get_title(self):
|
def get_title(self):
|
||||||
return _("Add blog for %s") % self.organization.name
|
return _("Add blog for %s") % self.organization.name
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
{% elif organization.is_open or can_edit %}
|
{% elif organization.is_open or can_edit %}
|
||||||
<form method="post" action="{{ url('join_organization', organization.id, organization.slug) }}">
|
<form method="post" action="{{ url('join_organization', organization.id, organization.slug) }}">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<input type="submit" class="unselectable button" value="{{ _('Join') }}" style="margin-right: 1em">
|
<input type="submit" class="unselectable button" value="{{ _('Join') }}">
|
||||||
</form>
|
</form>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="{{ url('request_organization', organization.id, organization.slug) }}"
|
<a href="{{ url('request_organization', organization.id, organization.slug) }}"
|
||||||
|
|
Loading…
Reference in a new issue