コード例 #1
0
 def test_customer(self):
     from autonomie.models.customer import Customer
     print Customer.get(1)
     appstruct = {'name':u'Projéct&$', "code":"ABDC", "customers":["1"]}
     self.addOne(appstruct)
     project = self.getOne()
     self.assertEqual(len(project.customers), 1)
コード例 #2
0
def test_customer_archive(customer, get_csrf_request_with_db):
    req = get_csrf_request_with_db()
    cid = customer.id
    from autonomie.views.customer import customer_archive
    req.context = customer
    req.referer = '/'
    customer_archive(req)
    req.dbsession.flush()
    assert Customer.get(cid).archived
    customer_archive(req)
    req.dbsession.flush()
    assert Customer.get(cid).archived is False
コード例 #3
0
def test_customer_archive(customer, get_csrf_request_with_db):
    req = get_csrf_request_with_db()
    cid = customer.id
    from autonomie.views.customer import customer_archive
    req.context = customer
    req.referer = '/'
    customer_archive(req)
    req.dbsession.flush()
    assert Customer.get(cid).archived
    customer_archive(req)
    req.dbsession.flush()
    assert Customer.get(cid).archived is False
コード例 #4
0
ファイル: views.py プロジェクト: CroissanceCommune/autonomie
    def submit_success(self, appstruct):
        if self.factory is None:
            raise Exception("Forgot to set the factory attribute")

        project_id = appstruct.pop('project_id')
        appstruct['project'] = Project.get(project_id)

        customer_id = appstruct.pop('customer_id')
        appstruct['customer'] = Customer.get(customer_id)

        new_object = self.factory(
            user=self.request.user,
            company=self.context.company,
            **appstruct
        )

        if hasattr(self, "_more_init_attributes"):
            self._more_init_attributes(new_object, appstruct)

        self.dbsession.add(new_object)
        self.dbsession.flush()

        if hasattr(self, "_after_flush"):
            self._after_flush(new_object)

        url = self.request.route_path(
            "/%ss/{id}" % new_object.type_,
            id=new_object.id
        )
        return HTTPFound(url)
コード例 #5
0
    def submit_success(self, appstruct):
        log.debug("Submitting cancelinvoice add")
        appstruct = get_cancel_invoice_dbdatas(appstruct)

        customer_id = appstruct["task"]['customer_id']
        customer = Customer.get(customer_id)

        cinvoice = CancelInvoice(
            self.context.company,
            customer,
            self.context,
            self.context.phases[0],
            self.request.user,
        )
        cinvoice = merge_session_with_post(
            cinvoice,
            appstruct["task"]
        )
        try:
            cinvoice = self.set_task_status(cinvoice)
            cinvoice.invoice.check_resulted(user_id=self.request.user.id)
            self.dbsession.merge(cinvoice.invoice)
            # Line handling
            cinvoice = add_lines_to_cancelinvoice(cinvoice, appstruct)
            self.dbsession.add(cinvoice)
            self.dbsession.flush()
            self.session.flash(u"L'avoir a bien été ajoutée.")
        except Forbidden, err:
            self.request.session.flash(err.message, queue='error')
コード例 #6
0
    def submit_success(self, appstruct):
        log.debug("Submitting estimation add")
        appstruct = get_estimation_dbdatas(appstruct)

        customer_id = appstruct["task"]['customer_id']
        customer = Customer.get(customer_id)

        estimation = Estimation(
            self.context.company,
            customer,
            self.context,
            self.context.phases[0],
            self.request.user,
        )
        estimation = merge_session_with_post(
            estimation,
            appstruct['task']
        )
        try:
            # Line handling
            estimation = add_lines_to_estimation(estimation, appstruct)
            self.dbsession.add(estimation)
            self.dbsession.flush()
            estimation = self.set_task_status(estimation)
            self.session.flash(u"Le devis a bien été ajouté.")
        except Forbidden, err:
            self.request.session.flash(err.message, queue='error')
コード例 #7
0
    def submit_success(self, appstruct):
        log.debug("Submitting invoice add")
        appstruct = get_invoice_dbdatas(appstruct)

        customer_id = appstruct["task"]['customer_id']
        customer = Customer.get(customer_id)

        invoice = Invoice(
            self.context.company,
            customer,
            self.context,
            self.context.phases[0],
            self.request.user,
        )
        invoice = merge_session_with_post(
            invoice,
            appstruct["task"]
        )
        try:
            invoice = self.set_task_status(invoice)
            # Line handling
            invoice = add_lines_to_invoice(invoice, appstruct)
            self.dbsession.add(invoice)
            self.dbsession.flush()
            self.session.flash(u"La facture a bien été ajoutée.")
        except Forbidden, err:
            self.request.session.flash(err.message, queue='error')
