示例#1
0
def main():

    try:
        form = CGIgetForm()
        user = CGIlogin(form)
        year, month, day = (None, None, None)
        try:
            if form.has_key("day"):
                day = form["day"]
            if form.has_key("month"):
                month = form["month"]
            if form.has_key("year"):
                year = form["year"]
            t = ReadDate(year, month, day)
            year, month, day = t[0:3]
        except ValueError:
            raise CalendarError, "Invalid date"
        if form.has_key("dayview"):
            p = Page(year, month, day)
            p.PutEvents()
            p.Format()
            p.Format(private=True)
            print DayView(year, month, day)
        elif form.has_key("monthview"):
            p = Page(year, month)
            p.Format()
            p.Format(private=True)
            print MonthView(year, month)
    except CalendarError, errorText:
        print ErrorPage(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 user == "admin" or user in GetEditors():
            new_event = Event()
            year, month, day = None, None, None
            if form.has_key("year"):
                date = form["year"]
                if form.has_key("month"):
                    date += " " + form["month"]
                    if form.has_key("day"):
                        date += " " + form["day"]
                        new_event.start = time.strptime(date, "%Y %m %d")
                    else:
                        new_event.start = time.strptime(date, "%Y %m")
                else:
                    new_event.start = time.strptime(date, "%Y")
            new_event.end = new_event.start
            new_event.reservation["start"] = new_event.start
            new_event.reservation["end"] = new_event.end
            new_event.reservation["option"] = "Same as Event"
            new_event.pattern = "Once Only"
            print new_event.EditPage()
        else:
            print LoginPage(script="AddEvent.py", form=form)
    except CalendarError, errorText:
        print ErrorPage(errorText)
示例#4
0
def main():

    try:
        form = CGIgetForm()
        user = CGIlogin(form)
        if user == "admin" or user in GetEditors():
            message = "Contact added"
            if form.has_key("firstname") and form.has_key("lastname"):
                c = Contact()
                c.firstname = form["firstname"]
                c.lastname = form["lastname"]
                c.user = c.firstname + " " + c.lastname
                c.name = c.user
            else:
                raise CalendarError, "No full name specified"
            if form.has_key("phone"):
                c.phone = form["phone"]
            if form.has_key("email"):
                if IsEmail(form["email"]):
                    c.email = form["email"]
                else:
                    message = "Invalid email address"
            #Set an initial password at random
            c.password = SetPassword()
            c.Store()
            print c.ContactPage(message)
        else:
            print LoginPage("Not authorized for this operation",
                            script="AddContact.py",
                            form=form)
    except CalendarError, errorText:
        print AdminPage(errorText)
示例#5
0
def main():

    try:
        form = CGIgetForm()
        user = CGIlogin(form)
        if form.has_key("ID"):
            if form.has_key("email"):
                e = Event(form["ID"])
                emails = form["email"].split()
                for email in emails:
                    if not IsEmail(email):
                        raise CalendarError, "Invalid email address"
                if e.repeats:
                    for repeat in e.repeats:
                        for email in emails:
                            Event(repeat).AddNotification(email)
                else:
                    for email in emails:
                        e.AddNotification(email)
                print e.EventView("Email added to the notification list")
            else:
                raise CalendarError, "No email address given"
        else:
            raise CalendarError, "No event specified"
    except CalendarError, errorText:
        if e:
            print e.EventView(errorText)
        else:
            print ErrorPage(errorText)
示例#6
0
def main():

    try:
        form = CGIgetForm()
        user = CGIlogin(form)
        year, month, day = (None, None, None)
        try:
            if form.has_key("day"):
                day = int(form["day"])
            if form.has_key("month"):
                month = int(form["month"])
            if form.has_key("year"):
                year = int(form["year"])
        except ValueError:
            raise CalendarError, "Invalid date"
        if day:
            print DayView(year, month, day)
        elif month:
            print MonthView(year, month)
        elif year:
            print YearView(year)
        else:
            year, month, day = Today()
            print MonthView(year, month)
    except CalendarError, errorText:
        print ErrorPage(errorText)
示例#7
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)
示例#8
0
def main():

    try:
        form = CGIgetForm()
        user = CGIlogin(form)
        if user == "admin" or user in GetSupervisors():
            if form.has_key("ID"):
                primary_event = Event(form["ID"])
                primary_event.status = "Approved"
                primary_event.AddLog("Event approved")
                primary_event.Store()
                if primary_event.repeats:
                    for repeat in primary_event.repeats:
                        repeat_event = Event(repeat)
                        if repeat <> form["ID"]:
                            repeat_event.AddLog("Event approved", save=False)
                            repeat_event.status = "Approved"
                            repeat_event.Store()
                primary_event.UpdatePages()
                print primary_event.EventView()
            else:
                raise CalendarError, "No event specified"
        else:
            print LoginPage(script="ApproveEvent.py", form=form)
    except CalendarError, errorText:
        print ErrorPage(errorText)
