示例#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":
            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)
示例#3
0
def main():

    try:
        form = CGIgetForm()
        user = CGIlogin(form)
        if form.has_key("ID"):
            e = Event(form["ID"])
            if form.has_key("cancel"):
                print e.EventView()
                return
        if user == "admin" or user in GetEditors():
            name = Editor(user).name
            email = Editor(user).email
            mailto = calendarEmail
            bcc = e.notifyList
            bcc.append(email)
            subject = "%s Event Notification" % calendarAbbr
            if form.has_key("message"):
                message = "---------\n%s\n---------" % form["message"]
            else:
                message = ""
            text="""\
Title: %s
Date: %s
Time: %s to %s
Location: %s

%s

%s

Please visit the following URL to view further details:
<%s/ViewEvent.py?ID=%s>

If you wish to be removed from the notification list for this event, 
please contact the %s Administration."""\
% (e.title, FormatDate(e.start, day=True),
            FormatTime(e.start), FormatTime(e.end), e.location,
            StripHTML(ConvertBreaks(e.description)), message,
            cgiURL, e.ID, calendarAbbr)
            SendEmail(mailto, subject, text, bcc=bcc)
            message = \
            "Requested information has been sent to the notification list"
            print e.EventView(message)
        else:
            print LoginPage(script="SendNotification.py", form=form)
    except CalendarError, errorText:
        print ErrorPage(errorText)
示例#4
0
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)
示例#5
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)
示例#6
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)
示例#7
0
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)
示例#8
0
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)
示例#9
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)
示例#10
0
def main():

    try:
        form = CGIgetForm()
        user = CGIlogin(form)
        if form.has_key("ID"):
            e = Event(form["ID"])
            if form.has_key("cancel"):
                print e.EventView()
                return
        if user in GetEditors():
            name = Editor(user).name
            email = Editor(user).email
            if email:
                emailLink = "<%s>" % email
            else:
                emailLink = ""
            mailto = []
            for supervisor in GetSupervisors():
                mailto.append(Editor(supervisor).email)
            mailto.append(calendarEmail)
            subject = "%s Event Request" % calendarAbbr
            if form.has_key("message"):
                message = "Additional Message:\n%s" % form["message"]
            else:
                message = ""
            if form.has_key("prefix"):
                prefix = form["prefix"]
            else:
                prefix = "A change to"
            if e.status == "Approved":
                script = "EditEvent.py"
            else:
                script = "ViewEvent.py"
            text = """\
%s the following %s event has been requested:

Title: %s
Date: %s
Time: %s to %s
Location: %s
Resource: %s
Category: %s

Requested by: %s %s

Please visit the following URL to approve or modify the requested event:

<%s/%s?ID=%s>

%s
""" % (prefix, calendarAbbr, e.title, FormatDate(e.start, day=True),
            FormatTime(e.reservation["start"]), FormatTime(e.reservation["end"]),
            ", ".join(e.locations), ", ".join(e.resources), ", ".join(
            e.categories), name, emailLink, cgiURL, script, e.ID, message)
            SendEmail(mailto, subject, text, cc=email)
            message = \
            "Requested information has been sent to the %s Administration" \
            % calendarAbbr
            print e.EventView(message)
        else:
            print LoginPage(script="SendRequest.py", form=form)
    except CalendarError, errorText:
        print ErrorPage(errorText)