コード例 #8
0
    def submit_success(self, appstruct):
        if self.factory is None:
            raise Exception("Forgot to set the factory attribute")

        name = appstruct['name']
        phase_id = appstruct['phase_id']
        phase = Phase.get(phase_id)
        project_id = appstruct['project_id']
        project = Project.get(project_id)
        customer_id = appstruct['customer_id']
        customer = Customer.get(customer_id)

        new_object = self.factory(
            self.context.company,
            customer,
            project,
            phase,
            self.request.user,
        )
        new_object.name = name

        if hasattr(self, "_more_init_attributes"):
            self._more_init_attributes(new_object, appstruct)

        self.dbsession.add(new_object)
        self.dbsession.flush()

        if hasattr(self, "_after_flush"):
            self._after_flush(new_object)

        url = self.request.route_path("/%ss/{id}" % new_object.type_,
                                      id=new_object.id)
        return HTTPFound(url)
コード例 #9
0
    def submit_success(self, appstruct):
        logger.debug("# Duplicating a document #")

        name = appstruct['name']
        phase_id = appstruct['phase_id']
        phase = Phase.get(phase_id)
        project_id = appstruct['project_id']
        project = Project.get(project_id)
        customer_id = appstruct['customer_id']
        customer = Customer.get(customer_id)

        task = self.context.duplicate(
            self.request.user,
            project,
            phase,
            customer,
        )
        task.name = name
        task.course = appstruct['course']
        self.dbsession.add(task)
        self.dbsession.flush()
        logger.debug(
            u"The {t.type_} {t.id} has been duplicated to {new_t.id}".format(
                t=self.context, new_t=task))
        return HTTPFound(
            self.request.route_path('/%ss/{id}' % self.context.type_,
                                    id=task.id))
コード例 #10
0
ファイル: views.py プロジェクト: Swannbm/autonomie
    def submit_success(self, appstruct):
        if self.factory is None:
            raise Exception("Forgot to set the factory attribute")

        project_id = appstruct.pop('project_id')
        appstruct['project'] = Project.get(project_id)

        customer_id = appstruct.pop('customer_id')
        appstruct['customer'] = Customer.get(customer_id)

        new_object = self.factory(
            user=self.request.user,
            company=self.context.company,
            **appstruct
        )

        if hasattr(self, "_more_init_attributes"):
            self._more_init_attributes(new_object, appstruct)

        self.dbsession.add(new_object)
        self.dbsession.flush()

        if hasattr(self, "_after_flush"):
            self._after_flush(new_object)

        url = self.request.route_path(
            "/%ss/{id}" % new_object.type_,
            id=new_object.id
        )
        return HTTPFound(url)
コード例 #11
0
ファイル: views.py プロジェクト: Swannbm/autonomie
    def submit_success(self, appstruct):
        logger.debug("# Duplicating a document #")

        project_id = appstruct.pop('project_id')
        appstruct['project'] = Project.get(project_id)

        customer_id = appstruct.pop('customer_id')
        appstruct['customer'] = Customer.get(customer_id)

        task = self.context.duplicate(
            user=self.request.user,
            **appstruct
        )
        if hasattr(self, "_after_task_duplicate"):
            self._after_task_duplicate(task, appstruct)

        self.dbsession.add(task)
        self.dbsession.flush()
        logger.debug(
            u"The {t.type_} {t.id} has been duplicated to {new_t.id}".format(
                t=self.context,
                new_t=task
            )
        )
        return HTTPFound(
            self.request.route_path(
                '/%ss/{id}' % self.context.type_,
                id=task.id
            )
        )
コード例 #12
0
    def submit_success(self, appstruct):
        log.debug("Submitting cancelinvoice add")
        appstruct = get_cancel_invoice_dbdatas(appstruct)

        customer_id = appstruct["task"]['customer_id']
        customer = Customer.get(customer_id)

        cinvoice = CancelInvoice(
            self.context.company,
            customer,
            self.context,
            self.context.phases[0],
            self.request.user,
        )
        cinvoice = merge_session_with_post(cinvoice, appstruct["task"])
        try:
            cinvoice = self.set_task_status(cinvoice)
            cinvoice.invoice.check_resulted(user_id=self.request.user.id)
            self.dbsession.merge(cinvoice.invoice)
            # Line handling
            cinvoice = add_lines_to_cancelinvoice(cinvoice, appstruct)
            self.dbsession.add(cinvoice)
            self.dbsession.flush()
            self.session.flash(u"L'avoir a bien été ajoutée.")
        except Forbidden, err:
            self.request.session.flash(err.message, queue='error')
