def program_layer_save_layer_text(self, visiting_group_id='', booking_day_id='', bucket_time='', layer_text_id='', text='', title=''): is_new = (layer_text_id=='') if is_new: id = genUID(type='program_layer_text') #...if slot_id is none, we need to figure out slot_id of bucket_time OR we simply save bucket_time layer_text = dict(type='program_layer_text', subtype='layer_text', state=0, booking_day_id=booking_day_id, bucket_time=bucket_time ) #...populate sheets and computed sheets? layer_text['text'] = text layer_text['title'] = title layer_text['visiting_group_id'] = visiting_group_id holly_couch[id] = layer_text else: layer_text = common_couch.getLayerText(holly_couch, layer_text_id) layer_text['text'] = text layer_text['title'] = title holly_couch[layer_text['_id']] = layer_text # TODO call it bucket text or layer text ? visiting_group = common_couch.getVisitingGroup(holly_couch, visiting_group_id) layer_text['layer_title']=visiting_group['name'] layer_text['layer_colour'] = "#fff" return dict(layer_text=layer_text)
def save_attachment(self, target_id, _id, text, attachment): timestamp = datetime.datetime.now().strftime('%Y-%m-%d %H:%M') if _id == '': attachment_o = dict(type='attachment', _id=genUID(type='attachment'), target_id=target_id, attachment_state=0, tags=list(), history=list(), text='') attachment_change='new' attachment_o['timestamp'] = timestamp else: attachment_o = common_couch.getAttachment(holly_couch, _id) history = attachment_o['history'] if history == None: history = list() else: history.append([timestamp, attachment_o['text']]) attachment_o['history'] = history attachment_change = 'changed' attachment_o['last_changed_by'] = getLoggedInUserId(request) attachment_o['text'] = text holly_couch[attachment_o['_id']] = attachment_o file = request.POST['attachment'] if file != '': holly_couch.put_attachment(attachment_o, attachment.file, filename=attachment.filename) # TODO FIX BELOW #remember_attachment_change(holly_couch, target_id=target_id, attachment_id=attachment_o['_id'], changed_by=getLoggedInUserId(request), attachment_change=attachment_change) # TODO: where do we go from here? redirect_to = '/' if 'visiting_group' in attachment_o['target_id']: redirect_to = '/visiting_group/show_visiting_group?visiting_group_id='+attachment_o['target_id'] raise redirect(redirect_to)
def save_note(self, target_id, _id, text): timestamp = datetime.datetime.now().strftime('%Y-%m-%d %H:%M') if _id == '': note_o = dict(type='note', _id=genUID(type='note'), target_id=target_id, note_state=0, tags=list(), history=list(), text='') note_change='new' note_o['timestamp'] = timestamp else: note_o = common_couch.getNote(holly_couch, _id) history = note_o['history'] if history == None: history = list() else: history.append([timestamp, note_o['text']]) note_o['history'] = history note_change = 'changed' note_o['last_changed_by'] = getLoggedInUserId(request) note_o['text'] = text holly_couch[note_o['_id']] = note_o remember_note_change(holly_couch, target_id=target_id, note_id=note_o['_id'], changed_by=getLoggedInUserId(request), note_change=note_change) # TODO: where do we go from here? redirect_to = '/' if 'visiting_group' in note_o['target_id']: redirect_to = '/visiting_group/show_visiting_group?visiting_group_id='+note_o['target_id'] raise redirect(redirect_to)
def create_living_schema(self): log.info("create_living_schema()") ensurePostRequest(request, __name__) ew_id = genUID(type='living_schema') schema = dict(type='day_schema', subtype='room', title='room schema 2013', activity_group_ids=["activity_groups_ids", "roomgroup.fyrbyn", "roomgroup.vaderstracken", "roomgroup.vindarnashus","roomgroup.tunet", "roomgroup.skrakvik","roomgroup.tc","roomgroup.alphyddorna","roomgroup.gokboet","roomgroup.kojan"]) all_activities = getAllActivities(holly_couch) #...create some living, map to all activities in ag groups house i=0 z=0 tmp_schema = dict() for tmp_act in list(all_activities): if tmp_act.has_key('activity_group_id') or True: if tmp_act.doc['activity_group_id'][:9] == 'roomgroup': z += 1 tmp_id = dict(zorder=z, id=tmp_act['id']) tmp_fm = dict(time_from='00:00:00', time_to='12:00:00', duration='12:00:00', title='FM', slot_id='live_slot.' + str(i) ) i +=1 tmp_em = dict(time_from='12:00:00', time_to='23:59:00', duration='12:00:00', title='EM', slot_id='live_slot.' + str( i) ) #...create fm and em but nothing more i+=1 tmp_schema[tmp_act['id']] = [tmp_id, tmp_fm, tmp_em] schema['schema'] = tmp_schema holly_couch[ew_id] = schema raise redirect(request.referer)
def create_living_schema(self): ew_id = genUID(type="living_schema") schema = dict( type="day_schema", subtype="room", title="room schema 2013", activity_group_ids=[ "activity_groups_ids", "roomgroup.fyrbyn", "roomgroup.vaderstracken", "roomgroup.vindarnashus", "roomgroup.tunet", "roomgroup.skrakvik", "roomgroup.tc", "roomgroup.alphyddorna", "roomgroup.gokboet", "roomgroup.kojan", ], ) all_activities = getAllActivities(holly_couch) # ...create some living, map to all activities in ag groups house i = 0 z = 0 tmp_schema = dict() for tmp_act in list(all_activities): if tmp_act.has_key("activity_group_id") or True: if tmp_act.doc["activity_group_id"][:9] == "roomgroup": z += 1 tmp_id = dict(zorder=z, id=tmp_act["id"]) tmp_fm = dict( time_from="00:00:00", time_to="12:00:00", duration="12:00:00", title="FM", slot_id="live_slot." + str(i), ) i += 1 tmp_em = dict( time_from="12:00:00", time_to="23:59:00", duration="12:00:00", title="EM", slot_id="live_slot." + str(i), ) # ...create fm and em but nothing more i += 1 tmp_schema[tmp_act["id"]] = [tmp_id, tmp_fm, tmp_em] schema["schema"] = tmp_schema holly_couch[ew_id] = schema raise redirect(request.referer)
def save_visiting_group_properties(self, visiting_group_id=None, name='', info='', from_date=None, to_date=None, contact_person='', contact_person_email='', contact_person_phone='', visiting_group_properties=None, camping_location='', boknr='', password='', subtype=''): log.info('save_visiting_group_properties') ensurePostRequest(request, __name__) is_new = ((None == visiting_group_id) or (visiting_group_id == '')) #...this is a hack so we can direct the id of the visiting group for special groups if not is_new: if 'visiting_group' not in visiting_group_id: is_new = True id_c = 'visiting_group.'+visiting_group_id else: id_c = genUID(type='visiting_group') if is_new: # TODO: make sure subtype is in one of if not subtype in ['program','course','staff']: flash('error with subtype') raise redirect(request.referrer) visiting_group_c = dict(type='visiting_group', subtype=subtype, tags=[], boknstatus=0, vodbstatus=0) #...populate sheets and computed sheets? else: id_c = visiting_group_id visiting_group_c = holly_couch[id_c] #visiting_group_c['type'] = 'visiting_group' visiting_group_c['name'] = name visiting_group_c['info'] = cleanHtml(info) ok, ok_from_date = sanitizeDate(from_date) if not ok: # TODO better error handling here flash('error with from-date') raise redirect(request.referrer) visiting_group_c['from_date'] = ok_from_date ok, ok_to_date = sanitizeDate(to_date) if not ok: # TODO: better error handling here flash('error with to-date') raise redirect(request.referrer) visiting_group_c['to_date'] = ok_to_date visiting_group_c['contact_person'] = contact_person visiting_group_c['contact_person_email'] = contact_person_email visiting_group_c['contact_person_phone'] = contact_person_phone # TODO: boknr maybe shouldnt be changeble if program or vodb state has passed by preliminary (10) ? visiting_group_c['boknr'] = boknr # TODO: password for group should be set in special page if password != '': visiting_group_c['password'] = password visiting_group_c['camping_location'] = camping_location #...now we have to update all cached content, so we need all bookings that belong to this visiting group visiting_group_c['visiting_group_properties'] = populatePropertiesAndRemoveUnusedProperties(visiting_group_c, visiting_group_properties) updateBookingsCacheContentAfterPropertyChange(holly_couch, visiting_group_c, getLoggedInUserId(request)) vodb_tag_times_tags = computeAllUsedVisitingGroupsTagsForTagSheet(visiting_group_c['tags'], visiting_group_c.get('vodb_tag_sheet',dict(items=[]))['items']) updateVisitingGroupComputedSheets(visiting_group_c, visiting_group_c['visiting_group_properties'], sheet_map=dict(vodb_eat_sheet=vodb_eat_times_options, vodb_live_sheet=vodb_live_times_options, vodb_tag_sheet=vodb_tag_times_tags)) holly_couch[id_c] = visiting_group_c if visiting_group_c.has_key('visiting_group_id'): raise redirect('/visiting_group/show_visiting_group?visiting_group_id='+visiting_group_c['visiting_group_id']) raise redirect('/visiting_group/view_all')