示例#1
0
    def create_user(self):
        """
        Creates new user
        """

        from stalker.db.session import DBSession
        from stalker import User

        new_user = User(
            name="{0}".format(self.user_name),
            login="******".format(self.user_login),
            email="{0}".format(self.user_email),
            password="******".format(self.user_password)
        )
        

        #Checks if the user's name and e-mail address are registered in the database.
        #Sends a warning message to the user if registered.

        if not User.query.filter_by(email=self.user_email).scalar() == None:
            QtWidgets.QMessageBox.warning(
                self,
                "Warning",
                "The email address you entered already belongs to an existing user , Please re-enter your e-mail address!"
            )

        elif not User.query.filter_by(login=self.user_login).scalar() == None:
            QtWidgets.QMessageBox.warning(
                self,
                "Warning",
                "The user '{0}' already exists, Please enter new username!".format(self.user_login)
            )


        else:
            try: 
                # Save the user to database
                DBSession.save(new_user)

            #Gets the string representation of an exception
            except BaseException as e:
                DBSession.rollback()
                QtWidgets.QMessageBox.critical(
                    self,
                    "Error",
                    str(e) 
                )

            # now we can give the information message
            QtWidgets.QMessageBox.information(
                self,
                "Success",
                "User '{0}' successfully created!".format(self.user_login)
            )
            # then we can close this dialog
            self.close() 
示例#2
0
    def type_field_changed(self):
        """runs when the type field has changed
        """
        if self.task is None:
            return

        if self.type_field_is_updating:
            return

        # get the type
        assert isinstance(self.type_field, QtWidgets.QComboBox)
        index = self.type_field.currentIndex()
        type_id = self.type_field.itemData(index)

        if type_id != -1:
            from stalker import Type
            type_ = Type.query.get(type_id)
            self.task.type = type_
            from stalker.db.session import DBSession
            DBSession.save(self.task)
