Example #1
0
 def post(self,project_id):
     api_key = request.args.get('api_key')
     if not authorized(api_key,project_id):
         return jsonify({'status':False})
     project = Project()
     project.get(project_id)
     data = request.json 
     project.add_entry(data['name'],data['description'],data['source'])
     return jsonify({'status':True,'msg':'entry created'})
Example #2
0
    def delete(self,project_id,entry_id):        
        api_key = request.args.get('api_key')
        if not authorized(api_key,project_id):
            return jsonify({'status':False})

        project = Project()
        project.get(project_id)
        del(project.project.entry[entry_id])
        del(project.project.stats[entry_id])
        del(project.project.export[entry_id])
        del(project.project.input_file[entry_id])
        project.save()
Example #3
0
    def put(self,project_id,entry_id):
        api_key = request.args.get('api_key')
        if not authorized(api_key,project_id):
            return jsonify({'status':False})

        project = Project()
        project.get(project_id)
        data = request.json
        entry = project.project.entry[entry_id]
        entry['description'] = data['description']
        entry['source'] = data['source']
        project.save()
        return jsonify({'status':True,'msg':'entry updated'})
Example #4
0
 def delete(self,project_id):
     api_key = request.args.get('api_key')
     if not authorized(api_key,project_id):
         return jsonify({'status':False})
     user = User()
     user.api_login(api_key)
     project = Project()
     project.get(project_id)
     if not project.get_id() in user.user.project:
         return jsonify({'status':False})
     user.remove_project(project.get_id())
     model = MongoModel(project=project.project_,collection=project.collection_)
     model.delete({'_id':objectid.ObjectId(str(project_id))})
     
     return jsonify({'status':True})
Example #5
0
    def delete(self, project_id, entry, entry_id):
        api_key = request.args.get("api_key")
        if not authorized(api_key, project_id):
            return jsonify({"status": False})

        # if project not in user.user.project:
        #    return jsonify({'status':False})

        id = objectid.ObjectId(str(entry_id))

        project = Project()
        project.get(project_id)
        model = project.get_entry_collection(entry)
        model.delete({"_id": id})
        project.entry_updated()
        return jsonify({"status": True})
Example #6
0
    def post(self, project_id, entry):
        api_key = request.args.get("api_key")

        if not authorized(api_key, project_id):
            return jsonify({"status": False, "message": "user is not authenticated"})

        # Lets disable it for now. Until flask-principal is implemented
        # if project not in user.user.project:
        #    return jsonify({'status':False,'message':'user don nott have access to project'})

        project = Project()
        project.get(project_id)
        model = project.get_entry_collection(entry)

        model.insert(request.json)
        project.entry_updated()
        return jsonify({"status": True})
Example #7
0
    def put(self,project_id):
        api_key = request.args.get('api_key')
        project = Project()
        project.get(project_id)
        user = User()
        user.api_login(api_key)
        data = request.json
                
        if data.get('action') == 'join':
            user.add_project(project.get_id())
            return jsonify({'status':True,'msg':'join project'})
        elif data.get('action') == 'withdraw':
            user.remove_project(project.get_id())
            return jsonify({'status':True,'msg':'withdrawn from project'})
            
        if not authorized(api_key,project_id):
            return jsonify({'status':False,'msg':'unauthorized'})

        if not project.get_id() in user.user.project:
            return jsonify({'status':False,'msg':'project not in user'})
        
        project.project.description = data['description']
        project.save()
        return jsonify({'status':True})