def add_user_to_project(projectID, username, user_role): try: proj = Project.objects.get(id=projectID) user = User.objects.get(username=username) association = UserAssociation(user=user, project=proj, role=user_role) association.save() except ObjectDoesNotExist: return
def create_project(user, fields): if user is None: return None if fields is None: return None try: u = User.objects.get(id=user.id) except ObjectDoesNotExist: return None title = fields.get('title', '') description = fields.get('description', '') proj = Project(title=title, description=description) proj.save() association = UserAssociation(user=user,project=proj, role=user_association.ROLE_OWNER) association.save() return proj
def create_project(user, fields): if user is None: return None if fields is None: return None try: u = User.objects.get(id=user.id) except ObjectDoesNotExist: return None title = fields.get('title', '') description = fields.get('description', '') proj = Project(title=title, description=description) proj.save() association = UserAssociation(user=user, project=proj, role=user_association.ROLE_OWNER) association.save() return proj