瀏覽代碼

remove user field

https
jakobsn 6 年之前
父節點
當前提交
29847557ce
共有 3 個檔案被更改,包括 29 行新增3 行删除
  1. +9
    -0
      src/app/models/login.py
  2. +1
    -1
      src/app/models/project.py
  3. +19
    -2
      src/app/views/new_project.py

+ 9
- 0
src/app/models/login.py 查看文件

@@ -12,6 +12,15 @@ def get_users():
cursor.close()
return users

def get_user_id_by_name(username):
cursor = db.cursor()
query = ("SELECT userid from users WHERE username =\"" + username + "\"")
cursor.execute(query)
userid = cursor.fetchall()
cursor.close()
return userid


def match_user(username, password):
"""
Check if user credentials are correct, return if exists


+ 1
- 1
src/app/models/project.py 查看文件

@@ -160,7 +160,7 @@ def get_task_files(taskid):
cursor.close
return filenames

def set_project_users(projectid, userid, read_permission="TRUE",
def set_project_user(projectid, userid, read_permission="TRUE",
write_permission="NULL", modify_permission="NULL"):
cursor = db.cursor()
query = ("INSERT INTO project_users VALUES (\"" + project_id + "\", \"" +


+ 19
- 2
src/app/views/new_project.py 查看文件

@@ -1,6 +1,7 @@
import web
from views.forms import get_task_form_elements, get_new_project_form, get_project_form_elements, get_user_form_elements
import models.project
import models.login
from views.utils import get_nav_bar

# Get html templates
@@ -46,19 +47,35 @@ class New_project:
project_form = self.compose_form(data, "remove_task")
return render.new_project(nav, project_form)
except Exception as e:

try:
# Post the form data and save the project in the database
if data["Create Project"]:
print("hei")
projectid = models.project.set_project(data.category_name, str(session.userid),
data.project_title, data.project_description, "open")
task_count = self.get_task_count(data)
user_count = self.get_user_count(data)
# Save the tasks in the database
for i in range(0, task_count):
models.project.set_task(str(projectid), (data["task_title_" + str(i)]),
(data["task_description_" + str(i)]), (data["budget_" + str(i)]))
print("HIHI")
for i in range(0, user_count):
userid = models.login.get_user_id_by_name(data["user_name_"+str(i)])
read, write, modify = "FALSE"
try:
if data["read_permission_"str(i)]:
read = "TRUE"
except Exception as e:
try:
if data["write_permission_"str(i)]:
write = "TRUE"
except Exception as e:
try:
if data["modify_permission_"str(i)]:
modify = "TRUE"
models.project.set_project_user(str(projectid), str(userid), )
raise web.seeother('/')
except Exception as e:
try:
if data["Add User"]:


Loading…
取消
儲存