mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-25 10:34:21 +00:00
Revert "Begin a PageRevision implementation, but this breaks currently everything!"
This reverts commit 979fc7bcb7
.
This commit is contained in:
parent
979fc7bcb7
commit
80926dd4ac
@ -1,45 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('core', '0012_auto_20151127_1504'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='PageRevision',
|
|
||||||
fields=[
|
|
||||||
('id', models.AutoField(verbose_name='ID', serialize=False, primary_key=True, auto_created=True)),
|
|
||||||
('title', models.CharField(blank=True, verbose_name='page title', max_length=255)),
|
|
||||||
('content', models.TextField(blank=True, verbose_name='page content')),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
migrations.RemoveField(
|
|
||||||
model_name='page',
|
|
||||||
name='content',
|
|
||||||
),
|
|
||||||
migrations.RemoveField(
|
|
||||||
model_name='page',
|
|
||||||
name='revision',
|
|
||||||
),
|
|
||||||
migrations.RemoveField(
|
|
||||||
model_name='page',
|
|
||||||
name='title',
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='pagerevision',
|
|
||||||
name='parent_page',
|
|
||||||
field=models.ForeignKey(related_name='revisions', to='core.Page'),
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='page',
|
|
||||||
name='last_revision',
|
|
||||||
field=models.OneToOneField(to='core.PageRevision', default=1),
|
|
||||||
preserve_default=False,
|
|
||||||
),
|
|
||||||
]
|
|
@ -1,19 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('core', '0013_auto_20151127_1521'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.RenameField(
|
|
||||||
model_name='page',
|
|
||||||
old_name='last_revision',
|
|
||||||
new_name='revision',
|
|
||||||
),
|
|
||||||
]
|
|
@ -151,7 +151,10 @@ class Page(GroupManagedObject, models.Model):
|
|||||||
query, but don't rely on it when playing with a Page object, use get_full_name() instead!
|
query, but don't rely on it when playing with a Page object, use get_full_name() instead!
|
||||||
"""
|
"""
|
||||||
name = models.CharField(_('page name'), max_length=30, blank=False)
|
name = models.CharField(_('page name'), max_length=30, blank=False)
|
||||||
revision = models.OneToOneField('PageRevision')
|
# TODO: move title and content to PageRev class with a OneToOne field
|
||||||
|
title = models.CharField(_("page title"), max_length=255, blank=True)
|
||||||
|
content = models.TextField(_("page content"), blank=True)
|
||||||
|
revision = models.PositiveIntegerField(_("current revision"), default=1)
|
||||||
is_locked = models.BooleanField(_("page mutex"), default=False)
|
is_locked = models.BooleanField(_("page mutex"), default=False)
|
||||||
parent = models.ForeignKey('self', related_name="children", null=True, blank=True, on_delete=models.SET_NULL)
|
parent = models.ForeignKey('self', related_name="children", null=True, blank=True, on_delete=models.SET_NULL)
|
||||||
# Attention: this field may not be valid until you call save(). It's made for fast query, but don't rely on it when
|
# Attention: this field may not be valid until you call save(). It's made for fast query, but don't rely on it when
|
||||||
@ -175,10 +178,6 @@ class Page(GroupManagedObject, models.Model):
|
|||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(Page, self).__init__(*args, **kwargs)
|
super(Page, self).__init__(*args, **kwargs)
|
||||||
if self.revision is None:
|
|
||||||
self.revision = PageRevision()
|
|
||||||
self.revision.save()
|
|
||||||
|
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
"""
|
"""
|
||||||
@ -191,8 +190,6 @@ class Page(GroupManagedObject, models.Model):
|
|||||||
_('Duplicate page'),
|
_('Duplicate page'),
|
||||||
code='duplicate',
|
code='duplicate',
|
||||||
)
|
)
|
||||||
if self.revision is not None:
|
|
||||||
self.revision = PageRevision(self.revision)
|
|
||||||
super(Page, self).clean()
|
super(Page, self).clean()
|
||||||
if self.parent is not None and self in self.get_parent_list():
|
if self.parent is not None and self in self.get_parent_list():
|
||||||
raise ValidationError(
|
raise ValidationError(
|
||||||
@ -241,9 +238,3 @@ class Page(GroupManagedObject, models.Model):
|
|||||||
return self.get_full_name()
|
return self.get_full_name()
|
||||||
|
|
||||||
|
|
||||||
class PageRevision(models.Model):
|
|
||||||
# TODO: move title and content to PageRev class with a OneToOne field
|
|
||||||
title = models.CharField(_("page title"), max_length=255, blank=True)
|
|
||||||
content = models.TextField(_("page content"), blank=True)
|
|
||||||
parent_page = models.ForeignKey(Page, related_name="revisions", null=False, blank=False)
|
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ from django.views.generic.edit import UpdateView
|
|||||||
from django.contrib.auth.decorators import login_required, permission_required
|
from django.contrib.auth.decorators import login_required, permission_required
|
||||||
from django.utils.decorators import method_decorator
|
from django.utils.decorators import method_decorator
|
||||||
|
|
||||||
from core.models import Page, PageRevision
|
from core.models import Page
|
||||||
from core.views.forms import PagePropForm
|
from core.views.forms import PagePropForm
|
||||||
from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin
|
from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin
|
||||||
|
|
||||||
@ -60,17 +60,17 @@ class PagePropView(CanEditPropMixin, UpdateView):
|
|||||||
parent_name = '/'.join(page_name.split('/')[:-1])
|
parent_name = '/'.join(page_name.split('/')[:-1])
|
||||||
name = page_name.split('/')[-1]
|
name = page_name.split('/')[-1]
|
||||||
if parent_name == "":
|
if parent_name == "":
|
||||||
p = Page(name=name, revision=PageRevision())
|
p = Page(name=name)
|
||||||
else:
|
else:
|
||||||
parent = Page.get_page_by_full_name(parent_name)
|
parent = Page.get_page_by_full_name(parent_name)
|
||||||
p = Page(name=name, parent=parent, revision=PageRevision())
|
p = Page(name=name, parent=parent)
|
||||||
self.page = p
|
self.page = p
|
||||||
return self.page
|
return self.page
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(PagePropView, self).get_context_data(**kwargs)
|
context = super(PagePropView, self).get_context_data(**kwargs)
|
||||||
if "page" in context.keys():
|
if "page" in context.keys():
|
||||||
context['tests'] = "PAGE_FOUND : "+context['page'].revision.title
|
context['tests'] = "PAGE_FOUND : "+context['page'].title
|
||||||
else:
|
else:
|
||||||
context['tests'] = "PAGE_NOT_FOUND"
|
context['tests'] = "PAGE_NOT_FOUND"
|
||||||
context['new_page'] = self.kwargs['page_name']
|
context['new_page'] = self.kwargs['page_name']
|
||||||
@ -78,7 +78,7 @@ class PagePropView(CanEditPropMixin, UpdateView):
|
|||||||
|
|
||||||
class PageEditView(CanEditMixin, UpdateView):
|
class PageEditView(CanEditMixin, UpdateView):
|
||||||
model = Page
|
model = Page
|
||||||
fields = ['revision.title', 'revision.content',]
|
fields = ['title', 'content',]
|
||||||
template_name_suffix = '_edit'
|
template_name_suffix = '_edit'
|
||||||
|
|
||||||
def get_object(self):
|
def get_object(self):
|
||||||
@ -88,7 +88,7 @@ class PageEditView(CanEditMixin, UpdateView):
|
|||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(PageEditView, self).get_context_data(**kwargs)
|
context = super(PageEditView, self).get_context_data(**kwargs)
|
||||||
if "page" in context.keys():
|
if "page" in context.keys():
|
||||||
context['tests'] = "PAGE_FOUND : "+context['page'].revision.title
|
context['tests'] = "PAGE_FOUND : "+context['page'].title
|
||||||
else:
|
else:
|
||||||
context['tests'] = "PAGE_NOT_FOUND"
|
context['tests'] = "PAGE_NOT_FOUND"
|
||||||
context['new_page'] = self.kwargs['page_name']
|
context['new_page'] = self.kwargs['page_name']
|
||||||
|
Loading…
Reference in New Issue
Block a user