示例#9
0
def main():
    try:
        form = CGIgetForm()
        user = CGIlogin(form)
        if user:
            if form.has_key("locations"):
                print OptionsPage("locations")
            elif form.has_key("resources"):
                print OptionsPage("resources")
            elif form.has_key("categories"):
                print OptionsPage("categories")
            else:
                raise CalendarError, "No viewing option specifed"
        else:
            print LoginPage(script="ViewOptions.py", form=form)
    except CalendarError, errorText:
        print ErrorPage(errorText)
示例#10
0
def main():

    try:
        form = CGIgetForm()
        user = CGIlogin(form)
        if form.has_key("ID"):
            if form.has_key("email"):
                e = Event(form["ID"])
                if e.repeats:
                    for repeat in e.repeats:
                        Event(repeat).RemoveNotification(form["email"])
                else:
                    e.RemoveNotification(form["email"])
                print e.EventView("Email removed from notification list")
            else:
                raise CalendarError, "No email address given"
        else:
            raise CalendarError, "No event specified"
    except CalendarError, errorText:
        print AdminPage(errorText)
示例#11
0
def main():

    try:
        form = CGIgetForm()
        user = CGIlogin(form)
        if user == "admin" or user in GetSupervisors():
            if form.has_key("location"):
                print OptionModule.EditPage("locations", form["location"])
            elif form.has_key("resource"):
                print OptionModule.EditPage("resources", form["resource"])
            elif form.has_key("category"):
                print OptionModule.EditPage("categories", form["category"])
            else:
                raise CalendarError, "No valid option specified"
        else:
            print LoginPage("Not authorized to change calendar options",
                            script="EditOption.py",
                            form=form)
    except CalendarError, errorText:
        print ErrorPage(errorText)
示例#12
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()
            else:
                if IsEmail(form["email"]):
                    if form["name"]:
                        byline = "by %s " % form["name"]
                    else:
                        byline = ""
                    mailto = e.email
                    subject = "[%s] %s" % (calendarAbbr, form["subject"])
                    text = """\
%s

--------
The above message was sent %sfrom the web page of a %s calendar event.

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

Please visit the following URL to view further details:
<%s/ViewEvent.py?ID=%s>
"""\
% (form["message"], byline, calendarAbbr, e.title,
                    FormatDate(e.start, day=True), FormatTime(e.start), FormatTime(e.end),
                    e.location, cgiURL, e.ID)
                    SendEmail(mailto, subject, text, mailfrom=form["email"])
                    print e.EventView\
                    ("The message has been sent to the event organizer")
                else:
                    print e.EventView("You must provide a valid email address")
    except CalendarError, errorText:
        print ErrorPage(errorText)
示例#13
0
def main():

    try:
        form = CGIgetForm()
        user = CGIlogin(form)
        if user == "admin" or user in GetSupervisors():
            if form.has_key("options"):
                options = form["options"]
            else:
                raise CalendarError, "No option specified"
            if form.has_key("selection"):
                selection = form["selection"]
            else:
                raise CalendarError, "No selection specified"
            if form.has_key("description"):
                description = ConvertCRLFs(form["description"])
            else:
                description = ""
            if form.has_key("modify"):
                OptionModule.Add(options, selection, description)
                print OptionsPage(options, "%s modified" % selection)
            elif form.has_key("delete"):
                OptionModule.Delete(options, selection)
                print OptionsPage(options, "%s deleted" % selection)
            elif form.has_key("cancel"):
                print OptionsPage(options)
        else:
            print LoginPage(script="ModifyOption.py", form=form)
    except CalendarError, errorText:
        print ErrorPage(errorText)