示例#3
0
def test_readme_tutorial_code(setup_sqlite3):
    """Tests the tutorial code in README.rst
    """
    from stalker import db
    db.setup()
    db.init()

    from stalker.db.session import DBSession
    assert str(DBSession.connection().engine.url) == 'sqlite://'

    from stalker import User
    me = User(name='Erkan Ozgur Yilmaz',
              login='******',
              email='*****@*****.**',
              password='******')

    # Save the user to database
    DBSession.save(me)

    from stalker import Repository
    repo = Repository(name='Commercial Projects Repository',
                      code='CPR',
                      windows_path='Z:/Projects',
                      linux_path='/mnt/Z/Projects',
                      osx_path='/Volumes/Z/Projects')

    from stalker import FilenameTemplate

    task_template = FilenameTemplate(
        name='Standard Task Filename Template',
        target_entity_type='Task',  # This is for files saved for Tasks
        path='{{project.repository.path}}/{{project.code}}/'
        '{%- for parent_task in parent_tasks -%}'
        '{{parent_task.nice_name}}/'
        '{%- endfor -%}',  # This is Jinja2 template code
        filename=
        '{{version.nice_name}}_v{{"%03d"|format(version.version_number)}}')

    from stalker import Structure
    standard_folder_structure = Structure(
        name='Standard Project Folder Structure',
        templates=[task_template],
        custom_template=
        '{{project.code}}/References'  # If you need extra folders
    )

    from stalker import Project
    new_project = Project(
        name='Test Project',
        code='TP',
        structure=standard_folder_structure,
        repositories=[repo
                      ],  # if you have more than one repository you can do it
    )

    from stalker import ImageFormat
    hd1080 = ImageFormat(name='1080p', width=1920, height=1080)

    new_project.image_format = hd1080

    # Save the project and all the other data it is connected to it
    DBSession.save(new_project)

    from stalker import Task, Asset, Shot, Type

    # define Character asset type
    char_type = Type(name='Character', code='CHAR', target_entity_type='Asset')

    character1 = Asset(name='Character 1',
                       code='CHAR1',
                       type=char_type,
                       project=new_project)

    # Save the Asset
    DBSession.save(character1)

    model = Task(name='Model', parent=character1)

    rigging = Task(
        name='Rig',
        parent=character1,
        depends=[model
                 ],  # For project management, define that Rig can not start
        # before Model ends.
    )

    # Save the new tasks
    DBSession.save([model, rigging])

    # A shot and some tasks for it
    shot = Shot(name='SH001', code='SH001', project=new_project)

    # Save the Shot
    DBSession.save(shot)

    animation = Task(
        name='Animation',
        parent=shot,
    )

    lighting = Task(
        name='Lighting',
        parent=shot,
        depends=[animation],  # Lighting can not start before Animation ends,
        schedule_timing=1,
        schedule_unit='d',  # The task expected to take 1 day to complete
        resources=[me])
    DBSession.save([animation, lighting])

    from stalker import Version

    new_version = Version(task=animation)
    new_version.update_paths()  # to render the naming convention template
    new_version.extension = '.ma'  # let's say that we have created under Maya

    assert new_version.absolute_full_path == \
        "%sTP/SH001/Animation/SH001_Animation_Main_v001.ma" % \
        repo.path
    assert new_version.version_number == 1

    new_version2 = Version(task=animation)
    new_version2.update_paths()  # to render the naming convention template
    new_version2.extension = '.ma'  # let's say that we have created under Maya

    assert new_version2.version_number == 2
    def setUp(self):
        """set up the test
        """
        super(self.__class__, self).setUp()

        # create departments
        from stalker import Department
        self.test_dep1 = Department(name='Dep1')
        self.test_dep2 = Department(name='Dep2')

        # create resources
        from stalker import User
        self.test_user1 = User(login='******',
                               name='User1',
                               email='*****@*****.**',
                               password='******',
                               departments=[self.test_dep1])
        from stalker.db.session import DBSession
        DBSession.add(self.test_user1)

        self.test_user2 = User(login='******',
                               name='User2',
                               email='*****@*****.**',
                               password='******',
                               departments=[self.test_dep1])
        DBSession.add(self.test_user2)

        self.test_user3 = User(login='******',
                               name='User3',
                               email='*****@*****.**',
                               password='******',
                               departments=[self.test_dep2])
        DBSession.add(self.test_user3)

        self.test_user4 = User(login='******',
                               name='User4',
                               email='*****@*****.**',
                               password='******',
                               departments=[self.test_dep2])
        DBSession.add(self.test_user4)

        # user with two departments
        self.test_user5 = User(login='******',
                               name='User5',
                               email='*****@*****.**',
                               password='******',
                               departments=[self.test_dep1, self.test_dep2])
        DBSession.add(self.test_user5)

        # user with no departments
        self.test_user6 = User(login='******',
                               name='User6',
                               email='*****@*****.**',
                               password='******')
        DBSession.add(self.test_user6)

        # repository
        from stalker import Repository
        self.test_repo = Repository(name='Test Repository',
                                    code='TR',
                                    linux_path='/mnt/T/',
                                    windows_path='T:/',
                                    osx_path='/Volumes/T/')
        DBSession.add(self.test_repo)

        # statuses
        from stalker import Status
        self.test_status1 = Status(name='Status 1', code='STS1')
        self.test_status2 = Status(name='Status 2', code='STS2')
        self.test_status3 = Status(name='Status 3', code='STS3')
        self.test_status4 = Status(name='Status 4', code='STS4')
        self.test_status5 = Status(name='Status 5', code='STS5')
        DBSession.add_all([
            self.test_status1, self.test_status2, self.test_status3,
            self.test_status4, self.test_status5
        ])

        # create one project
        from stalker import Project
        self.test_proj1 = Project(name='Test Project 1',
                                  code='TP1',
                                  repository=self.test_repo,
                                  start=datetime.datetime(2013,
                                                          4,
                                                          4,
                                                          tzinfo=pytz.utc),
                                  end=datetime.datetime(2013,
                                                        5,
                                                        4,
                                                        tzinfo=pytz.utc))
        DBSession.add(self.test_proj1)
        self.test_proj1.now = datetime.datetime(2013, 4, 4, tzinfo=pytz.utc)

        # create two tasks with the same resources
        from stalker import Task
        self.test_task1 = Task(
            name='Task1',
            project=self.test_proj1,
            resources=[self.test_user1, self.test_user2],
            alternative_resources=[
                self.test_user3, self.test_user4, self.test_user5
            ],
            schedule_model=0,
            schedule_timing=50,
            schedule_unit='h',
        )
        DBSession.add(self.test_task1)

        self.test_task2 = Task(name='Task2',
                               project=self.test_proj1,
                               resources=[self.test_user1, self.test_user2],
                               alternative_resources=[
                                   self.test_user3, self.test_user4,
                                   self.test_user5
                               ],
                               depends=[self.test_task1],
                               schedule_model=0,
                               schedule_timing=60,
                               schedule_unit='h',
                               priority=800)
        DBSession.save(self.test_task2)