def obj_create(self, bundle, **kwargs): result = super(ProjectResource, self).obj_create(bundle, created_user=bundle.request.user) user_project = UserProject(project=bundle.obj, user=bundle.request.user, permission=1, created_user=bundle.request.user) user_project.save() project_part = ProjectPart(title='Project Part 1', project=bundle.obj, order=0, created_user=bundle.request.user) project_part.save() return result
def invite(self, request, **kwargs): project = get_object_or_404(Project, pk=kwargs['pk']) data = json.loads(request.raw_post_data) if not 'user' in data: return HttpResponse('Unauthorized', status=401) user = get_object_or_404(User, pk=data['user']) if UserProject.objects.check_perms(project, request.user): user_project = UserProject(project=project, user=user, permission=0, created_user=request.user) user_project.save() response_data = {'id': user.id, 'user': '******' % user.id, 'username': '******'.join([user.first_name, user.last_name]), 'permission': 0} else: return HttpResponse('Unauthorized', status=401) return HttpResponse(json.dumps(response_data), mimetype='application/json')
def invite(self, request, **kwargs): project = get_object_or_404(Project, pk=kwargs['pk']) data = json.loads(request.raw_post_data) if not 'user' in data: return HttpResponse('Unauthorized', status=401) user = get_object_or_404(User, pk=data['user']) if UserProject.objects.check_perms(project, request.user): user_project = UserProject(project=project, user=user, permission=0, created_user=request.user) user_project.save() response_data = { 'id': user.id, 'user': '******' % user.id, 'username': '******'.join([user.first_name, user.last_name]), 'permission': 0 } else: return HttpResponse('Unauthorized', status=401) return HttpResponse(json.dumps(response_data), mimetype='application/json')