def post(self, request, *args, **kwargs): data=[] print request.POST for _id in request.POST['ids'].split(','): if request.POST[str(_id)+'_!nativeeditor_status']=='inserted': t_obj=TimeTable() t_obj.start_date_time=datetime.datetime.strptime(request.POST[_id+'_start_date'],"%d/%m/%Y %H:%M") t_obj.end_date_time=datetime.datetime.strptime(request.POST[_id+'_end_date'],"%d/%m/%Y %H:%M") t_obj.sid=_id; sub_map_id=int(request.POST[_id+'_text'].split('/')[0]) t_obj.sub_map=SubjectMap.objects.filter(id=sub_map_id)[0] t_obj.save() x=[{'status':'ok','tid':'','type':'inserted','sid':''}] if request.POST[str(_id)+'_!nativeeditor_status']=='updated': t_obj=TimeTable.objects.filter(sid=_id)[0] t_obj.start_date_time=datetime.datetime.strptime(request.POST[_id+'_start_date'],"%d/%m/%Y %H:%M") t_obj.end_date_time=datetime.datetime.strptime(request.POST[_id+'_end_date'],"%d/%m/%Y %H:%M") t_obj.sid=_id; sub_map_id=int(request.POST[_id+'_text'].split('/')[0]) t_obj.sub_map=SubjectMap.objects.filter(id=sub_map_id)[0] t_obj.save() x=[{'status':'ok','tid':'','type':'updated','sid':''}] if request.POST[str(_id)+'_!nativeeditor_status']=='deleted': t_obj=TimeTable.objects.filter(sid=_id)[0].delete() x=[{'status':'ok','tid':'','type':'deleted','sid':''}] x=[{'status':'ok','tid':'','type':'updated','sid':''}] return HttpResponse(json.dumps(x), content_type="application/json")
def post(self, request, *args, **kwargs): table=json.loads(request.body)['data'] for r in range(len(table)): if r==0 or r==1: continue for c in range(len(table[0])): if table[r][c]=='NA' or c==0 or c==1 or c==2 or table[r][c] is None: continue _rdate=datetime.datetime.strptime(table[r][1],"%d/%m/%y").date() _map_id=int(table[r][c].split('(')[1].replace(')','')) _smap=SubjectMap.objects.filter(id=_map_id)[0] if table[0][c].find(EVE_SE_LABEL)>-1: slot=EVE_SE_SLOT #Evening combined else: slot=DAY_SE_SLOT #Day combined exits_entry=TimeTable.objects.filter(date=_rdate,slot_no=slot,sub_map=_smap) #check for a record update case='new' if len(exits_entry)==0: tt_entry=TimeTable() else: tt_entry= exits_entry[0] case='update' #print tt_entry,case,tt_entry.slot_no,tt_entry.sub_map.id,tt_entry.date tt_entry.date=_rdate tt_entry.sub_map=_smap tt_entry.slot_no=slot tt_entry.save() return HttpResponse('saved')
def post(self, request, *args, **kwargs): table = json.loads(request.body)['data'] for r in range(len(table)): if r == 0 or r == 1: continue for c in range(len(table[0])): if table[r][c] == 'NA' or c == 0 or c == 1 or c == 2 or table[ r][c] is None: continue _rdate = datetime.datetime.strptime(table[r][1], "%d/%m/%y").date() _map_id = int(table[r][c].split('(')[1].replace(')', '')) _smap = SubjectMap.objects.filter(id=_map_id)[0] if table[0][c].find(EVE_SE_LABEL) > -1: slot = EVE_SE_SLOT #Evening combined else: slot = DAY_SE_SLOT #Day combined exits_entry = TimeTable.objects.filter(date=_rdate, slot_no=slot, sub_map=_smap) #check for a record update case = 'new' if len(exits_entry) == 0: tt_entry = TimeTable() else: tt_entry = exits_entry[0] case = 'update' #print tt_entry,case,tt_entry.slot_no,tt_entry.sub_map.id,tt_entry.date tt_entry.date = _rdate tt_entry.sub_map = _smap tt_entry.slot_no = slot tt_entry.save() return HttpResponse('saved')
def post(self, request, *args, **kwargs): data = [] print request.POST for _id in request.POST['ids'].split(','): if request.POST[str(_id) + '_!nativeeditor_status'] == 'inserted': t_obj = TimeTable() t_obj.start_date_time = datetime.datetime.strptime( request.POST[_id + '_start_date'], "%d/%m/%Y %H:%M") t_obj.end_date_time = datetime.datetime.strptime( request.POST[_id + '_end_date'], "%d/%m/%Y %H:%M") t_obj.sid = _id sub_map_id = int(request.POST[_id + '_text'].split('/')[0]) t_obj.sub_map = SubjectMap.objects.filter(id=sub_map_id)[0] t_obj.save() x = [{ 'status': 'ok', 'tid': '', 'type': 'inserted', 'sid': '' }] if request.POST[str(_id) + '_!nativeeditor_status'] == 'updated': t_obj = TimeTable.objects.filter(sid=_id)[0] t_obj.start_date_time = datetime.datetime.strptime( request.POST[_id + '_start_date'], "%d/%m/%Y %H:%M") t_obj.end_date_time = datetime.datetime.strptime( request.POST[_id + '_end_date'], "%d/%m/%Y %H:%M") t_obj.sid = _id sub_map_id = int(request.POST[_id + '_text'].split('/')[0]) t_obj.sub_map = SubjectMap.objects.filter(id=sub_map_id)[0] t_obj.save() x = [{'status': 'ok', 'tid': '', 'type': 'updated', 'sid': ''}] if request.POST[str(_id) + '_!nativeeditor_status'] == 'deleted': t_obj = TimeTable.objects.filter(sid=_id)[0].delete() x = [{'status': 'ok', 'tid': '', 'type': 'deleted', 'sid': ''}] x = [{'status': 'ok', 'tid': '', 'type': 'updated', 'sid': ''}] return HttpResponse(json.dumps(x), content_type="application/json")