fix blog permissions

This commit is contained in:
cuom1999 2022-05-30 23:35:30 -05:00
parent 9f43e712d0
commit eaa7be6ec6
3 changed files with 10 additions and 6 deletions

View file

@ -99,11 +99,10 @@ class PostList(FeedView):
.order_by("-sticky", "-publish_on")
.prefetch_related("authors__user", "organizations")
)
if not self.request.user.has_perm("judge.edit_all_post"):
filter = Q(is_organization_private=False)
if self.request.user.is_authenticated:
filter |= Q(organizations__in=self.request.profile.organizations.all())
queryset = queryset.filter(filter)
filter = Q(is_organization_private=False)
if self.request.user.is_authenticated:
filter |= Q(organizations__in=self.request.profile.organizations.all())
queryset = queryset.filter(filter)
return queryset
def get_context_data(self, **kwargs):

View file

@ -714,6 +714,11 @@ class AddOrganizationBlog(
model = BlogPost
form_class = OrganizationBlogForm
def get_form_class(self):
if self.can_edit_organization(self.organization):
return OrganizationAdminBlogForm
return OrganizationBlogForm
def get_title(self):
return _("Add blog for %s") % self.organization.name

View file

@ -13,7 +13,7 @@
{% elif organization.is_open or can_edit %}
<form method="post" action="{{ url('join_organization', organization.id, organization.slug) }}">
{% csrf_token %}
<input type="submit" class="unselectable button" value="{{ _('Join') }}" style="margin-right: 1em">
<input type="submit" class="unselectable button" value="{{ _('Join') }}">
</form>
{% else %}
<a href="{{ url('request_organization', organization.id, organization.slug) }}"