Пример #1
0
def index(request):
    storage = Storage(GcalCredentials, "id", request.user, "credential")
    credential = storage.get()
    if credential is None or credential.invalid == True:
        return redirect(reverse("gcal:index"))
    else:
        conn = Connection(request.user, credential)

        results = conn.find("#test")

        events = []

        for result in results:
            events.append(
                conn.read(result)
            )  # Very ineficcient since the event content is actually retreived during find

        return render_to_response("gcal_test/index.html", {"events": events})
Пример #2
0
def create(request):
    storage = Storage(GcalCredentials, "id", request.user, "credential")
    credential = storage.get()
    if False:
        return redirect(reverse("gcal:index"))
    else:
        conn = Connection(request.user, credential)

        event = Event(
            summary="Created",
            description="",
            start=datetime.datetime.now(),
            end=datetime.datetime.now() + datetime.timedelta(hours=1),
            tags=[{"tag": "test"}, {"tag": "creation"}],
        )

        event_id = conn.create(event)
        event = conn.read(event_id)

        return render_to_response("gcal_test/update.html", {"event": event, "action": "created"})
Пример #3
0
def update(request):
    storage = Storage(GcalCredentials, "id", request.user, "credential")
    credential = storage.get()
    if False:
        return redirect(reverse("gcal:index"))
    else:
        conn = Connection(request.user, credential)

        results = conn.find("#test")

        if results:
            event = conn.read(results[0])

            event.content["tags"] = [{"tag": "updated"}, {"tag": "test"}]
            event.content["summary"] = str(event.content["summary"]) + " Updated"
            event.content["start"] = event.content["start"] + datetime.timedelta(hours=1)
            event.content["end"] = event.content["end"] + datetime.timedelta(hours=1)

            conn.update(results[0], event)
        else:
            event = None

        return render_to_response("gcal_test/update.html", {"event": event, "action": "updated"})