Beispiel #1
0
    def save(self, user):
        project = Project()
        project.name = self.cleaned_data['project_name']
        project.status = 'A'
        project.creator = user
        project.company = Company.objects.get(main_company = True)
        project.save()
        logo = self.cleaned_data['project_logo']
        if logo != None:
            utils.save_image(project, project.id, logo, settings.PROJECT_LOGO_SIZE, 'logo', 'JPEG')
        project.save()

        user_in_p = UserInProject(
                                  user=user,
                                  project=project,
                                  state='a',
                    )
        user_in_p.save()

        return project
Beispiel #2
0
    def save(self, project):

        for uid in self.cleaned_data['user_not_in_project']:
            user = get_object_or_404(User, id=uid)

            up = UserInProject()
            up.user = user
            up.project = project
            up.state = 'a'
            up.save()
            formperm = self.cleaned_data['permissions']

            if formperm['message'] == 'delete':
                user.add_row_perm(project, PERMISSIONS_MESSAGE_EDITDELETE)
                user.add_row_perm(project, PERMISSIONS_MESSAGE_CREATE)
                user.add_row_perm(project, PERMISSIONS_MESSAGE_VIEW)
            elif formperm['message'] == 'create':
                user.add_row_perm(project, PERMISSIONS_MESSAGE_CREATE)
                user.add_row_perm(project, PERMISSIONS_MESSAGE_VIEW)
            elif formperm['message'] == 'view':
                user.add_row_perm(project, PERMISSIONS_MESSAGE_VIEW)

            if formperm['todo'] == 'delete':
                user.add_row_perm(project, PERMISSIONS_TODO_EDITDELETE)
                user.add_row_perm(project, PERMISSIONS_TODO_CREATE)
                user.add_row_perm(project, PERMISSIONS_TODO_VIEW)
            elif formperm['todo'] == 'create':
                user.add_row_perm(project, PERMISSIONS_TODO_CREATE)
                user.add_row_perm(project, PERMISSIONS_TODO_VIEW)
            elif formperm['todo'] == 'view':
                user.add_row_perm(project, PERMISSIONS_TODO_VIEW)

            if formperm['milestone'] == 'delete':
                user.add_row_perm(project, PERMISSIONS_MILESTONE_EDITDELETE)
                user.add_row_perm(project, PERMISSIONS_MILESTONE_CREATE)
                user.add_row_perm(project, PERMISSIONS_MILESTONE_VIEW)
            elif formperm['milestone'] == 'create':
                user.add_row_perm(project, PERMISSIONS_MILESTONE_CREATE)
                user.add_row_perm(project, PERMISSIONS_MILESTONE_VIEW)
            elif formperm['milestone'] == 'view':
                user.add_row_perm(project, PERMISSIONS_MILESTONE_VIEW)

            if formperm['wikiboard'] == 'delete':
                user.add_row_perm(project, PERMISSIONS_WIKIBOARD_EDITDELETE)
                user.add_row_perm(project, PERMISSIONS_WIKIBOARD_CREATE)
                user.add_row_perm(project, PERMISSIONS_WIKIBOARD_VIEW)
            elif formperm['wikiboard'] == 'create':
                user.add_row_perm(project, PERMISSIONS_WIKIBOARD_CREATE)
                user.add_row_perm(project, PERMISSIONS_WIKIBOARD_VIEW)
            elif formperm['wikiboard'] == 'view':
                user.add_row_perm(project, PERMISSIONS_WIKIBOARD_VIEW)

            if formperm['file'] == 'delete':
                user.add_row_perm(project, PERMISSIONS_FILE_EDITDELETE)
                user.add_row_perm(project, PERMISSIONS_FILE_CREATE)
                user.add_row_perm(project, PERMISSIONS_FILE_VIEW)
            elif formperm['file'] == 'create':
                user.add_row_perm(project, PERMISSIONS_FILE_CREATE)
                user.add_row_perm(project, PERMISSIONS_FILE_VIEW)
            elif formperm['file'] == 'view':
                user.add_row_perm(project, PERMISSIONS_FILE_VIEW)