mezzanine_events/event_import.py
def import_from_url(self, request):
        """
        Import an event from another site.
        """

        def fail(message):
            """
            Display and error message and reload the page.
            """
            self.message_user(request, message, level=messages.ERROR)
            return redirect(request.path)

        if request.method == "GET":
            template_name = self.template_name
            context = {"title": "Import event"}
            return render(request, template_name, context)

        try:
            event_url = request.POST["event-url"]
        except KeyError:
            return fail("Could not find 'event-url' in form data.")

        try:
            url, data = self.get_event_data(event_url)
        except EventImportError as e:
            return fail(str(e))

        event = self.create_event(data, data_url=url, user=request.user)

        self.message_user(request, "Event imported successfully")
        return redirect(admin_url(Event, "change", event.pk))

        Import an event from another site.
        
Import an event from another site.
Import an event from another site .
def import_from_url(self, request):
        def fail(message):
            self.message_user(request, message, level=messages.ERROR)
            return redirect(request.path)
        if request.method == "GET":
            template_name = self.template_name
            context = {"title": "Import event"}
            return render(request, template_name, context)
        try:
            event_url = request.POST["event-url"]
        except KeyError:
            return fail("Could not find 'event-url' in form data.")
        try:
            url, data = self.get_event_data(event_url)
        except EventImportError as e:
            return fail(str(e))
        event = self.create_event(data, data_url=url, user=request.user)
        self.message_user(request, "Event imported successfully")
        return redirect(admin_url(Event, "change", event.pk))
def import_from_url ( self , request ) : def fail ( message ) : """
            Display and error message and reload the page.
            """ self . message_user ( request , message , level = messages . ERROR ) return redirect ( request . path ) if request . method == "GET" : template_name = self . template_name context = { "title" : "Import event" } return render ( request , template_name , context ) try : event_url = request . POST [ "event-url" ] except KeyError : return fail ( "Could not find 'event-url' in form data." ) try : url , data = self . get_event_data ( event_url ) except EventImportError as e : return fail ( str ( e ) ) event = self . create_event ( data , data_url = url , user = request . user ) self . message_user ( request , "Event imported successfully" ) return redirect ( admin_url ( Event , "change" , event . pk ) )
Import an event from another site.
Import an event from another site .
"""
        Import an event from another site.
        """ """
            Display and error message and reload the page.
            """
self
request