def add_project(): # Fetch form data projectDetails = request.get_json() name = projectDetails.get('name') description = projectDetails.get('description') visibility = projectDetails.get('visibility') owner = get_jwt_identity() # Check if all data is supplied correctly if name is None: return jsonify({"error": "Project name not specified"}), 400 if description is None: return jsonify({"error": "Project description not specified"}), 400 if visibility is None: return jsonify({"error": "Project visibility not specified"}), 400 if visibility not in allowed_project_visibilities: return jsonify({"error": "Project visibility not a legal value"}), 400 if owner is None: return jsonify({"error": "Project owner not specified"}), 400 if not function.isInt(owner): return jsonify({"error": "ownerID should be string"}) # Add project to the database project = database.addProject(name, description, visibility, owner) # Add owner of project to projectusers user = database.addProjectUser(owner, project['projectID'], 'OWNER') return jsonify(project), 201
def creator(): if request.method == "POST": button = request.form['button'] if button == "Save": pname = request.form["projectname"] if len(pname) >= 1: user = session["user"] html = request.form["pagehtml"] database.addProject(user,pname,html) return redirect(url_for("creator2",prname=pname)) if button == "Return to Homepage": return redirect(url_for("home")) if button == "Publish to Public Projects": pname = request.form["projectname"] if len(pname) >= 1: user = session['user'] html = request.form["pagehtml"] database.addPublicProject(user,pname,html) return redirect(url_for("creator2",prname=pname)) return render_template("creator.html")
def creator2(prname): user = session['user'] if request.method == "POST": button = request.form['button'] if button == "Save": pname = prname user = session["user"] html = request.form["pagehtml"] database.addProject(user,pname,html) return redirect(url_for("creator2",prname=prname)) if button == "Return to Homepage": return redirect(url_for("home")) if button == "Publish to Public Projects": pname = prname user = session['user'] html = request.form["pagehtml"] database.addPublicProject(user,pname,html) if button == "Find User": pname = prname use = session["user"] tar = request.form["colabname"] if database.nameInSys(tar) == 0: tar = "ERR0RZ" html = database.getProject(use,pname) else: html = database.getProject(use,pname) database.makeCollab(use,pname,tar) database.addProject(tar,pname,html) database.makeCollab(tar,pname,use) return render_template("creator.html",p=html,colab=[tar,pname]) if button == str(database.whoCollab(session['user'],prname)): use = session["user"] pname = prname database.stopCollab(use,pname) project = database.getProject(user,prname) if database.isCollab(user,prname): return render_template("creator.html",p=project,colab=[database.whoCollab(user,prname),prname]) return render_template("creator.html",p=project)