Exemplo n.º 1
0
def event_ical(request, abbr, event_id):
    event = db.events.find_one({"_id": event_id})
    if event is None:
        raise Http404

    x_name = "X-BILLY"

    cal = Calendar()
    cal.add("prodid", "-//Sunlight Labs//billy//")
    cal.add("version", billy.__version__)

    cal_event = Event()
    cal_event.add("summary", event["description"])
    cal_event["uid"] = "%s@%s" % (event["_id"], get_domain())
    cal_event.add("priority", 5)
    cal_event.add("dtstart", event["when"])
    cal_event.add("dtend", (event["when"] + datetime.timedelta(hours=1)))
    cal_event.add("dtstamp", event["updated_at"])

    if "participants" in event:
        for participant in event["participants"]:
            name = participant["participant"]
            cal_event.add("attendee", name)
            if "id" in participant and participant["id"]:
                cal_event.add("%s-ATTENDEE-ID" % (x_name), participant["id"])

    if "related_bills" in event:
        for bill in event["related_bills"]:
            if "bill_id" in bill and bill["bill_id"]:
                cal_event.add("%s-RELATED-BILL-ID" % (x_name), bill["bill_id"])

    cal.add_component(cal_event)
    return HttpResponse(cal.to_ical(), content_type="text/calendar")
Exemplo n.º 2
0
def event_ical(request, abbr, event_id):
    event = db.events.find_one({'_id': event_id})
    if event is None:
        raise Http404

    x_name = "X-BILLY"

    cal = Calendar()
    cal.add('prodid', '-//Open States//billy//')
    cal.add('version', billy.__version__)

    cal_event = Event()
    cal_event.add('summary', event['description'])
    cal_event['uid'] = "%s@%s" % (event['_id'], get_domain())
    cal_event.add('priority', 5)
    cal_event.add('dtstart', event['when'])
    cal_event.add('dtend', (event['when'] + datetime.timedelta(hours=1)))
    cal_event.add('dtstamp', event['updated_at'])

    if "participants" in event:
        for participant in event['participants']:
            name = participant['participant']
            cal_event.add('attendee', name)
            if "id" in participant and participant['id']:
                cal_event.add("%s-ATTENDEE-ID" % (x_name), participant['id'])

    if "related_bills" in event:
        for bill in event['related_bills']:
            if "bill_id" in bill and bill['bill_id']:
                cal_event.add("%s-RELATED-BILL-ID" % (x_name), bill['bill_id'])

    cal.add_component(cal_event)
    return HttpResponse(cal.to_ical(), content_type="text/calendar")
Exemplo n.º 3
0
    def gcal_string(self):

        dt_format = "%Y%m%dT%H%M%SZ"
        start_date = self['when'].strftime(dt_format)
        duration = datetime.timedelta(hours=1)
        end_data = (self['when'] + duration)
        end_date = end_data.strftime(dt_format)

        gcal_info = {
            "action": "TEMPLATE",
            "text": self['description'].encode('utf-8'),
            "dates": "%s/%s" % (start_date, end_date),
            "details": "",
            "location": self['location'].encode('utf-8'),
            "trp": "false",
            "sprop": "http://%s/" % get_domain(),
            "sprop": "name:billy"
        }
        gcal_string = urllib.urlencode(gcal_info)
        return gcal_string
Exemplo n.º 4
0
Arquivo: events.py Projeto: ybv/billy
    def gcal_string(self):

        dt_format = "%Y%m%dT%H%M%SZ"
        start_date = self['when'].strftime(dt_format)
        duration = datetime.timedelta(hours=1)
        end_data = (self['when'] + duration)
        end_date = end_data.strftime(dt_format)

        gcal_info = {
            "action": "TEMPLATE",
            "text": self['description'].encode('utf-8'),
            "dates": "%s/%s" % (start_date, end_date),
            "details": "",
            "location": self['location'].encode('utf-8'),
            "trp": "false",
            "sprop": "http://%s/" % get_domain(),
            "sprop": "name:billy"
        }
        gcal_string = urllib.urlencode(gcal_info)
        return gcal_string
Exemplo n.º 5
0
 def title(self, obj):
     s = u"{0}: {1} legislative events."
     return s.format(get_domain(), obj.display_name())
Exemplo n.º 6
0
 def title(self, obj):
     s = u"{0}: Votes by {1}."
     return s.format(get_domain(), obj.display_name())
Exemplo n.º 7
0
 def title(self, obj):
     s = u"{0}: News stories mentioning {1}."
     return s.format(get_domain(), obj.display_name())
Exemplo n.º 8
0
 def title(self, obj):
     s = u"{0}: Votes by {1}."
     return s.format(get_domain(), obj.display_name())
Exemplo n.º 9
0
 def title(self, obj):
     s = u"{0}: News stories mentioning {1}."
     return s.format(get_domain(), obj.display_name())
Exemplo n.º 10
0
 def title(self, obj):
     s = u"{0}: {1} legislative events."
     return s.format(get_domain(), obj.display_name())