Esempio n. 1
0
def phase2(dbsession, project2):
    from autonomie.models.project import Phase
    phase = Phase(name=u"Phase")
    phase.project = project2
    phase.project_id = project2.id
    project2.phases.append(phase)
    dbsession.add(phase)
    dbsession.flush()
    return phase
Esempio n. 2
0
def phase(dbsession, project):
    from autonomie.models.project import Phase
    phase = Phase(name=u"Phase")
    phase.project = project
    phase.project_id = project.id
    project.phases.append(phase)
    dbsession.add(phase)
    dbsession.flush()
    return phase
Esempio n. 3
0
def add_phase(project, phase_name):
    phase = Phase(name=phase_name)
    phase.project = project

    session = DBSESSION()
    session.add(phase)
    session.flush()

    print u"Added phase to %s: %s" % (project.name, phase_name)

    return phase
Esempio n. 4
0
def populate_db(session):
    from autonomie.models.user import User
    user = User(
        login='******',
        firstname='user1_firstname',
        lastname="user1_lastname",
        email="*****@*****.**"
    )
    user.set_password('o')
    session.add(user)

    from autonomie.models.project import Project
    project = Project(
        name='Projet 1',
        code='P001',
        definition="Projet 1"
    )
    session.add(project)

    from autonomie.models.customer import Customer
    cust = Customer(
        code='C001',
        name='Client1',
        contactLastName=u'Client Lastname',
        address=u'15 rue Victore Hugo',
        zipCode='69003',
        city='Lyon',
    )
    cust.projects.append(project)
    session.add(cust)

    from autonomie.models.project import Phase
    phase = Phase(name='Phase de test')
    phase.project = project
    session.add(phase)


    from autonomie.models.company import Company
    c = Company(
        name="company1",
        goal="Company of user1",
        phone='0457858585',
    )
    c.employees.append(user)
    c.customers.append(cust)
    c.projects.append(project)
    session.add(c)
    from autonomie.scripts import fake_database
    fake_database.set_configuration()
Esempio n. 5
0
def populate_db(session):
    from autonomie.models.user import User
    user = User(
        login='******',
        firstname='user1_firstname',
        lastname="user1_lastname",
        email="*****@*****.**"
    )
    user.set_password('o')
    session.add(user)

    from autonomie.models.project import Project
    project = Project(
        name='Projet 1',
        code='P001',
        definition="Projet 1"
    )
    session.add(project)

    from autonomie.models.customer import Customer
    cust = Customer(
        code='C001',
        name='Client1',
        contactLastName=u'Client Lastname',
        address=u'15 rue Victore Hugo',
        zipCode='69003',
        city='Lyon',
    )
    cust.projects.append(project)
    session.add(cust)

    from autonomie.models.project import Phase
    phase = Phase(name='Phase de test')
    phase.project = project
    session.add(phase)


    from autonomie.models.company import Company
    c = Company(
        name="company1",
        goal="Company of user1",
        phone='0457858585',
    )
    c.employees.append(user)
    c.customers.append(cust)
    c.projects.append(project)
    session.add(c)
    from autonomie.scripts import fake_database
    fake_database.set_configuration()
Esempio n. 6
0
 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))