# HG changeset patch # User Paul Boddie # Date 1315763597 -7200 # Node ID a9685bee2fe3f440f5364bd91343e0ae4201854a # Parent 233e032f72059abd92d6a8bc120d800483f4a353 Prevented a form-only update when the main form submission buttons are used, since the whole page must be affected in case of success or cancellation. Thus, error situations must result in the form plus error being displayed as part of the entire page. Renamed the URL field to make it clearer what the value is currently used for. Introduced white-space stripping on the title and template fields in order to prevent pages being created with leading and trailing spaces in their names. Added white-space stripping to various fields in order to allow defaults to be displayed. diff -r 233e032f7205 -r a9685bee2fe3 actions/EventAggregatorNewEvent.py --- a/actions/EventAggregatorNewEvent.py Sun Sep 11 19:27:16 2011 +0200 +++ b/actions/EventAggregatorNewEvent.py Sun Sep 11 19:53:17 2011 +0200 @@ -136,13 +136,13 @@ "start_offset_default" : escattr(form.get("start-offset", [""])[0]), "end_label" : escape(_("End date (day, month, year) - if different")), - "end_day_default" : escattr(form.get("end-day", [""])[0] or form.get("start-day", [""])[0]), + "end_day_default" : escattr(form.get("end-day", [""])[0].strip() or form.get("start-day", [""])[0]), "end_year_default" : escattr(end_year_default), "end_time_label" : escape(_("End time (hour, minute, second)")), "end_hour_default" : escattr(form.get("end-hour", [""])[0]), "end_minute_default" : escattr(form.get("end-minute", [""])[0]), "end_second_default" : escattr(form.get("end-second", [""])[0]), - "end_offset_default" : escattr(form.get("end-offset", [""])[0] or form.get("start-offset", [""])[0]), + "end_offset_default" : escattr(form.get("end-offset", [""])[0].strip() or form.get("start-offset", [""])[0]), "title_label" : escape(_("Event title/summary")), "title_default" : escattr(form.get("title", [""])[0]), @@ -154,7 +154,7 @@ "latitude_default" : escattr(form.get("latitude", [""])[0]), "longitude_label" : escape(_("Longitude")), "longitude_default" : escattr(form.get("longitude", [""])[0]), - "link_label" : escape(_("Event URL")), + "link_label" : escape(_("External URL")), "link_default" : escattr(form.get("link", [""])[0]), "topics_label" : escape(_("Topics")), @@ -162,7 +162,7 @@ "remove_topic_label" : escape(_("Remove topic")), "template_label" : escape(_("Event template")), - "template_default" : escattr(form.get("template", [""])[0] or template_default), + "template_default" : escattr(form.get("template", [""])[0].strip() or template_default), "parent_label" : escape(_("Parent page")), "parent_default" : escattr(form.get("parent", [""])[0]), @@ -548,7 +548,11 @@ # Either render the form as a fragment of a page. - if msgtype == "dialog" and self.get_form().get("update-form-only", ["false"])[0] == "true": + form = self.get_form() + update_form_only = form.get("update-form-only", ["false"])[0] == "true" + action_attempted = form.has_key(self.form_trigger) + + if msgtype == "dialog" and update_form_only and not action_attempted: send_headers = get_send_headers(self.request) send_headers(["Content-Type: text/html; charset=%s" % config.charset]) self.request.write(msg.render()) @@ -591,12 +595,14 @@ # Validate certain fields. - try: - title = form["title"][0] - template = form["template"][0] - parent = form["parent"][0] - except (KeyError, IndexError): - return 0, _("Event title or template missing.") + title = form.get("title", [""])[0].strip() + template = form.get("template", [""])[0].strip() + parent = form.get("parent", [""])[0].strip() + + if not title: + return 0, _("No event title specified.") + if not template: + return 0, _("No event template specified.") try: start_day = self._get_input(form, "start-day")