Exemplo n.º 1
0
 def test_context_is_editable(self):
     context = MagicMock()
     context.__name__ = "invoice"
     context.is_editable = lambda :True
     self.assertTrue(context_is_editable(None, context))
     context = MagicMock()
     context.__name__ = "notinvoice"
     self.assertTrue(context_is_editable(None, context))
     context = MagicMock()
     context.__name__ = 'invoice'
     context.is_editable = lambda :False
     context.is_waiting = lambda :True
     request = self.get_csrf_request()
     request.context = context
     self.assertTrue(context_is_editable(request, context))
Exemplo n.º 2
0
def test_context_is_editable(config, pyramid_request):
    from autonomie.views.taskaction import context_is_editable
    context = MagicMock()
    context.__name__ = "invoice"
    context.is_editable = lambda :True
    assert(context_is_editable(None, context))
    context = MagicMock()
    context.__name__ = "notinvoice"
    assert(context_is_editable(None, context))
    context = MagicMock()
    context.__name__ = 'invoice'
    context.is_editable = lambda :False
    context.is_waiting = lambda :True
    pyramid_request.context = context
    assert(context_is_editable(pyramid_request, context))
Exemplo n.º 3
0
    def before(self, form):
        if not context_is_editable(self.request, self.context):
            raise HTTPFound(self.request.route_path("estimation",
                                id=self.context.id,
                                _query=dict(view='html')))

        super(EstimationEdit, self).before(form)
        populate_actionmenu(self.request)
Exemplo n.º 4
0
    def before(self, form):
        if not context_is_editable(self.request, self.context):
            raise HTTPFound(self.request.route_path("cancelinvoice",
                                id=self.context.id,
                                _query=dict(view='html')))

        super(CancelInvoiceEdit, self).before(form)
        populate_actionmenu(self.request)
Exemplo n.º 5
0
    def before(self, form):
        if not context_is_editable(self.request, self.context):
            raise HTTPFound(self.request.route_path("invoice",
                                id=self.context.id,
                                _query=dict(view='html')))

        super(InvoiceEdit, self).before(form)
        populate_actionmenu(self.request)
        form.widget.template = "autonomie:deform_templates/form.pt"
Exemplo n.º 6
0
    def before(self, form):
        if not context_is_editable(self.request):
            raise HTTPFound(
                self.request.route_path(
                    "cancelinvoice",
                    id=self.context.id,
                    _query=dict(view='html')
                )
            )

        super(CancelInvoiceEdit, self).before(form)
        populate_actionmenu(self.request)
Exemplo n.º 7
0
    def before(self, form):
        if not context_is_editable(self.request):
            raise HTTPFound(
                self.request.route_path(
                    "estimation",
                    id=self.context.id,
                    _query=dict(view='html')
                )
            )

        super(EstimationEdit, self).before(form)
        populate_actionmenu(self.request)