Пример #1
0
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)
Пример #2
0
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)
Пример #3
0
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)
Пример #4
0
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)