mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-09 19:40:19 +00:00
Add page for clubs and inactive clubs
This commit is contained in:
@ -147,6 +147,10 @@ Welcome to the wiki page!
|
||||
p.set_lock(root)
|
||||
PageRev(page=p, title="Laverie", author=root, content="Fonctionnement de la laverie").save()
|
||||
|
||||
p = Page(name=settings.SITH_CLUB_ROOT_PAGE)
|
||||
p.set_lock(root)
|
||||
p.save()
|
||||
|
||||
# Here we add a lot of test datas, that are not necessary for the Sith, but that provide a basic development environment
|
||||
if not options['prod']:
|
||||
# Adding user Skia
|
||||
|
@ -999,6 +999,11 @@ class Page(models.Model):
|
||||
except:
|
||||
return self.name
|
||||
|
||||
@property
|
||||
def is_club_page(self):
|
||||
unauthorized_parent = Page.objects.filter(name=settings.SITH_CLUB_ROOT_PAGE).first()
|
||||
return unauthorized_parent is not None and (self == unauthorized_parent or unauthorized_parent in self.get_parent_list())
|
||||
|
||||
def delete(self):
|
||||
self.unset_lock_recursive()
|
||||
self.set_lock_recursive(User.objects.get(id=0))
|
||||
|
@ -25,12 +25,16 @@
|
||||
<div class="tool_bar">
|
||||
<div class="tools">
|
||||
{% if page %}
|
||||
{% if page.club %}
|
||||
<a href="{{ url('club:club_view', club_id=page.club.id) }}">{% trans %}View{% endtrans %}</a>
|
||||
{% else %}
|
||||
<a href="{{ url('core:page', page.get_full_name()) }}">{% trans %}View{% endtrans %}</a>
|
||||
{% endif %}
|
||||
<a href="{{ url('core:page_hist', page_name=page.get_full_name()) }}">{% trans %}History{% endtrans %}</a>
|
||||
{% if can_edit(page, user) %}
|
||||
<a href="{{ url('core:page_edit', page_name=page.get_full_name()) }}">{% trans %}Edit{% endtrans %}</a>
|
||||
{% endif %}
|
||||
{% if can_edit_prop(page, user) %}
|
||||
{% if can_edit_prop(page, user) and not page.is_club_page %}
|
||||
<a href="{{ url('core:page_prop', page_name=page.get_full_name()) }}">{% trans %}Prop{% endtrans %}</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
@ -1,12 +1,18 @@
|
||||
{% extends "core/page.jinja" %}
|
||||
|
||||
{% block content %}
|
||||
{% if page %}
|
||||
{{ super() }}
|
||||
{% endif %}
|
||||
<h2>{% trans %}Page properties{% endtrans %}</h2>
|
||||
<form action="" method="post">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p() }}
|
||||
<p><input type="submit" value="{% trans %}Save{% endtrans %}" /></p>
|
||||
</form>
|
||||
{% if page %}
|
||||
<a href="{{ url('core:page_delete', page_id=page.id)}}">{% trans %}Delete{% endtrans %}</a>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
|
@ -25,7 +25,6 @@ function make_preview() {
|
||||
<p><input type="button" value="{% trans %}Preview{% endtrans %}" onclick="javascript:make_preview();" /></p>
|
||||
<p><input type="submit" value="{% trans %}Save{% endtrans %}" /></p>
|
||||
</form>
|
||||
<a href="{{ url('core:page_delete', page_id=page.id)}}">{% trans %}Delete{% endtrans %}</a>
|
||||
<div id="preview" class="page_content">
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
@ -269,3 +269,17 @@ class PagePropForm(forms.ModelForm):
|
||||
super(PagePropForm, self).__init__(*arg, **kwargs)
|
||||
self.fields['edit_groups'].required = False
|
||||
self.fields['view_groups'].required = False
|
||||
|
||||
|
||||
class PageForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Page
|
||||
fields = ['parent', 'name', 'owner_group', 'edit_groups', 'view_groups']
|
||||
widgets = {
|
||||
'edit_groups': CheckboxSelectMultiple,
|
||||
'view_groups': CheckboxSelectMultiple,
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(PageForm, self).__init__(*args, **kwargs)
|
||||
self.fields['parent'].queryset = self.fields['parent'].queryset.exclude(name=settings.SITH_CLUB_ROOT_PAGE).filter(club=None)
|
||||
|
@ -27,13 +27,22 @@ from django.core.urlresolvers import reverse_lazy
|
||||
from django.views.generic import ListView, DetailView
|
||||
from django.views.generic.edit import UpdateView, CreateView, DeleteView
|
||||
from django.forms.models import modelform_factory
|
||||
from django.forms import CheckboxSelectMultiple
|
||||
from django.http import Http404
|
||||
|
||||
from core.models import Page, PageRev, LockError
|
||||
from core.views.forms import MarkdownInput
|
||||
from core.views.forms import MarkdownInput, PageForm, PagePropForm
|
||||
from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin, CanCreateMixin
|
||||
|
||||
|
||||
class CanEditPagePropMixin(CanEditPropMixin):
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
res = super(CanEditPagePropMixin, self).dispatch(request, *args, **kwargs)
|
||||
if self.object.is_club_page:
|
||||
raise Http404
|
||||
return res
|
||||
|
||||
|
||||
class PageListView(CanViewMixin, ListView):
|
||||
model = Page
|
||||
template_name = 'core/page_list.jinja'
|
||||
@ -88,12 +97,7 @@ class PageRevView(CanViewMixin, DetailView):
|
||||
|
||||
class PageCreateView(CanCreateMixin, CreateView):
|
||||
model = Page
|
||||
form_class = modelform_factory(Page,
|
||||
fields=['parent', 'name', 'owner_group', 'edit_groups', 'view_groups', ],
|
||||
widgets={
|
||||
'edit_groups': CheckboxSelectMultiple,
|
||||
'view_groups': CheckboxSelectMultiple,
|
||||
})
|
||||
form_class = PageForm
|
||||
template_name = 'core/page_prop.jinja'
|
||||
|
||||
def get_initial(self):
|
||||
@ -118,14 +122,9 @@ class PageCreateView(CanCreateMixin, CreateView):
|
||||
return ret
|
||||
|
||||
|
||||
class PagePropView(CanEditPropMixin, UpdateView):
|
||||
class PagePropView(CanEditPagePropMixin, UpdateView):
|
||||
model = Page
|
||||
form_class = modelform_factory(Page,
|
||||
fields=['parent', 'name', 'owner_group', 'edit_groups', 'view_groups', ],
|
||||
widgets={
|
||||
'edit_groups': CheckboxSelectMultiple,
|
||||
'view_groups': CheckboxSelectMultiple,
|
||||
})
|
||||
form_class = PagePropForm
|
||||
template_name = 'core/page_prop.jinja'
|
||||
slug_field = '_full_name'
|
||||
slug_url_kwarg = 'page_name'
|
||||
@ -189,7 +188,7 @@ class PageEditView(CanEditMixin, UpdateView):
|
||||
return super(PageEditView, self).form_valid(form)
|
||||
|
||||
|
||||
class PageDeleteView(CanEditPropMixin, DeleteView):
|
||||
class PageDeleteView(CanEditPagePropMixin, DeleteView):
|
||||
model = Page
|
||||
template_name = 'core/delete_confirm.jinja'
|
||||
pk_url_kwarg = 'page_id'
|
||||
|
Reference in New Issue
Block a user