diff --git a/docs/releases/3.0.rst b/docs/releases/3.0.rst index 8116dc5014..8b91c1144f 100644 --- a/docs/releases/3.0.rst +++ b/docs/releases/3.0.rst @@ -621,6 +621,8 @@ Bugs fixed or issues closed * `GitLab issue #474 `_ Provide option to serve Mayan EDMS without a webserver (using Tornado o similar). * `GitLab issue #480 `_ Wrong Environment Variables names in documentation * `GitLab issue #481 `_ IMAP sources with metadata not working in 3.0rc1 +* `GitLab issue #484 `_ Document upload wizard only works as admin + * `GitHub issue #264 `_ migrate fails on document_states 0004_workflow_internal_name * `GitHub issue #269 `_ Lack of authentication for document previews diff --git a/mayan/apps/cabinets/wizard_steps.py b/mayan/apps/cabinets/wizard_steps.py index 19360d4650..5dd73c073c 100644 --- a/mayan/apps/cabinets/wizard_steps.py +++ b/mayan/apps/cabinets/wizard_steps.py @@ -9,6 +9,7 @@ from django.utils.translation import ugettext_lazy as _ from sources.wizards import WizardStep from .forms import CabinetListForm +from .permissions import permission_cabinet_add_document class WizardStepCabinets(WizardStep): @@ -28,6 +29,7 @@ class WizardStepCabinets(WizardStep): def get_form_kwargs(self, wizard): return { 'help_text': _('Cabinets to which the document will be added.'), + 'permission': permission_cabinet_add_document, 'user': wizard.request.user } diff --git a/mayan/apps/sources/wizards.py b/mayan/apps/sources/wizards.py index b74c849763..dc8b3897f3 100644 --- a/mayan/apps/sources/wizards.py +++ b/mayan/apps/sources/wizards.py @@ -19,18 +19,31 @@ class WizardStep(object): _registry = {} _deregistry = {} + @classmethod + def deregister(cls, step): + cls._deregistry[step.name] = step + + @classmethod + def deregister_all(cls): + for step in cls.get_all(): + cls.deregister(step=step) + @classmethod def done(cls, wizard): return {} @classmethod def get(cls, name): - return cls._registry[name] + for step in cls.get_all(): + if name == step.name: + return step @classmethod def get_all(cls): return sorted( - cls._registry.values(), key=lambda x: x.number + [ + step for step in cls._registry.values() if step.name not in cls._deregistry + ], key=lambda x: x.number ) @classmethod @@ -56,11 +69,6 @@ class WizardStep(object): @classmethod def register(cls, step): - if step in cls._deregistry: - # This step has been marked for reregistration before it was - # registered - return - if step.name in cls._registry: raise Exception('A step with this name already exists: %s' % step.name) @@ -70,13 +78,12 @@ class WizardStep(object): cls._registry[step.name] = step @classmethod - def deregister(cls, step): - try: - cls._registry.pop(step.name) - except KeyError: - cls._deregistry[step.name] = step - else: - cls._deregistry[step.name] = step + def reregister(cls, name): + cls._deregistry.pop(name) + + @classmethod + def reregister_all(cls): + cls._deregistry = {} @classmethod def step_post_upload_process(cls, document, querystring=None): @@ -125,6 +132,7 @@ class DocumentCreateWizard(SessionWizardView): form_list = WizardStep.get_choices(attribute_name='form_class') condition_dict = dict(WizardStep.get_choices(attribute_name='condition')) + result = self.__class__.get_initkwargs(form_list=form_list, condition_dict=condition_dict) self.form_list = result['form_list'] self.condition_dict = result['condition_dict']