comparison doc/design.txt @ 5332:d0689aaa83db

Applied patch 0038 from issue2550960 to upgrade code examples in documentation to be compatible with both python 2 and 3. Patch supplied by Joseph Myers.
author John Rouillard <rouilj@ieee.org>
date Tue, 12 Jun 2018 20:27:04 -0400
parents 15440504fb04
children ee2e8f8d6648
comparison
equal deleted inserted replaced
5331:57caeefb2f81 5332:d0689aaa83db
978 proceeds when it has three approvals:: 978 proceeds when it has three approvals::
979 979
980 # Permit users only to add themselves to the "approvals" list. 980 # Permit users only to add themselves to the "approvals" list.
981 981
982 def check_approvals(db, cl, id, newdata): 982 def check_approvals(db, cl, id, newdata):
983 if newdata.has_key("approvals"): 983 if "approvals" in newdata:
984 if cl.get(id, "status") == db.status.lookup("approved"): 984 if cl.get(id, "status") == db.status.lookup("approved"):
985 raise Reject, "You can't modify the approvals list " \ 985 raise Reject("You can't modify the approvals list "
986 "for a project that has already been approved." 986 "for a project that has already been approved.")
987 old = cl.get(id, "approvals") 987 old = cl.get(id, "approvals")
988 new = newdata["approvals"] 988 new = newdata["approvals"]
989 for uid in old: 989 for uid in old:
990 if uid not in new and uid != db.getuid(): 990 if uid not in new and uid != db.getuid():
991 raise Reject, "You can't remove other users from " \ 991 raise Reject("You can't remove other users from "
992 "the approvals list; you can only remove " \ 992 "the approvals list; you can only remove "
993 "yourself." 993 "yourself.")
994 for uid in new: 994 for uid in new:
995 if uid not in old and uid != db.getuid(): 995 if uid not in old and uid != db.getuid():
996 raise Reject, "You can't add other users to the " \ 996 raise Reject("You can't add other users to the "
997 "approvals list; you can only add yourself." 997 "approvals list; you can only add yourself.")
998 998
999 # When three people have approved a project, change its status from 999 # When three people have approved a project, change its status from
1000 # "pending" to "approved". 1000 # "pending" to "approved".
1001 1001
1002 def approve_project(db, cl, id, olddata): 1002 def approve_project(db, cl, id, olddata):
1003 if (olddata.has_key("approvals") and 1003 if ("approvals" in olddata and
1004 len(cl.get(id, "approvals")) == 3): 1004 len(cl.get(id, "approvals")) == 3):
1005 if cl.get(id, "status") == db.status.lookup("pending"): 1005 if cl.get(id, "status") == db.status.lookup("pending"):
1006 cl.set(id, status=db.status.lookup("approved")) 1006 cl.set(id, status=db.status.lookup("approved"))
1007 1007
1008 def init(db): 1008 def init(db):
1019 # Only accept attempts to create new patches that come with patch 1019 # Only accept attempts to create new patches that come with patch
1020 # files. 1020 # files.
1021 1021
1022 def check_new_patch(db, cl, id, newdata): 1022 def check_new_patch(db, cl, id, newdata):
1023 if not newdata["files"]: 1023 if not newdata["files"]:
1024 raise Reject, "You can't submit a new patch without " \ 1024 raise Reject("You can't submit a new patch without "
1025 "attaching a patch file." 1025 "attaching a patch file.")
1026 for fileid in newdata["files"]: 1026 for fileid in newdata["files"]:
1027 if db.file.get(fileid, "type") != "text/plain": 1027 if db.file.get(fileid, "type") != "text/plain":
1028 raise Reject, "Submitted patch files must be " \ 1028 raise Reject("Submitted patch files must be "
1029 "text/plain." 1029 "text/plain.")
1030 1030
1031 # When the status is changed from "approved" to "applied", apply the 1031 # When the status is changed from "approved" to "applied", apply the
1032 # patch. 1032 # patch.
1033 1033
1034 def apply_patch(db, cl, id, olddata): 1034 def apply_patch(db, cl, id, olddata):

Roundup Issue Tracker: http://roundup-tracker.org/