Commit e46cba20 authored by Kacprzak, Izabella's avatar Kacprzak, Izabella
Browse files

When deleting a user added deleting corresponding todos and assignmenets in projects [IK]

parent e3cede7e
Pipeline #204784 passed with stages
in 2 minutes and 33 seconds
......@@ -2,6 +2,8 @@ from flask import Blueprint, request, jsonify, Response
from backend.database_config.database import DB
from backend.models.user_model import User
from backend.models.user_model import User_project
from backend.models.todo_model import Todo
from backend.models.task_model import AssignedTask
from backend.main import Message
import backend.main
import bcrypt
......@@ -30,7 +32,6 @@ def get_all_users_in_value_label_form():
def get_id(username):
user = User.query.get(username)
return jsonify(
username = user.username,
firstname = user.firstname,
surname = user.surname,
password = user.password,
......@@ -77,27 +78,19 @@ def add_user():
@user.route('/users/<username>', methods=['POST'])
def update_user(username):
entry = User.query.get(username)
firstname, surname, password, title, email, phone_no, bio, joined, location, availability, partnership_opportunities, interests = (
firstname, surname, title, email, phone_no, bio, location, availability, partnership_opportunities, interests = (
request.json['firstname'],
request.json['surname'],
request.json['password'],
request.json['title'],
request.json['email'], request.json['phone_no'], request.json['bio'], request.json['joined'],
request.json['email'], request.json['phone_no'], request.json['bio'],
request.json['location'],request.json['availability'],
request.json['partnership_opportunities'], request.json['interests'])
entry.firstname = firstname
entry.surname = surname
salt = bcrypt.gensalt()
hash_pswd = bcrypt.hashpw(password.encode('utf-8'), salt)
entry.password = hash_pswd
entry.title = title
entry.email = email
entry.phone_no = phone_no
entry.bio = bio
entry.joined = joined
entry.location = location
entry.availability = availability
entry.partnership_opportunities = partnership_opportunities
......@@ -116,6 +109,14 @@ def delete_user(username):
for e in entries:
DB.delete(e)
entries = Todo.query.filter_by(username=username)
for e in entries:
DB.delete(e)
entries = AssignedTask.query.filter_by(username=username)
for e in entries:
DB.delete(e)
entry = User.query.get(username)
DB.delete(entry)
return ''
......
{
"files": {
"main.css": "/static/react/css/main.599c7cc1.chunk.css",
"main.js": "/static/react/js/main.69c151b5.chunk.js",
"main.js.map": "/static/react/js/main.69c151b5.chunk.js.map",
"main.js": "/static/react/js/main.4429b17a.chunk.js",
"main.js.map": "/static/react/js/main.4429b17a.chunk.js.map",
"runtime-main.js": "/static/react/js/runtime-main.094287be.js",
"runtime-main.js.map": "/static/react/js/runtime-main.094287be.js.map",
"js/2.518ddeb9.chunk.js": "/static/react/js/2.518ddeb9.chunk.js",
"js/2.518ddeb9.chunk.js.map": "/static/react/js/2.518ddeb9.chunk.js.map",
"js/2.49ea22cc.chunk.js": "/static/react/js/2.49ea22cc.chunk.js",
"js/2.49ea22cc.chunk.js.map": "/static/react/js/2.49ea22cc.chunk.js.map",
"js/3.ddc4d6e7.chunk.js": "/static/react/js/3.ddc4d6e7.chunk.js",
"js/3.ddc4d6e7.chunk.js.map": "/static/react/js/3.ddc4d6e7.chunk.js.map",
"../../templates/index.html": "/static/react/../../templates/index.html",
"css/main.599c7cc1.chunk.css.map": "/static/react/css/main.599c7cc1.chunk.css.map",
"js/2.518ddeb9.chunk.js.LICENSE.txt": "/static/react/js/2.518ddeb9.chunk.js.LICENSE.txt"
"js/2.49ea22cc.chunk.js.LICENSE.txt": "/static/react/js/2.49ea22cc.chunk.js.LICENSE.txt"
},
"entrypoints": [
"js/runtime-main.094287be.js",
"js/2.518ddeb9.chunk.js",
"js/2.49ea22cc.chunk.js",
"css/main.599c7cc1.chunk.css",
"js/main.69c151b5.chunk.js"
"js/main.4429b17a.chunk.js"
]
}
\ No newline at end of file
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.599c7cc1.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:"ddc4d6e7"}[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.518ddeb9.chunk.js"></script><script src="/static/react/js/main.69c151b5.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.599c7cc1.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:"ddc4d6e7"}[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.49ea22cc.chunk.js"></script><script src="/static/react/js/main.4429b17a.chunk.js"></script></body></html>
\ No newline at end of file
......@@ -130,7 +130,6 @@ const AddUser = () => {
placeholder="Tell your colleagues a bit about yourself"
/>
{/* Think about changing type to force date */}
<label>Joined [required]</label>
<input
type="date"
......
......@@ -34,7 +34,7 @@ const EditProject = () => {
});
});
}).then(() => {
history.push('/');
history.push('/projects');
})
}
......
......@@ -33,7 +33,7 @@ const EditUser = () => {
headers: { "Content-Type": "application/json" },
body: JSON.stringify(e)
}).then(() => {
history.push('/');
history.push('/users');
})
}
......@@ -49,8 +49,9 @@ const EditUser = () => {
<br />
<h2>Edit user</h2>
{isPending && <h2>Loading...</h2>}
<Link to={`/users/change-password`}>Change Password</Link>
<Link to={`/users/change-password`} style={{fontSize: "20px"}}>Change Password</Link>
{firstname && <form onSubmit={handleSubmit(onSubmit)}>
<br />
<label htmlFor="firstname">Firstname</label>
<input {...register("firstname")}
placeholder="Input your first name here"
......@@ -69,13 +70,6 @@ const EditUser = () => {
defaultValue={title}
/>
<label htmlFor="password">Password (click link above to change password)</label>
<input {...register("password")}
disabled
placeholder="Input the password"
defaultValue={password}
/>
<label htmlFor="email">Email</label>
<input {...register("email")}
......@@ -96,13 +90,6 @@ const EditUser = () => {
defaultValue={bio}
/>
<label htmlFor="joined">Joined</label>
<input {...register("joined")}
placeholder="Eg: 20th April 2020"
type="date"
defaultValue={joined}
/>
<label htmlFor="location">Location</label>
<input {...register("location")}
placeholder="Where are you currently based?"
......
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