コード例 #13
0
ファイル: views.py プロジェクト: CroissanceCommune/autonomie
    def submit_success(self, appstruct):
        logger.debug("# Duplicating a document #")

        project_id = appstruct.pop('project_id')
        appstruct['project'] = Project.get(project_id)

        customer_id = appstruct.pop('customer_id')
        appstruct['customer'] = Customer.get(customer_id)

        task = self.context.duplicate(
            user=self.request.user,
            **appstruct
        )
        if hasattr(self, "_after_task_duplicate"):
            self._after_task_duplicate(task, appstruct)

        self.dbsession.add(task)
        self.dbsession.flush()
        logger.debug(
            u"The {t.type_} {t.id} has been duplicated to {new_t.id}".format(
                t=self.context,
                new_t=task
            )
        )
        return HTTPFound(
            self.request.route_path(
                '/%ss/{id}' % self.context.type_,
                id=task.id
            )
        )
コード例 #14
0
ファイル: project.py プロジェクト: w3bcr4ft/autonomie
def customer_objectify(id_):
    """
    Objectify the associated form node schema (an id schemanode)

    Return the customer object with the given id_

    Note :
        colanderalchemy schemanode is to a model and provides a objectify method
        used to convert an appstruct to the appropriate model.  For the
        project->customer relationship, we need to be able to configure only
        existing elements. Since we didn't found a clear way to do it with
        colanderalchemy, we add the node manually and fit the colanderalchemy
        way of working by implementing usefull methods (namely objectify and
        dictify)
    """
    obj = Customer.get(id_)
    return obj
コード例 #15
0
ファイル: project.py プロジェクト: mike-perdide/autonomie
 def submit_success(self, appstruct):
     """
         Flush project edition to the database
     """
     customer_ids = appstruct.pop("customers", [])
     project = merge_session_with_post(self.request.context, appstruct)
     project.customers = []
     for customer_id in customer_ids:
         customer = Customer.get(customer_id)
         if customer is not None:
             project.customers.append(customer)
     self.dbsession.merge(project)
     self.dbsession.flush()
     message = u"Le projet <b>{0}</b> a été édité avec succès".format(
                                                               project.name)
     self.request.session.flash(message)
     return HTTPFound(self.request.route_path('project', id=project.id))
コード例 #16
0
def customer_objectify(id_):
    """
    Objectify the associated form node schema (an id schemanode)

    Return the customer object with the given id_

    Note :
        colanderalchemy schemanode is to a model and provides a objectify method
        used to convert an appstruct to the appropriate model.  For the
        project->customer relationship, we need to be able to configure only
        existing elements. Since we didn't found a clear way to do it with
        colanderalchemy, we add the node manually and fit the colanderalchemy
        way of working by implementing usefull methods (namely objectify and
        dictify)
    """
    obj = Customer.get(id_)
    return obj
コード例 #17
0
 def pre_duplicate_process(self, task, status, params):
     """
         Common pre process method for document duplication
     """
     form = get_duplicate_form(self.request)
     # if an error is raised here, it will be cached a level higher
     appstruct = form.validate(params.items())
     logger.debug(u" * Form has been validated")
     customer_id = appstruct.get('customer')
     customer = Customer.get(customer_id)
     project_id = appstruct.get('project')
     project = Project.get(project_id)
     phase_id = appstruct.get('phase')
     phase = Phase.get(phase_id)
     logger.debug(u" * Phase : %s" % phase)
     logger.debug(u" * Project : %s" % project)
     appstruct['phase'] = phase
     appstruct['project'] = project
     appstruct['customer'] = customer
     appstruct['user'] = self.request.user
     return appstruct
コード例 #18
0
ファイル: taskaction.py プロジェクト: w3bcr4ft/autonomie
 def pre_duplicate_process(self, task, status, params):
     """
         Common pre process method for document duplication
     """
     form = get_duplicate_form(self.request)
     # if an error is raised here, it will be cached a level higher
     appstruct = form.validate(params.items())
     log.debug(u" * Form has been validated")
     customer_id = appstruct.get('customer')
     customer = Customer.get(customer_id)
     project_id = appstruct.get('project')
     project = Project.get(project_id)
     phase_id = appstruct.get('phase')
     phase = Phase.get(phase_id)
     log.debug(u" * Phase : %s" % phase)
     log.debug(u" * Project : %s" % project)
     appstruct['phase'] = phase
     appstruct['project'] = project
     appstruct['customer'] = customer
     appstruct['user'] = self.request.user
     return appstruct
コード例 #19
0
ファイル: project.py プロジェクト: mike-perdide/autonomie
 def submit_success(self, appstruct):
     """
         Add a project with a default phase in the database
     """
     project = Project()
     project.company_id = self.request.context.id
     customer_ids = appstruct.pop("customers", [])
     project = merge_session_with_post(project, appstruct)
     for customer_id in customer_ids:
         customer = Customer.get(customer_id)
         if customer:
             project.customers.append(customer)
     self.dbsession.add(project)
     self.dbsession.flush()
     # Add a default phase to the project
     default_phase = Phase()
     default_phase.project = project
     self.dbsession.add(default_phase)
     message = u"Le projet <b>{0}</b> a été ajouté avec succès".format(
                                                             project.name)
     self.request.session.flash(message)
     return HTTPFound(self.request.route_path('project', id=project.id))