示例#14
0
def main():

    try:
        CGIprintHeader()
        form = CGIgetForm()
        if form.has_key("year") and form.has_key("month"):
            year, month = int(form["year"]), int(form["month"])
        else:
            year, month = Today()[0:2]
        title = "%s - %s" % (calendarName, CalendarTitle(year, month))
        table = HTML.Table([170],
                           class_="transparent",
                           cellspacing="0",
                           cellpadding="0",
                           align="center")
        table.Add(
            HTML.Row(
                HTML.Cell(ReducedMonth(year, month, links=True),
                          class_="transparent")))
        print HTML.FramePage(title, table, width=172)
    except CalendarError, errorText:
        print errorText
示例#15
0
def main():

    try:
        form = CGIgetForm()
        user = CGIlogin(form)
        if user == "admin" or user in GetSupervisors():
            supervisor = True
        else:
            supervisor = False
        if user:
            if form.has_key("ID"):
                e = Event(form["ID"])
                if form.has_key("cancel"):
                    print e.EventView()
                    return
                if e.status == "Approved" and not supervisor:
                    message = "Not authorized to remove an approved event"
                    print e.EventView(message)
                    return
                if form.has_key("repeat") and form["repeat"] <> "single":
                    if form["repeat"] == "future":
                        repeats = filter(lambda ID: IDdate(ID) >= Today(),
                                         e.repeats)
                        e.AddLog("Future repeated events removed")
                    else:
                        repeats = e.repeats
                        e.AddLog("Repeated events removed")
                    for ID in repeats:
                        Event(ID).Remove()
                else:
                    e.AddLog("Event removed")
                    e.Remove()
                e.UpdatePages()
                y, m, d = e.start[0:3]
                print DayView(y, m, d, updated=True)
        else:
            print LoginPage(script="ConfirmRemoval.py", form=form)
    except CalendarError, errorText:
        print ErrorPage(errorText)
示例#16
0
文件: Logout.py 项目: rayosborn/pycal
def main():

    try:
        form = CGIgetForm()
        print DeleteCookie()
        CGIprintHeader()
        if form.has_key("year"):
            year = int(form["year"])
            if form.has_key("month"):
                month = int(form["month"])
                if form.has_key("day"):
                    day = int(form["day"])
                    print DayView(year, month, day)
                else:
                    print MonthView(year, month)
            else:
                print YearView(year)
        else:
            year, month, day = Today()
            print MonthView(year, month)
    except CalendarError, errorText:
        print ErrorPage(errorText)
示例#17
0
def main():

    try:
        form = CGIgetForm()
        user = CGIlogin(form)
        if form.has_key("ID"):
            if IDexists(form["ID"]):
                e = Event(form["ID"])
                if user:
                    print e.LogPage()
                else:
                    print LoginPage(script="ViewLog.py", form=form)
    except CalendarError, errorText:
        print ErrorPage(errorText)
示例#18
0
def main():

    try:
        form = CGIgetForm()
        user = CGIlogin(form)
        if user == "admin" or user in GetSupervisors():
            if form.has_key("options"):
                options = form["options"]
            else:
                raise CalendarError, "No option specified"
            if form.has_key("selection"):
                selection = form["selection"]
                if form.has_key("description"):
                    description = ConvertCRLFs(form["description"])
                else:
                    description = None
                OptionModule.Add(options, selection, description)
                print OptionsPage(options, "%s added to the list" % selection)
            else:
                print OptionsPage(options, "No option specified")
        else:
            print LoginPage(script="AddOption.py", form=form)
    except CalendarError, errorText:
        print ErrorPage(errorText)
示例#19
0
def main():

    try:
        form = CGIgetForm()
        user = CGIlogin(form)
        if user == "admin" or user in GetEditors():
            if form.has_key("ID"):
                e = Event(form["ID"])
            else:
                raise CalendarError, "Cannot edit non-existent event"
            print e.EditPage()
        else:
            print LoginPage(script="EditEvent.py", form=form)
    except CalendarError, errorText:
        print ErrorPage(errorText)
示例#20
0
def main():

    try:
        form = CGIgetForm()
        user = CGIlogin(form)
        if form.has_key("ID"):
            ID = form["ID"]
            if IDexists(ID):
                e = Event(ID)
                print e.MessagePage()
            else:
                raise CalendarError, "Event does not exist"
        else:
            raise CalendarError, "No calendar event specified"
    except CalendarError, errorText:
        print ErrorPage(errorText)
