| @@ -60,33 +60,44 @@ class New_project: | |||
| try: | |||
| # Post the form data and save the project in the database | |||
| if data["Create Project"]: | |||
| projectid = models.project.set_project(data.category_name, str(session.userid), | |||
| data.project_title, data.project_description, "open") | |||
| task_count = self.get_task_count(data) | |||
| user_count = self.get_user_count(data) | |||
| # Get the "real" user_count, if there is only one field and no users assigned the project is open | |||
| if user_count > 0: | |||
| if len(data.user_name_0): | |||
| status = "in progress" | |||
| else: | |||
| status = "open" | |||
| else: | |||
| status = "open" | |||
| projectid = models.project.set_project(data.category_name, str(session.userid), | |||
| data.project_title, data.project_description, status) | |||
| # Save the tasks in the database | |||
| for i in range(0, task_count): | |||
| models.project.set_task(str(projectid), (data["task_title_" + str(i)]), | |||
| (data["task_description_" + str(i)]), (data["budget_" + str(i)])) | |||
| for i in range(0, user_count): | |||
| userid = models.login.get_user_id_by_name(data["user_name_"+str(i)]) | |||
| read, write, modify = "FALSE", "FALSE", "FALSE" | |||
| try: | |||
| if data["read_permission_"+str(i)]: | |||
| read = "TRUE" | |||
| except Exception as e: | |||
| if len(data["user_name_"+str(i)]): | |||
| userid = models.login.get_user_id_by_name(data["user_name_"+str(i)]) | |||
| read, write, modify = "FALSE", "FALSE", "FALSE" | |||
| try: | |||
| if data["write_permission_"+str(i)]: | |||
| write = "TRUE" | |||
| if data["read_permission_"+str(i)]: | |||
| read = "TRUE" | |||
| except Exception as e: | |||
| try: | |||
| if data["modify_permission_"+str(i)]: | |||
| modify = "TRUE" | |||
| if data["write_permission_"+str(i)]: | |||
| write = "TRUE" | |||
| except Exception as e: | |||
| # This error will be raised if no permission is set | |||
| raise e | |||
| models.project.set_projects_user(str(projectid), str(userid), read, write, modify) | |||
| raise web.seeother('/') | |||
| try: | |||
| if data["modify_permission_"+str(i)]: | |||
| modify = "TRUE" | |||
| except Exception as e: | |||
| # This error will be raised if no permission is set | |||
| raise e | |||
| models.project.set_projects_user(str(projectid), str(userid), read, write, modify) | |||
| raise web.seeother('/') | |||
| except Exception as e: | |||
| raise e | |||