Exemple #1
0
def activity_table(request):
    form = EducationActivityForm(request.POST, request.FILES)
    if form.is_valid():
        result = form.save()
        try:
            resident = Resident.objects.get(name='群体')
        except Resident.DoesNotExist:
            resident = Resident(name='群体', gender=2, nation='汉族', birthday=timezone.now().date())
        record = WorkRecord(provider=request.user, resident=resident, app_label='education',
                            model_name='EducationActivity', item_id=result.id,
                            evaluation=WorkRecord.SATISFIED, status=WorkRecord.FINISHED)
        service_item = Service.items.get(name=result.act_type)
        record.service_item = service_item
        record.service_item_alias = service_item.alias
        record.save()
        if result.material_type and result.material_num:
            service_item = Service.items.get(name=result.material_type)
            for i in range(result.material_num):
                record = WorkRecord(provider=request.user, resident=resident, app_label='education',
                                    model_name='EducationActivity', item_id=result.id,
                                    evaluation=WorkRecord.SATISFIED, status=WorkRecord.FINISHED)
                record.service_item = service_item
                record.service_item_alias = service_item.alias
                record.save()

        success, message = True, u'健康教育活动记录保存完成'
    else:
        success, message = False, u'健康教育活动数据验证失败'

    return HttpResponse(simplejson.dumps({'success': success, 'message': message}),
                        content_type='text/html; charset=UTF-8')
Exemple #2
0
def service_disposal_post(request, content_form, type_label, item_label):
    form = content_form(request.POST)
    if form.is_valid():
        service_result = form.save()
        record = WorkRecord()
        record.provider = request.user
        record.resident = Resident.objects.get(
            id=int(request.session.get('resident_id')))
        record.service_item = Service.objects.filter(service_type__alias=type_label).\
            get(alias=item_label)
        record.app_label = type_label
        record.model_name = form.Meta.model.__name__  # Test
        record.service_item_alias = item_label
        record.item_id = service_result.id
        record.evaluation = WorkRecord.SATISFIED  # this should be some para from request
        record.submit_time = datetime.now()
        record.status = WorkRecord.FINISHED
        record.save()

        for session_para in [
                'resident_id', 'resident_name', 'service_items_id_highlight'
        ]:
            try:
                request.session[session_para]
            except KeyError:
                pass
            else:
                del request.session[session_para]
        return HttpResponseRedirect(reverse('services:service_grid'))
    else:
        return service_render(request, form, type_label, item_label)
Exemple #3
0
def activity_table(request):
    form = EducationActivityForm(request.POST, request.FILES)
    if form.is_valid():
        result = form.save()
        try:
            resident = Resident.objects.get(name='群体')
        except Resident.DoesNotExist:
            resident = Resident(name='群体',
                                gender=2,
                                nation='汉族',
                                birthday=timezone.now().date())
        record = WorkRecord(provider=request.user,
                            resident=resident,
                            app_label='education',
                            model_name='EducationActivity',
                            item_id=result.id,
                            evaluation=WorkRecord.SATISFIED,
                            status=WorkRecord.FINISHED)
        service_item = Service.items.get(name=result.act_type)
        record.service_item = service_item
        record.service_item_alias = service_item.alias
        record.save()
        if result.material_type and result.material_num:
            service_item = Service.items.get(name=result.material_type)
            for i in range(result.material_num):
                record = WorkRecord(provider=request.user,
                                    resident=resident,
                                    app_label='education',
                                    model_name='EducationActivity',
                                    item_id=result.id,
                                    evaluation=WorkRecord.SATISFIED,
                                    status=WorkRecord.FINISHED)
                record.service_item = service_item
                record.service_item_alias = service_item.alias
                record.save()

        success, message = True, u'健康教育活动记录保存完成'
    else:
        success, message = False, u'健康教育活动数据验证失败'

    return HttpResponse(simplejson.dumps({
        'success': success,
        'message': message
    }),
                        content_type='text/html; charset=UTF-8')