From 96459324d6682525cc5188027ff088316dd444c4 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Thu, 19 Sep 2019 22:07:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8C=BA=E5=9F=9F=E4=BA=8C=E7=BB=B4=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- groups/migrations/0001_initial.py | 1 - .../migrations/0268_merge_20190919_1423.py | 14 ++++++++++++++ safesite/migrations/0269_auto_20190919_1423.py | 18 ++++++++++++++++++ safesite/templates/observe.html | 2 +- safesite/templates/observedetail.html | 5 ++++- safesite/views.py | 16 +++++++++------- 6 files changed, 46 insertions(+), 10 deletions(-) create mode 100644 safesite/migrations/0268_merge_20190919_1423.py create mode 100644 safesite/migrations/0269_auto_20190919_1423.py diff --git a/groups/migrations/0001_initial.py b/groups/migrations/0001_initial.py index 5da27209..904a0432 100644 --- a/groups/migrations/0001_initial.py +++ b/groups/migrations/0001_initial.py @@ -8,7 +8,6 @@ class Migration(migrations.Migration): initial = True dependencies = [ - ('safesite', '0269_auto_20190919_1409'), ] operations = [ diff --git a/safesite/migrations/0268_merge_20190919_1423.py b/safesite/migrations/0268_merge_20190919_1423.py new file mode 100644 index 00000000..e03d23ed --- /dev/null +++ b/safesite/migrations/0268_merge_20190919_1423.py @@ -0,0 +1,14 @@ +# Generated by Django 2.1.5 on 2019-09-19 14:23 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('safesite', '0267_auto_20190917_1543'), + ('safesite', '0265_auto_20190917_1716'), + ] + + operations = [ + ] diff --git a/safesite/migrations/0269_auto_20190919_1423.py b/safesite/migrations/0269_auto_20190919_1423.py new file mode 100644 index 00000000..897971a2 --- /dev/null +++ b/safesite/migrations/0269_auto_20190919_1423.py @@ -0,0 +1,18 @@ +# Generated by Django 2.1.5 on 2019-09-19 14:23 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('safesite', '0268_merge_20190919_1423'), + ] + + operations = [ + migrations.AddField( + model_name='observe', + name='lookers', + field=models.ManyToManyField(related_name='gcrs', to='safesite.User'), + ), + ] diff --git a/safesite/templates/observe.html b/safesite/templates/observe.html index 997550e3..12dbfe57 100644 --- a/safesite/templates/observe.html +++ b/safesite/templates/observe.html @@ -101,7 +101,7 @@ { field: 'lookplace', title: '观察地点', width: 150 }, { field: 'actname', title: '作业名称', width: 200 }, { field: 'looktime', title: '观察时间', width: 200 }, - { field: 'looker__name', title: '观察人', width: 200 }, + { field: 'looker__name', title: '观察记录人', width: 200 }, { field: 'lookeder', title: '被观察对象', width: 200 }, { field: 'otherunsafe', title: '过程和交流记录', width: 300 }, ]] diff --git a/safesite/templates/observedetail.html b/safesite/templates/observedetail.html index 68e05d24..1bbf1cf5 100644 --- a/safesite/templates/observedetail.html +++ b/safesite/templates/observedetail.html @@ -14,7 +14,10 @@ 所属部门:{{lookpart__partname}} - 观察人:{{looker__name}} + 观察人记录人:{{looker__name}} + + + 观察人员:{{lookers}} 开始时间:{{looktime| dateFormat 'yyyy-MM-dd hh:mm'}} diff --git a/safesite/views.py b/safesite/views.py index 631173d2..fd426a0a 100644 --- a/safesite/views.py +++ b/safesite/views.py @@ -2542,11 +2542,12 @@ def gchandle(req): obj.usecomp = Partment.objects.get(partid=companyid) if 'lookimg' in gcdata: obj.lookimg = '?'.join(gcdata['lookimg']) - ulist=gcdata['lookers'].split(',') - for i in ulist: - x=User.objects.get(userid=i) - obj.lookers.add(x) obj.save() + if 'lookers' in gcdata: + ulist=gcdata['lookers'].split(',') + for i in ulist: + x=User.objects.get(userid=i) + obj.lookers.add(x) if 'unsafe' in gcdata: olist = gcdata['unsafe'] for i in olist: @@ -2625,9 +2626,10 @@ def gchandle(req): x['lookimg'] = x['lookimg'].split('?') else: x['lookimg']=[] - for key in x: - if x[key] == None: - x[key] = '' + x['lookers']=[] + for i in a[0].lookers.all(): + x['lookers'].append(i.name) + x['lookers']=','.join(x['lookers']) Observeto.objects.get_or_create(observe=a[0], user=User.objects.get(userid=req.session['userid']),defaults={'read': 1}) return HttpResponse(json.dumps(x,cls=MyEncoder),content_type="application/json") elif a == 'getdics':