示例#21
0
def main():

    try:
        form = CGIgetForm()
        user = CGIlogin(form)
        if user:
            if form.has_key("cancel"):
                print ContactsPage()
            elif form.has_key("delete"):
                if form.has_key("username"):
                    c = Contact(form["username"])
                    c.Delete()
                    message = "Contact deleted"
                else:
                    message = "Contact not specified"
                print ContactsPage(message)
            elif form.has_key("firstname") and form.has_key("lastname"):
                name = "%s %s" % (form["firstname"], form["lastname"])
                if name == form["username"]:
                    c = Contact(name)
                else:
                    c = Contact()
                    c.user = name
                    c.name = name
                    c.firstname = form["firstname"]
                    c.lastname = form["lastname"]
                    oldContact = Contact(form["username"])
                    c.phone = oldContact.phone
                    c.email = oldContact.email
                    oldContact.Delete()
                message = "Contact details successfully updated"
                if form.has_key("email"):
                    if IsEmail(form["email"]):
                        c.email = form["email"]
                    else:
                        message = "Invalid email address"
                else:
                    c.email = ""
                if form.has_key("phone"):
                    c.phone = form["phone"]
                else:
                    c.phone = ""
                c.Store()
                print ContactsPage(message)
            else:
                print ContactsPage("Name not fully specified")
        else:
            print LoginPage(script="ModifyContact.py", form=form)
    except CalendarError, errorText:
        print ErrorPage(errorText)
示例#22
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)
示例#23
0
def main():

    try:
        form = CGIgetForm()
        user = CGIlogin(form)
        if user:
            if form.has_key("contact"):
                username = form["contact"]
                if username not in GetContacts():
                    raise CalendarError, "Invalid contact"
                c = Contact(username)
                print c.ContactPage()
            else:
                raise CalendarError, "No editor specified"
        else:
            print LoginPage(script="EditContact.py", form=form)
    except CalendarError, errorText:
        print ErrorPage(errorText)
示例#24
0
def main():

    try:
        form = CGIgetForm()
        user = CGIlogin(form)
        if user == "admin" or user in GetEditors():
            if form.has_key("ID"):
                ID = form["ID"]
                if IDexists(ID):
                    e = Event(ID)
                    print e.RemovePage()
                else:
                    raise CalendarError, "Event does not exist"
            else:
                raise CalendarError, "No calendar event specified"
        else:
            print LoginPage(script="RemoveEvent.py", form=form)
    except CalendarError, errorText:
        print ErrorPage(errorText)
示例#25
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)
示例#26
0
def main():

    try:
        form = CGIgetForm()
        user = CGIlogin(form)
        if form.has_key("ID"):
            if IDexists(form["ID"]):
                e = Event(form["ID"])
                if user:
                    print e.EventView()
                elif e.status == "Approved" and \
                     e.type <> "Private" and e.type <> "Setup":
                    print e.EventView()
                else:
                    print LoginPage(script="ViewEvent.py", form=form)
            else:
                raise CalendarError, "Event does not exist"
        else:
            raise CalendarError, "No event ID specified"
    except CalendarError, errorText:
        print ErrorPage(errorText)
示例#27
0
def main():

    try:
        form = CGIgetForm()
        user = CGIlogin(form)
        if user == "admin" or user in GetEditors():
            if form.has_key("ID"):
                e = Event(form["ID"])
                t = Event()
                t.Copy(e)
                t.status = "Requested"
                t.pattern = "Once Only"
                t.repeats = []
                t.logs = []
                t.notifyList = []
            else:
                raise CalendarError, "Cannot copy non-existent event"
            print t.EditPage("Don't forget to change the date of this copy",
                             copied=True)
        else:
            print LoginPage(script="CopyEvent.py", form=form)
    except CalendarError, errorText:
        print ErrorPage(errorText)
示例#28
0
def main():

    try:
        CGIprintHeader()
        form = CGIgetForm()
        if form.has_key("length"):
            length = int(form["length"])
        else:
            length = 14
        if form.has_key("type"):
            type = form["type"]
            if not isinstance(type, list):
                type = [type]
        else:
            type = ["Event", "Special", "Banner", "Holiday"]
        if form.has_key("status"):
            status = form["status"]
            if not isinstance(status, list):
                status = [status]
        else:
            status = ["Approved"]
        location, resource, category = None, None, None
        if form.has_key("location"):
            location = form["location"]
        if form.has_key("resource"):
            resource = form["resource"]
        if form.has_key("category"):
            category = form["category"]
        year, month, day = Today()
        title = "%s Event List" % calendarAbbr
        content = HTML.Div(style="font-size:0.85em")
        content.Add(
            HTML.Para(
                CurrentList(year, month, day, length, type, status, location,
                            resource, category)))
        print HTML.FramePage(title, content, width=172)
    except CalendarError, errorText:
        print errorText
