def jsondump_occurences_old(occurrences, user): occ_list = [] for occ in occurrences: original_id = occ.id occ.id = encode_occurrence(occ) if occ.start.time().__str__() == '00:00:00' and occ.end.time().__str__( ) == '00:00:00': occ.allday = True else: occ.allday = False occ.start = occ.start.__str__() occ.end = occ.end.__str__() occ.recurring = bool(occ.event.rule) occ.persisted = bool(original_id) occ.description = occ.description.replace( '\n', '\\n') # this can be multiline if occ.manager: occ.url = reverse("edit_calendar_event") + "?id=" + occ.id else: occ.url = '' occ.author = User.objects.get(pk=occ.event.creator_id).get_full_name() occ_list.append(occ) rnd = loader.get_template('calendars/occurrences_json.html') resp = rnd.render(Context({'occurrences': occ_list})) return resp
def occurrences_to_json(request, occurrences, user): occ_list = [] for occ in occurrences: original_id = occ.id occ_list.append({ 'id': encode_occurrence(occ), 'title': occ.title, 'start': occ.start.isoformat(), 'end': occ.end.isoformat(), 'recurring': bool(occ.event.rule), 'persisted': bool(original_id), 'description': occ.description.replace('\n', '\\n'), 'allDay': False, 'cancelled': occ.cancelled, 'event_options': short( render_to_string("myagenda/event_options_wrapper.html", {'occ': occ}, context_instance=RequestContext(request))), }) return simplejson.dumps(occ_list)
def jsondump_occurences(occurrences, user): occ_list = [] for occ in occurrences: ed = {} ed['id'] = encode_occurrence(occ) ed['calendar_id'] = occ.calendar_id ed['calendar_name'] = occ.calendar_name if occ.start.time().__str__() == '00:00:00' and occ.end.time().__str__( ) == '00:00:00': ed['allday'] = True else: ed['allday'] = False ed['title'] = occ.title ed['start'] = occ.start.__str__() ed['end'] = occ.end.__str__() ed['description'] = "<br />".join(occ.description.split("\n")) if occ.manager or occ.event.creator == user: ed['editable'] = True ed['url'] = reverse( "edit_calendar_event") + "?id=" + encode_occurrence(occ) else: ed['url'] = '' ed['editable'] = False ed['author'] = User.objects.get( pk=occ.event.creator_id).get_full_name() ed['location'] = occ.details.location if occ.details.bgcolor: ed['backgroundColor'] = occ.details.bgcolor elif occ.details.category: ed['backgroundColor'] = occ.details.category.bgcolor ed['category'] = occ.details.category.name else: ed['backgroundColor'] = False ed['category'] = '' occ_list.append(ed) rnd = loader.get_template('calendars/occurrences_json.html') resp = rnd.render(Context({'occurrences': occ_list})) return resp
def jsondump_occurences(occurrences, user): occ_list = [] for occ in occurrences: ed = {} ed['id'] = encode_occurrence(occ) ed['calendar_id'] = occ.calendar_id ed['calendar_name'] = occ.calendar_name if occ.start.time().__str__() == '00:00:00' and occ.end.time().__str__() == '00:00:00': ed['allday'] = True else: ed['allday'] = False ed['title'] = occ.title ed['start'] = occ.start.__str__() ed['end'] = occ.end.__str__() ed['description'] = "<br />".join(occ.description.split("\n")) if occ.manager or occ.event.creator == user: ed['editable'] = True ed['url'] = reverse( "edit_calendar_event") + "?id=" + encode_occurrence(occ) else: ed['url'] = '' ed['editable'] = False ed['author'] = User.objects.get( pk=occ.event.creator_id).get_full_name() ed['location'] = occ.details.location if occ.details.bgcolor: ed['backgroundColor'] = occ.details.bgcolor elif occ.details.category: ed['backgroundColor'] = occ.details.category.bgcolor ed['category'] = occ.details.category.name else: ed['backgroundColor'] = False ed['category'] = '' occ_list.append(ed) rnd = loader.get_template('calendars/occurrences_json.html') resp = rnd.render(Context({'occurrences': occ_list})) return resp
def jsondump_occurences_old(occurrences, user): occ_list = [] for occ in occurrences: original_id = occ.id occ.id = encode_occurrence(occ) if occ.start.time().__str__() == '00:00:00' and occ.end.time().__str__() == '00:00:00': occ.allday = True else: occ.allday = False occ.start = occ.start.__str__() occ.end = occ.end.__str__() occ.recurring = bool(occ.event.rule) occ.persisted = bool(original_id) occ.description = occ.description.replace( '\n', '\\n') # this can be multiline if occ.manager: occ.url = reverse("edit_calendar_event") + "?id=" + occ.id else: occ.url = '' occ.author = User.objects.get(pk=occ.event.creator_id).get_full_name() occ_list.append(occ) rnd = loader.get_template('calendars/occurrences_json.html') resp = rnd.render(Context({'occurrences': occ_list})) return resp