def main(): try: form = CGIgetForm() user = CGIlogin(form) if user == "admin" or user in GetSupervisors(): if form.has_key("username"): username = form["username"].lower() if username in GetEditors(): raise CalendarError, "Username already used." e = Editor(username) else: raise CalendarError, "No username specified" e.user = username if form.has_key("firstname") and form.has_key("lastname"): e.firstname = form["firstname"] e.lastname = form["lastname"] e.name = e.firstname + " " + e.lastname else: raise CalendarError, "No full name specified" #Set an initial password at random e.password = SetPassword() e.Store() print e.EditorPage() else: print LoginPage("Not authorized for this operation", script="AddEditor.py", form=form) except CalendarError, errorText: print AdminPage(errorText)
def main(): try: form = CGIgetForm() user = CGIlogin(form) if form.has_key("username"): e = Editor(form["username"]) else: raise CalendarError, "No username specified" if user == e.user or user == "admin" or user in GetSupervisors(): if form.has_key("cancel"): print EditorsPage() elif form.has_key("delete"): if user == e.user: print e.EditorPage("Cannot delete yourself") else: e.Delete() print EditorsPage("Editor deleted") else: if form.has_key("firstname") and form.has_key("lastname"): e.firstname = form["firstname"] e.lastname = form["lastname"] e.name = "%s %s" % (e.firstname, e.lastname) message = "Editor details successfully updated" if form.has_key("email"): if IsEmail(form["email"]): e.email = form["email"] else: message = "Invalid email address" else: e.email = "" if form.has_key("phone"): e.phone = form["phone"] else: e.phone = "" if form.has_key("authority"): e.authority = form["authority"] e.Store() print e.EditorPage(message) else: print LoginPage(script="ModifyEditor.py", form=form) except CalendarError, errorText: print ErrorPage(errorText)
def main(): try: form = CGIgetForm() user = CGIlogin(form) if user == "admin": print AdminPage() elif user in GetEditors(): e = Editor(user) print e.EditorPage() return else: raise CalendarError, "Invalid user and/or password" except CalendarError, errorText: print ErrorPage(errorText)
def main(): try: form = CGIgetForm() user = CGIlogin(form) if user: if form.has_key("editor"): username = form["editor"] if username not in GetEditors(): raise CalendarError, "Invalid editor name" if user == username or user == "admin" \ or user in GetSupervisors(): e = Editor(username) print e.EditorPage() else: raise CalendarError, "No editor specified" else: print LoginPage(script="EditEditor.py", form=form) except CalendarError, errorText: print ErrorPage(errorText)
def main(): try: form = CGIgetForm() user = CGIlogin(form, printHeader=False) e = Editor(form["username"]) if user == e.user or user == "admin" or user in GetSupervisors(): if form["newpassword"]: e.password = form["newpassword"].strip() if form["verification"]: if form["verification"].strip() == e.password: message = "Password successfully changed." e.Store() if user == e.user: print MakeCookie(user, e.password) else: message = \ "Password not changed as the two entries did not match." CGIprintHeader() print e.EditorPage(message) else: print LoginPage(script="ChangePassword.py", form=form) except CalendarError, errorText: print ErrorPage(errorText)