示例#29
0
def main():

    try:
        form = CGIgetForm()
        user = CGIlogin(form)
        type, status, layout = None, None, None
        if form.has_key("type"):
            type = form["type"]
            if not isinstance(type, list):
                type = [type]
        else:
            type = ["Event", "Special", "Banner", "Holiday"]
        if form.has_key("setup"):
            if form["setup"] == "setup":
                type = ["Setup"]
        if form.has_key("status"):
            status = form["status"]
            if not isinstance(status, list):
                status = [status]
        else:
            status = ["Approved"]
        if form.has_key("layout"):
            layout = form["layout"]
        organizer, location, resource, category = None, None, None, None
        if form.has_key("location"):
            if form["location"] <> "Location...":
                location = form["location"]
        if form.has_key("resource"):
            if form["resource"] <> "Resource...":
                resource = form["resource"]
        if form.has_key("category"):
            if form["category"] <> "Category...":
                category = form["category"]
        if form.has_key("organizer"):
            if form["organizer"] <> "Organizer...":
                organizer = form["organizer"]
        if form.has_key("startyear") and form.has_key("startmonth") and \
           form.has_key("startday"):
            start = ReadDate(form["startyear"], form["startmonth"], 
                             form["startday"])
        else:
            start = Today()
        if form.has_key("length"):
            try:
                length = int(form["length"])
            except TypeError:
                raise CalendarError, "Invalid entry for number of days"
        else:
            length = 14
        year, month, day = start[0:3]
        print ListPage(year, month, day, length, type, status, layout,
                       organizer, location, resource, category)
    except CalendarError, errorText:
        print ErrorPage(errorText)
示例#30
0
def main():

    try:
        form = CGIgetForm()
        user = CGIlogin(form)
        if user == "admin" or user in GetSupervisors():
            supervisor = True
        else:
            supervisor = False
        if user is None:
            print LoginPage(script="ModifyEvent.py", form=form)
            return
        if form.has_key("ID"):
            ID = form["ID"]
            if not IDexists(ID):
                raise CalendarError, "No event to edit"
            if ID.find("tmp") >= 0:
                e = TemporaryEvent(ID)
            else:
                e = TemporaryEvent()
                e.Copy(Event(ID))
                e.oldID = ID
                e.oldDate = e.start[0:3]
        else:
            e = TemporaryEvent()
        if form.has_key("title"):
            e.title = form["title"]
        if form.has_key("type"):
            e.type = form["type"]
        else:
            e.type = "Event"
        if form.has_key("description"):
            e.description = ConvertCRLFs(form["description"])
        else:
            e.description = ""
        if form.has_key("location"):
            if form["location"] == "Location...":
                e.location = ""
            else:
                e.location = form["location"]           
        try:
            if type == "Banner" or type == "Holiday":
                e.start = ReadTime(form["startyear"], form["startmonth"], 
                                   form["startday"], 12, 0, "AM")
                e.end = e.start
            else:
                e.start = ReadTime(form["startyear"], form["startmonth"], 
                                   form["startday"], form["starthour"], 
                                   form["startminute"], 
                                   form["startampm"].upper())
                e.end = ReadTime(form["startyear"], form["startmonth"], 
                                 form["startday"], form["endhour"], 
                                 form["endminute"], 
                                 form["endampm"].upper(),
                                 end=True)
        except KeyError:
            if not hasattr(e, "oldID"):
                raise CalendarError, "Invalid date/time entry"
        if form.has_key("cancel"):
            if e.start:
                y, m, d = e.start[0:3]
            else:
                y, m, d = Today()
            print DayView(y, m, d)
            return
        if form.has_key("name") and form["name"] <> "Name...":
            if form["name"] in GetEditors(name=True):
                c = GetEditor(form["name"])
            else:
                c = Contact(form["name"])
            e.organizer = c.name
            e.phone = c.phone
            e.email = c.email
        elif form.has_key("organizer"):
            e.organizer = form["organizer"]
            if form.has_key("phone") and form.has_key("email"):
                e.phone = form["phone"]
                e.email = form["email"]
            else:
                if e.organizer in GetEditors(name=True):
                    c = GetEditor(e.organizer)
                elif e.organizer in GetContacts():
                    c = Contact(e.organizer)
                else:
                    c = None
                if form.has_key("phone"):
                    e.phone = form["phone"]
                elif c:
                    e.phone = c.phone
                if form.has_key("email"):
                    e.email = form["email"]
                elif c:
                    e.email = c.email
        else:
            e.organizer = ""
        try:
            e.reservation["option"] = form["reserve"]
            if e.reservation["option"] == "Same as Event":
                e.reservation["start"] = e.start
                e.reservation["end"] = e.end
            elif e.reservation["option"] == "All Day":
                e.reservation["start"] = ReadTime(form["startyear"], 
                                                  form["startmonth"], 
                                                  form["startday"],
                                                  "12", "00", "AM")
                e.reservation["end"] = ReadTime(form["startyear"], 
                                                form["startmonth"], 
                                                form["startday"],
                                                "12", "00", "AM", 
                                                end=True)
            else:
                e.reservation["start"] = ReadTime(form["startyear"], 
                                                  form["startmonth"], 
                                                  form["startday"],
                                                  form["resstarthour"], 
                                                  form["resstartminute"], 
                                                  form["resstartampm"].upper())
                e.reservation["end"] = ReadTime(form["startyear"], 
                                                form["startmonth"], 
                                                form["startday"],
                                                form["resendhour"], 
                                                form["resendminute"], 
                                                form["resendampm"].upper(),
                                                end=True)
                if e.reservation["start"] > e.start:
                    e.reservation["start"] = e.start
                if e.reservation["end"] < e.end:
                    e.reservation["end"] = e.end
        except KeyError:
            if not hasattr(e, "oldID"):
                raise CalendarError, "Invalid reservation time"
        if form.has_key("locations"):
            if isinstance(form["locations"], list):
                e.locations = form["locations"]
            else:
                e.locations = [form["locations"]]
            if "Locations..." in e.locations:
                e.locations.remove("Locations...")
        else:
            e.locations = []
        if e.location:
            try:
                e.locations.remove(e.location)
            except ValueError:
                pass
            e.locations.insert(0, e.location)
        if form.has_key("resources"): 
            if isinstance(form["resources"], list):
                e.resources = form["resources"]
            else:
                e.resources = [form["resources"]]
            if "Resources..." in e.resources:
                e.resources.remove("Resources...")
        else:
            e.resources = []
        if form.has_key("categories"): 
            if isinstance(form["categories"], list):
                e.categories = form["categories"]
            else:
                e.categories = [form["categories"]]
            if "Categories..." in e.categories:
               e.categories.remove("Categories...")
        else:
            e.categories = []
        if form.has_key("setup"):
            e.setup = ConvertCRLFs(form["setup"])
        else:
            e.setup = ""
        if form.has_key("status"):
            e.status = form["status"]
        if form.has_key("editor"): 
            e.editor = form["editor"]
        if form.has_key("pattern"):
            e.pattern = form["pattern"]
            if form["pattern"] <> "Once Only":
                e.number, e.final = None, None
                if form.has_key("number"):
                    e.number = int(form["number"])
                if form.has_key("endyear"):
                    e.final = ReadDate(form["endyear"], form["endmonth"],
                                       form["endday"])
                e.repeats = MakeRepeats(e.pattern, e.start, e.final, e.number)
            else:
                e.repeats = []
        elif form.has_key("repeat"):
            if form["repeat"] == "single":
                e.repeats = []
                e.pattern = "Once Only"
            elif form.has_key("repeats"):
                if isinstance(form["repeats"], list):
                    e.repeats = form["repeats"]
                else:
                    e.repeats = [form["repeats"]]
                if form["repeat"] == "future":
                    e.repeats = filter(lambda ID:IDdate(ID)>=Today(), e.repeats)
            else:
                e.repeats = []
        message = None
        if e.type <> "Banner" and e.type <> "Holiday" and e.end < e.start:
            message = "Warning: End of event precedes the start."
        elif e.type <> "Banner" and e.type <> "Holiday" and e.end == e.start:
            message = "Warning: Event has no duration."
        elif e.start < Now():
            message = "Warning: This event is in the past."
        elif not e.title:
            message = "Warning: No title given for event."
        if hasattr(e, "oldDate"):
            if e.oldDate <> e.start[0:3] and e.repeats:
                message = \
        "Warning: Changing the date will break the link with event repeats."
                e.repeats = []
                e.pattern = "Once Only"
        e.Store()
        print e.EventView(message=message, updating=True)
    except CalendarError, errorText:
        print ErrorPage(errorText)