Changeset 12215


Ignore:
Timestamp:
13 Dec 2014, 17:21:27 (10 years ago)
Author:
Henrik Bettermann
Message:

Add DocumentTriggerTransitionFormPage?.

Do not add document without editing document title.

Location:
main/waeup.ikoba/trunk/src/waeup/ikoba
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/browser.py

    r12214 r12215  
    811811    pnav = 4
    812812
     813    form_fields = grok.AutoFields(ICustomerDocument)
     814
    813815    @property
    814816    def selectable_doctypes(self):
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/browser_templates/documentaddform.pt

    r12090 r12215  
    1818      </tr>
    1919    </tbody>
     20    <tal:widgets content="structure provider:widgets" />
    2021  </table>
    2122  <div tal:condition="view/availableActions">
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py

    r12214 r12215  
    828828        self.browser.getControl("Add document").click()
    829829        self.browser.getControl(name="doctype").value = ['CustomerPDFDocument']
     830        self.browser.getControl(name="form.title").value = 'My PDF Document'
    830831        self.browser.getControl("Add document").click()
    831832        self.assertTrue('PDF Document added.' in self.browser.contents)
     
    899900        self.browser.getControl("Add document").click()
    900901        self.browser.getControl(name="doctype").value = ['CustomerSampleDocument']
     902        self.browser.getControl(name="form.title").value = 'My Sample Document'
    901903        self.browser.getControl("Add document").click()
    902904        self.assertTrue('Sample Document added.' in self.browser.contents)
     
    10371039        self.browser.getControl("Add document").click()
    10381040        self.browser.getControl(name="doctype").value = ['CustomerPDFDocument']
     1041        self.browser.getControl(name="form.title").value = 'My PDF Document'
    10391042        self.browser.getControl("Add document").click()
    10401043        self.browser.open(self.documents_path + '/d102/manage')
  • main/waeup.ikoba/trunk/src/waeup/ikoba/documents/browser.py

    r12214 r12215  
    2424from urllib import urlencode
    2525from datetime import datetime
     26from hurry.workflow.interfaces import (
     27    IWorkflowInfo, IWorkflowState, InvalidTransitionError)
    2628from zope.event import notify
    2729from zope.i18n import translate
     
    116118    pnav = 2
    117119
     120    form_fields = grok.AutoFields(IPublicDocument)
     121
    118122    @property
    119123    def selectable_doctypes(self):
     
    149153    grok.name('index')
    150154    grok.require('waeup.viewDocuments')
    151     #grok.template('basepage')
     155    grok.template('documentpage')
    152156    pnav = 2
    153157
     
    198202    def delLocalRoles(self, **data):
    199203        return del_local_roles(self,2,**data)
     204
     205
     206class DocumentTriggerTransitionFormPage(IkobaEditFormPage):
     207    """ View to trigger public document transitions
     208    """
     209    grok.context(IPublicDocument)
     210    grok.name('trigtrans')
     211    grok.require('waeup.triggerTransition')
     212    grok.template('trigtrans')
     213    label = _('Trigger document transition')
     214    pnav = 2
     215
     216    def update(self):
     217        return super(IkobaEditFormPage, self).update()
     218
     219    def getTransitions(self):
     220        """Return a list of dicts of allowed transition ids and titles.
     221
     222        Each list entry provides keys ``name`` and ``title`` for
     223        internal name and (human readable) title of a single
     224        transition.
     225        """
     226        wf_info = IWorkflowInfo(self.context)
     227        allowed_transitions = [t for t in wf_info.getManualTransitions()]
     228        return [dict(name='', title=_('No transition'))] +[
     229            dict(name=x, title=y) for x, y in allowed_transitions]
     230
     231    @action(_('Save'), style='primary')
     232    def save(self, **data):
     233        form = self.request.form
     234        if 'transition' in form and form['transition']:
     235            transition_id = form['transition']
     236            wf_info = IWorkflowInfo(self.context)
     237            try:
     238                wf_info.fireTransition(transition_id)
     239            except InvalidTransitionError, error:
     240                self.flash(error, type="warning")
     241        return
  • main/waeup.ikoba/trunk/src/waeup/ikoba/documents/browser_templates/documentaddform.pt

    r12214 r12215  
    1717        </td>
    1818      </tr>
     19      <tal:widgets content="structure provider:widgets" />
    1920    </tbody>
    2021  </table>
  • main/waeup.ikoba/trunk/src/waeup/ikoba/documents/viewlets.py

    r12206 r12215  
    2727
    2828from waeup.ikoba.documents.interfaces import (
    29     IDocumentsContainer, IDocument)
     29    IDocumentsContainer, IPublicDocument)
    3030from waeup.ikoba.documents.browser import (
    3131    DocumentsContainerManageFormPage, DocumentsContainerPage,
     
    6464class DocumentViewActionButton(ManageActionButton):
    6565    grok.order(1)
    66     grok.context(IDocument)
     66    grok.context(IPublicDocument)
    6767    grok.view(DocumentManageFormPage)
    6868    grok.require('waeup.manageDocuments')
     
    7474class DocumentManageActionButton(ManageActionButton):
    7575    grok.order(1)
    76     grok.context(IDocument)
     76    grok.context(IPublicDocument)
    7777    grok.view(DocumentDisplayFormPage)
    7878    grok.require('waeup.manageDocuments')
    7979    text = _('Manage')
    8080    target = 'manage'
     81
     82
     83class DocumentTrigTransActionButton(ManageActionButton):
     84    grok.order(2)
     85    grok.context(IPublicDocument)
     86    grok.view(DocumentDisplayFormPage)
     87    grok.require('waeup.manageDocuments')
     88    icon = 'actionicon_trigtrans.png'
     89    text = _(u'Transition')
     90    target = 'trigtrans'
     91
     92
  • main/waeup.ikoba/trunk/src/waeup/ikoba/documents/workflow.py

    r12213 r12215  
    4040        msg = _('Document created'),
    4141        destination = CREATED),
     42
     43    Transition(
     44        transition_id = 'publish',
     45        title = _('Publish document'),
     46        source = CREATED,
     47        condition = NullCondition,
     48        msg = _('Document published'),
     49        destination = PUBLISHED),
    4250    )
    4351
Note: See TracChangeset for help on using the changeset viewer.