Commit 7e28062a authored by ras19's avatar ras19
Browse files

Tried changing database to link adding user functionality to the backend. Not...

Tried changing database to link adding user functionality to the backend. Not fully there yet [RS, EW]
parent c9ccb3c8
Pipeline #202344 passed with stage
in 58 seconds
......@@ -41,7 +41,7 @@ def upload_project():
request.json['location'], request.json['files'])
entry = Project(name=name, status=status, description=description, tag=tag, location=location, files=files)
DB.add(entry)
return ''
return entry.id
@project.route('/projects/<project_id>', methods=['POST'])
def update_project(project_id):
......
from re import T
from flask import Blueprint, request, jsonify
from backend.database_config.database import DB
from backend.models.user_model import User_project
user_project = Blueprint('user_project', __name__)
@user_project.route('/user_project', methods=['POST'])
def assign_project_to_user():
username, project_id = (request.json['username'], request.json['project_id'])
entry = User_project(username=username, project_id=project_id)
DB.add(entry)
return ''
\ No newline at end of file
......@@ -64,7 +64,7 @@ class User_project(db.Model):
def serialize(self):
return jsonify(
surname = self.surname,
username = self.username,
project_id = self.project_id,
id = self.id
)
\ No newline at end of file
{
"files": {
"main.css": "/static/react/css/main.953731b2.chunk.css",
"main.js": "/static/react/js/main.fca2f7da.chunk.js",
"main.js.map": "/static/react/js/main.fca2f7da.chunk.js.map",
"main.js": "/static/react/js/main.fa156619.chunk.js",
"main.js.map": "/static/react/js/main.fa156619.chunk.js.map",
"runtime-main.js": "/static/react/js/runtime-main.2ec97bd9.js",
"runtime-main.js.map": "/static/react/js/runtime-main.2ec97bd9.js.map",
"js/2.d9c95973.chunk.js": "/static/react/js/2.d9c95973.chunk.js",
"js/2.d9c95973.chunk.js.map": "/static/react/js/2.d9c95973.chunk.js.map",
"js/2.d2190c59.chunk.js": "/static/react/js/2.d2190c59.chunk.js",
"js/2.d2190c59.chunk.js.map": "/static/react/js/2.d2190c59.chunk.js.map",
"js/3.b496c8d9.chunk.js": "/static/react/js/3.b496c8d9.chunk.js",
"js/3.b496c8d9.chunk.js.map": "/static/react/js/3.b496c8d9.chunk.js.map",
"../../templates/index.html": "/static/react/../../templates/index.html",
"css/main.953731b2.chunk.css.map": "/static/react/css/main.953731b2.chunk.css.map",
"js/2.d9c95973.chunk.js.LICENSE.txt": "/static/react/js/2.d9c95973.chunk.js.LICENSE.txt"
"js/2.d2190c59.chunk.js.LICENSE.txt": "/static/react/js/2.d2190c59.chunk.js.LICENSE.txt"
},
"entrypoints": [
"js/runtime-main.2ec97bd9.js",
"js/2.d9c95973.chunk.js",
"js/2.d2190c59.chunk.js",
"css/main.953731b2.chunk.css",
"js/main.fca2f7da.chunk.js"
"js/main.fa156619.chunk.js"
]
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/static/react/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/static/react/logo192.png"/><link rel="manifest" href="/static/react/manifest.json"/><title>React App</title><script>window.token="{{DRP_token}}"</script><link href="/static/react/css/main.953731b2.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,u,i=r[0],c=r[1],l=r[2],s=0,p=[];s<i.length;s++)u=i[s],Object.prototype.hasOwnProperty.call(o,u)&&o[u]&&p.push(o[u][0]),o[u]=0;for(n in c)Object.prototype.hasOwnProperty.call(c,n)&&(e[n]=c[n]);for(f&&f(r);p.length;)p.shift()();return a.push.apply(a,l||[]),t()}function t(){for(var e,r=0;r<a.length;r++){for(var t=a[r],n=!0,i=1;i<t.length;i++){var c=t[i];0!==o[c]&&(n=!1)}n&&(a.splice(r--,1),e=u(u.s=t[0]))}return e}var n={},o={1:0},a=[];function u(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,u),t.l=!0,t.exports}u.e=function(e){var r=[],t=o[e];if(0!==t)if(t)r.push(t[2]);else{var n=new Promise((function(r,n){t=o[e]=[r,n]}));r.push(t[2]=n);var a,i=document.createElement("script");i.charset="utf-8",i.timeout=120,u.nc&&i.setAttribute("nonce",u.nc),i.src=function(e){return u.p+"js/"+({}[e]||e)+"."+{3:"b496c8d9"}[e]+".chunk.js"}(e);var c=new Error;a=function(r){i.onerror=i.onload=null,clearTimeout(l);var t=o[e];if(0!==t){if(t){var n=r&&("load"===r.type?"missing":r.type),a=r&&r.target&&r.target.src;c.message="Loading chunk "+e+" failed.\n("+n+": "+a+")",c.name="ChunkLoadError",c.type=n,c.request=a,t[1](c)}o[e]=void 0}};var l=setTimeout((function(){a({type:"timeout",target:i})}),12e4);i.onerror=i.onload=a,document.head.appendChild(i)}return Promise.all(r)},u.m=e,u.c=n,u.d=function(e,r,t){u.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},u.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},u.t=function(e,r){if(1&r&&(e=u(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(u.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)u.d(t,n,function(r){return e[r]}.bind(null,n));return t},u.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return u.d(r,"a",r),r},u.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},u.p="/static/react/",u.oe=function(e){throw console.error(e),e};var i=this["webpackJsonpinaglobe-dashboard"]=this["webpackJsonpinaglobe-dashboard"]||[],c=i.push.bind(i);i.push=r,i=i.slice();for(var l=0;l<i.length;l++)r(i[l]);var f=c;t()}([])</script><script src="/static/react/js/2.d9c95973.chunk.js"></script><script src="/static/react/js/main.fca2f7da.chunk.js"></script></body></html>
\ No newline at end of file
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/static/react/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/static/react/logo192.png"/><link rel="manifest" href="/static/react/manifest.json"/><title>React App</title><script>window.token="{{DRP_token}}"</script><link href="/static/react/css/main.953731b2.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,u,i=r[0],c=r[1],l=r[2],s=0,p=[];s<i.length;s++)u=i[s],Object.prototype.hasOwnProperty.call(o,u)&&o[u]&&p.push(o[u][0]),o[u]=0;for(n in c)Object.prototype.hasOwnProperty.call(c,n)&&(e[n]=c[n]);for(f&&f(r);p.length;)p.shift()();return a.push.apply(a,l||[]),t()}function t(){for(var e,r=0;r<a.length;r++){for(var t=a[r],n=!0,i=1;i<t.length;i++){var c=t[i];0!==o[c]&&(n=!1)}n&&(a.splice(r--,1),e=u(u.s=t[0]))}return e}var n={},o={1:0},a=[];function u(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,u),t.l=!0,t.exports}u.e=function(e){var r=[],t=o[e];if(0!==t)if(t)r.push(t[2]);else{var n=new Promise((function(r,n){t=o[e]=[r,n]}));r.push(t[2]=n);var a,i=document.createElement("script");i.charset="utf-8",i.timeout=120,u.nc&&i.setAttribute("nonce",u.nc),i.src=function(e){return u.p+"js/"+({}[e]||e)+"."+{3:"b496c8d9"}[e]+".chunk.js"}(e);var c=new Error;a=function(r){i.onerror=i.onload=null,clearTimeout(l);var t=o[e];if(0!==t){if(t){var n=r&&("load"===r.type?"missing":r.type),a=r&&r.target&&r.target.src;c.message="Loading chunk "+e+" failed.\n("+n+": "+a+")",c.name="ChunkLoadError",c.type=n,c.request=a,t[1](c)}o[e]=void 0}};var l=setTimeout((function(){a({type:"timeout",target:i})}),12e4);i.onerror=i.onload=a,document.head.appendChild(i)}return Promise.all(r)},u.m=e,u.c=n,u.d=function(e,r,t){u.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},u.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},u.t=function(e,r){if(1&r&&(e=u(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(u.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)u.d(t,n,function(r){return e[r]}.bind(null,n));return t},u.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return u.d(r,"a",r),r},u.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},u.p="/static/react/",u.oe=function(e){throw console.error(e),e};var i=this["webpackJsonpinaglobe-dashboard"]=this["webpackJsonpinaglobe-dashboard"]||[],c=i.push.bind(i);i.push=r,i=i.slice();for(var l=0;l<i.length;l++)r(i[l]);var f=c;t()}([])</script><script src="/static/react/js/2.d2190c59.chunk.js"></script><script src="/static/react/js/main.fa156619.chunk.js"></script></body></html>
\ No newline at end of file
......@@ -9,7 +9,6 @@ const CreateProject = () => {
const [tag, setTag] = useState("Other");
const [location, setLocation] = useState("");
const [files, setFiles] = useState("");
const [username, setUsername] = useState("");
const [selectUsers, setSelectUsers] = useState([]);
const history = useHistory();
......@@ -25,20 +24,24 @@ const CreateProject = () => {
method: 'POST',
headers: { "Content-Type": "application/json" },
body: JSON.stringify(newProject)
}).then(() => {
history.push('/');
}).then(response => {
console.log(response)
history.push("/")
})
// selectUsers.map(user =>
// const {assign_project} = { user.username, newProject }
// fetch("/user_project", {
// method: 'POST',
// headers: { "Content-Type": "application/json" },
// body: JSON.stringify(newProject)
// }).then(() => {
// history.push('/');
// }
// )
}
// const addUser = (e) => {
// e.preventDefault()
// setSelectUsers(selectUsers.concat(e.target.value))
// console.log("A user has been added: " + e.target.value)
// console.log("The users are now: " + selectUsers.map(user => { return user } ))
// }
}
return (
<div className="create-project">
......@@ -76,10 +79,10 @@ const CreateProject = () => {
<option value="Health">Health</option>
<option value="Other">Other</option>
</select>
<label>Volunteers assigned to this project</label>
{/* <label>Volunteers assigned to this project</label>
<select multiple={true} onChange={(e) => setSelectUsers(selectUsers.concat(e.target.value))} value={selectUsers} >
{users.map(user => <option value={user.username}>{user.firstname} {user.surname}</option>)}
</select>
</select> */}
<label>Google Drive folder</label>
<textarea placeholder="Copy the link to the Google Drive folder for this project" value={files} onChange={(e) => setFiles(e.target.value)}></textarea>
<button>Add project</button>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment