Skip to content
This repository has been archived by the owner on Jan 16, 2023. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:Blueshoe/djangocms-reversion2
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Pollithy committed May 26, 2017
2 parents 6b027d1 + 1d5e1c2 commit 32126c3
Show file tree
Hide file tree
Showing 7 changed files with 278 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Refactor the Reversion
======================

[![Documentation Status](https://readthedocs.org/projects/djangocms-reversion2/badge/?version=latest)](http://djangocms-reversion2.readthedocs.io/en/latest/?badge=latest)


We don't want to use the Reversion backend anymore.
Therefore we will persist the versioned pages in a second tree (MP_Tree).

Expand Down
Empty file added docs/Branching.rst
Empty file.
36 changes: 36 additions & 0 deletions docs/RightsManagement.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
A sketch for RightsManagement
=============================

For a simple collaboration workflow we need the following roles on every PageVersion
- editors
- grammar/spell checkers
- admins
- readers

UserStory for the workflow
--------------------------

1. Two editors decide to create different styles for one page
in order to let the readers choose the better one.
2. They create a PageVersion of the current page (the version before their competition)
3. Now they make a nonsense change and create a PageVersion for the first editor
4. ... and the same for the second editor
5. After writing they ask the grammar/spell checkers who have access to their versions to correct some
mistakes
6. Both editors create a new PageVersion with the corrected page content
7. They notify the user group 'readers' do give feedback
8. After modifying the pages according to the feedback the editors meet again
9. Now they can compare their final PageVersions to the current draft
(or even compare their PageVersions directly)
10. They decide which Version to use and make it the active PageVersion!

Requirements deduced from the UserStory
---------------------------------------

1. Parallel editing of PageVersions
2. Comparision of PageVersions
3. User groups
3.1 editors (also include the spell checkers)
3.2 admins
3.3 readers
4. Explicit sharing of a PageVersion?
20 changes: 20 additions & 0 deletions docs/sphinx/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXPROJ = djangocms_reversion2
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
177 changes: 177 additions & 0 deletions docs/sphinx/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
# -*- coding: utf-8 -*-
#
# djangocms_reversion2 documentation build configuration file, created by
# sphinx-quickstart on Wed May 24 16:48:47 2017.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))


# -- General configuration ------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = []

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'

# The master toctree document.
master_doc = 'index'

# General information about the project.
project = u'djangocms_reversion2'
copyright = u'2017, Blueshoe'
author = u'Blueshoe'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = u'0.2'
# The full version, including alpha/beta/rc tags.
release = u'0.2'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = []

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False


# -- Options for HTML output ----------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']


# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'djangocms_reversion2doc'


# -- Options for LaTeX output ---------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'djangocms_reversion2.tex', u'djangocms\\_reversion2 Documentation',
u'Blueshoe', 'manual'),
]


# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'djangocms_reversion2', u'djangocms_reversion2 Documentation',
[author], 1)
]


# -- Options for Texinfo output -------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'djangocms_reversion2', u'djangocms_reversion2 Documentation',
author, 'djangocms_reversion2', 'One line description of project.',
'Miscellaneous'),
]



# -- Options for Epub output ----------------------------------------------

# Bibliographic Dublin Core info.
epub_title = project
epub_author = author
epub_publisher = author
epub_copyright = copyright

# The unique identifier of the text. This can be a ISBN number
# or the project homepage.
#
# epub_identifier = ''

# A unique identification for the text.
#
# epub_uid = ''

# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']


20 changes: 20 additions & 0 deletions docs/sphinx/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.. djangocms_reversion2 documentation master file, created by
sphinx-quickstart on Wed May 24 16:48:47 2017.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to djangocms_reversion2's documentation!
================================================

.. toctree::
:maxdepth: 2
:caption: Contents:



Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
25 changes: 22 additions & 3 deletions models.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from cms import constants
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from django.utils.encoding import python_2_unicode_compatible, force_text
from django.utils.translation import ugettext_lazy as _, get_language

from treebeard.mp_tree import MP_Node
Expand All @@ -29,6 +30,7 @@ class PageVersion(MP_Node):
help_text=_('Only new PageVersions are not dirty of if a page has been reverted to a '
'PageVersion.'))
language = models.CharField(_('Language'), blank=True, max_length=20)
owner = models.CharField(_("owner"), max_length=constants.PAGE_USERNAME_MAX_LENGTH, editable=False)

def get_title(self):
return self.title or 'implement' # TODO
Expand All @@ -38,18 +40,35 @@ def create_version(cls, draft, language, version_parent=None, comment='', title=
if draft.page_versions.filter(active=True, dirty=False, language=language).count() > 0:
raise AssertionError('not dirty')

# owner of the PageVersion is the last editor
from cms.utils.permissions import get_current_user
user = get_current_user()
if user:
try:
owner = force_text(user)
except AttributeError:
# AnonymousUser may not have USERNAME_FIELD
owner = "anonymous"
else:
# limit changed_by and created_by to avoid problems with Custom User Model
if len(owner) > constants.PAGE_USERNAME_MAX_LENGTH:
changed_by = u'{0}... (id={1})'.format(owner[:constants.PAGE_USERNAME_MAX_LENGTH - 15], user.pk)
else:
owner = "script"

# draft.page_versions.update(clean=False)
hidden_page = revise_page(draft, language)
if not version_parent and draft.page_versions.filter(language=language).exists():
version_parent = draft.page_versions.get(active=True, language=language)

if version_parent:
page_version = version_parent.add_child(hidden_page=hidden_page, draft=draft, comment=comment, title=title,
active=version_parent.active, language=language)
active=version_parent.active, language=language, owner=owner)
version_parent.deactivate()
else:
page_version = PageVersion.add_root(hidden_page=hidden_page, draft=draft, comment=comment, title=title,
active=True, language=language)
active=True, language=language, owner=owner)

return page_version

def save(self, **kwargs):
Expand Down

0 comments on commit 32126c3

Please sign in to comment.