質問編集履歴

2

index.htmlを追記いたします

2020/02/23 06:25

投稿

ponitaro
ponitaro

スコア5

test CHANGED
File without changes
test CHANGED
@@ -8,10 +8,6 @@
8
8
 
9
9
  ソースコードの一部は下記のとおりです。恐縮ですが、errorの解決方法についてご教授いただけたら幸いです。
10
10
 
11
-
12
-
13
-
14
-
15
11
  図-1 アプリ画面
16
12
 
17
13
  ![イメージ説明](419cd2758cdd4dfed76b20e708f168fc.png)
@@ -28,8 +24,6 @@
28
24
 
29
25
  (views.py)
30
26
 
31
-
32
-
33
27
  ```
34
28
 
35
29
  @login_required
@@ -38,35 +32,157 @@
38
32
 
39
33
 
40
34
 
41
-
35
+ if request.method =='POST':
36
+
37
+ if request.POST['mode']=='__workrequest_recognition__':
38
+
39
+ gps=workrequest.objects.filter(worker=request.user)
40
+
41
+ workrequests=[]
42
+
43
+ for item in gps:
44
+
45
+ workrequests.append(item.id)
46
+
47
+ workrequestsanswer=[]
48
+
49
+ for item in workrequests:
50
+
51
+ aa=request.POST['workrequest_recognitionform'+str(item)]
52
+
53
+ workrequestsanswer.append(literal_eval(aa))
54
+
55
+ yeslist=[]
56
+
57
+ nolist=[]
58
+
59
+ for item in workrequestsanswer:
60
+
61
+ if item[0]=='yes':
62
+
63
+ yeslist.append(item[1])
64
+
65
+ else:
66
+
67
+ nolist.append(item[1])
68
+
69
+ yeswork=workrequest.objects.filter(id__in=yeslist)
70
+
71
+ for item in yeswork:
72
+
73
+ owner=item.worker
74
+
75
+ genre=item.genre
76
+
77
+ overview=item.overview
78
+
79
+ priority=item.priority
80
+
81
+ start_time=item.start_time
82
+
83
+ end_time=item.end_time
84
+
85
+ obj=work(owner=owner,genre=genre,overview=overview,priority=priority,start_time=start_time,end_time=end_time)
86
+
87
+ obj.save()
88
+
89
+ for item in yeswork:
90
+
91
+ requester=item.requester
92
+
93
+ worker=item.worker
94
+
95
+ genre=item.genre
96
+
97
+ overview=item.overview
98
+
99
+ priority=item.priority
100
+
101
+ start_time=item.start_time
102
+
103
+ end_time=item.end_time
104
+
105
+ yesorno='の依頼は受理されました'
106
+
107
+ objj=workrequestresponse(requester=requester,worker=worker,genre=genre,overview=overview,priority=priority,start_time=start_time,end_time=end_time,yesorno=yesorno)
108
+
109
+ objj.save()
110
+
111
+ yeswork.delete()
112
+
113
+ nowork=workrequest.objects.filter(id__in=nolist)
114
+
115
+ for item in nowork:
116
+
117
+ requester=item.requester
118
+
119
+ worker=item.worker
120
+
121
+ genre=item.genre
122
+
123
+ overview=item.overview
124
+
125
+ priority=item.priority
126
+
127
+ start_time=item.start_time
128
+
129
+ end_time=item.end_time
130
+
131
+ yesorno='の依頼は拒否されました'
132
+
133
+ objj=workrequestresponse(requester=requester,worker=worker,genre=genre,overview=overview,priority=priority,start_time=start_time,end_time=end_time,yesorno=yesorno)
134
+
135
+ objj.save()
136
+
137
+ nowork.delete()
138
+
139
+ return redirect(to='yoteihyo/')
140
+
141
+
142
+
143
+
42
144
 
43
145
 
44
146
 
147
+ if request.POST['mode']=='__workrequest_responseform__':
148
+
45
- if request.method =='POST':
149
+ if request.POST['yesorno']=='yes':
150
+
46
-
151
+ ccc=workrequestresponse.objects.filter(requester=request.user)
152
+
153
+ ccc.delete()
154
+
155
+ return redirect(to='yoteihyo/')
156
+
157
+
158
+
159
+
160
+
161
+
162
+
47
- if request.POST['mode']=='__workrequest_recognition__':
163
+ if request.POST['mode']=='__group_request_recognition__':
48
-
164
+
49
- gps=workrequest.objects.filter(worker=request.user)
165
+ ggg=group_request.objects.filter(groupowner=request.user)
50
-
166
+
51
- workrequests=[]
167
+ grouprequests=[]
52
-
168
+
53
- for item in gps:
169
+ for item in ggg:
54
-
170
+
55
- workrequests.append(item.id)
171
+ grouprequests.append(item.id)
56
-
172
+
57
- workrequestsanswer=[]
173
+ grouprequestsanswer=[]
58
-
174
+
59
- for item in workrequests:
175
+ for item in grouprequests:
60
-
176
+
61
- aa=request.POST['workrequest_recognitionform'+str(item)]
177
+ aa=request.POST['group_request_recognitionform'+str(item)]
62
-
178
+
63
- workrequestsanswer.append(literal_eval(aa))
179
+ grouprequestsanswer.append(literal_eval(aa))
64
180
 
65
181
  yeslist=[]
66
182
 
67
- nolist=[]
183
+ nolist=[]
68
-
184
+
69
- for item in workrequestsanswer:
185
+ for item in grouprequestsanswer:
70
186
 
71
187
  if item[0]=='yes':
72
188
 
@@ -76,314 +192,356 @@
76
192
 
77
193
  nolist.append(item[1])
78
194
 
79
- yeswork=workrequest.objects.filter(id__in=yeslist)
195
+ yeswork=group_request.objects.filter(id__in=yeslist)
80
196
 
81
197
  for item in yeswork:
82
198
 
83
- owner=item.worker
199
+ user=item.owner
84
-
200
+
85
- genre=item.genre
201
+ group=item.groupname
86
-
87
- overview=item.overview
202
+
88
-
89
- priority=item.priority
90
-
91
- start_time=item.start_time
203
+ obj=groupmember(user=user, group=group)
92
-
93
- end_time=item.end_time
94
-
95
- obj=work(owner=owner,genre=genre,overview=overview,priority=priority,start_time=start_time,end_time=end_time)
96
204
 
97
205
  obj.save()
98
206
 
207
+ """いまここ"""
208
+
99
209
  for item in yeswork:
100
210
 
101
- requester=item.requester
102
-
103
- worker=item.worker
211
+ owner=item.owner
104
-
105
- genre=item.genre
212
+
106
-
107
- overview=item.overview
213
+ groupowner=item.groupowner
108
-
214
+
109
- priority=item.priority
215
+ groupid=item.groupid
110
-
111
- start_time=item.start_time
216
+
112
-
113
- end_time=item.end_time
217
+ groupname=item.groupname
114
-
218
+
115
- yesorno='の依頼は受理されました'
219
+ yesorno='グループ入会申請は受理されました'
116
-
220
+
117
- objj=workrequestresponse(requester=requester,worker=worker,genre=genre,overview=overview,priority=priority,start_time=start_time,end_time=end_time,yesorno=yesorno)
221
+ objj=group_requestresponse(owner=owner, groupowner=groupowner, groupid=groupid, groupname=groupname, yesorno=yesorno)
118
222
 
119
223
  objj.save()
120
224
 
121
225
  yeswork.delete()
122
226
 
123
- nowork=workrequest.objects.filter(id__in=nolist)
227
+ nowork=group_request.objects.filter(id__in=nolist)
124
228
 
125
229
  for item in nowork:
126
230
 
127
- requester=item.requester
128
-
129
- worker=item.worker
231
+ owner=item.owner
130
-
131
- genre=item.genre
232
+
132
-
133
- overview=item.overview
233
+ groupowner=item.groupowner
134
-
234
+
135
- priority=item.priority
235
+ groupid=item.groupid
136
-
137
- start_time=item.start_time
236
+
138
-
139
- end_time=item.end_time
237
+ groupname=item.groupname
140
-
238
+
141
- yesorno='の依頼は拒否されました'
239
+ yesorno='グループ入会申請は拒否されました'
142
-
240
+
143
- objj=workrequestresponse(requester=requester,worker=worker,genre=genre,overview=overview,priority=priority,start_time=start_time,end_time=end_time,yesorno=yesorno)
241
+ objj=group_requestresponse(owner=owner, groupowner=groupowner, groupid=groupid, groupname=groupname, yesorno=yesorno)
144
242
 
145
243
  objj.save()
146
244
 
147
- nowork.delete()
245
+ nowork.delete()
148
246
 
149
247
  return redirect(to='yoteihyo/')
150
248
 
249
+
250
+
151
-
251
+ if request.POST['mode']=='__grouprequest_responseform__':
252
+
253
+ if request.POST['yesorno']=='yes':
254
+
255
+ ccc=group_requestresponse.objects.filter(requester=request.user)
256
+
257
+ ccc.delete()
258
+
259
+ return redirect(to='yoteihyo/')
260
+
261
+
262
+
263
+
264
+
265
+ else:
152
266
 
153
267
 
154
268
 
269
+ Workrequest_recognition='2'
270
+
271
+ schedulekari=work.objects.filter(owner=request.user)
272
+
273
+ schedules = schedulekari.order_by('start_time')
274
+
275
+ time_schedule = TimeScheduleBS4(step=10, minute_height=0.5)
276
+
277
+ time_schedule= mark_safe(time_schedule.format_schedule(schedules) )
278
+
279
+ """仕事リクエスト処理"""
280
+
281
+ gps=workrequest.objects.filter(worker=request.user)
282
+
283
+ workrequests=[]
284
+
285
+ for item in gps:
286
+
287
+ workrequests.append(item.id)
288
+
289
+ Workrequest_recognition=workrequest_recognition(workrequests)
290
+
291
+
292
+
293
+
294
+
295
+
296
+
297
+ requestresponsecount=workrequestresponse.objects.filter(requester=request.user).count()
298
+
299
+ if requestresponsecount>0:
300
+
301
+ requestresponsehtml=workrequestresponse.objects.filter(requester=request.user)
302
+
303
+ requestresponseform=workrequest_responseform()
304
+
305
+
306
+
307
+ else:
308
+
309
+ requestresponsehtml='仕事依頼に対する返信はありません'
310
+
311
+ requestresponseform=' '
312
+
313
+
314
+
315
+
316
+
317
+ ggg=group_request.objects.filter(groupowner=request.user)
318
+
319
+ grouprequests=[]
320
+
321
+ for item in ggg:
322
+
323
+ grouprequests.append(item.id)
324
+
325
+ Grouprequest_recognition=group_request_recognition(grouprequests)
326
+
327
+
328
+
329
+ grouprequestresponsecount=group_requestresponse.objects.filter(owner=request.user).count()
330
+
331
+ if grouprequestresponsecount>0:
332
+
333
+ grouprequestresponsehtml=group_requestresponse.objects.filter(owner=request.user)
334
+
335
+ grouprequestresponseform=group_request_responseform()
336
+
337
+
338
+
339
+ else:
340
+
341
+ grouprequestresponsehtml='仕事依頼に対する返信はありません'
342
+
343
+ grouprequestresponseform=' '
344
+
155
345
 
156
346
 
347
+ params={
348
+
349
+ 'getdata': Workrequest_recognition,
350
+
351
+ 'time_schedule': time_schedule,
352
+
353
+ 'requestresponsehtml':requestresponsehtml,
354
+
157
- if request.POST['mode']=='__workrequest_responseform__':
355
+ 'requestresponseform':requestresponseform,
158
-
356
+
159
- if request.POST['yesorno']=='yes':
357
+ 'Grouprequest_recognition':Grouprequest_recognition,
358
+
160
-
359
+ 'grouprequestresponsehtml':grouprequestresponsehtml,
360
+
161
- ccc=workrequestresponse.objects.filter(requester=request.user)
361
+ 'grouprequestresponseform':grouprequestresponseform
162
-
163
- ccc.delete()
362
+
164
-
165
- return redirect(to='yoteihyo/')
166
-
167
-
168
-
169
-
170
-
171
-
172
-
173
- if request.POST['mode']=='__group_request_recognition__':
174
-
175
- ggg=group_request.objects.filter(groupowner=request.user)
176
-
177
- grouprequests=[]
178
-
179
- for item in ggg:
180
-
181
- grouprequests.append(item.id)
182
-
183
- grouprequestsanswer=[]
184
-
185
- for item in grouprequests:
186
-
187
- aa=request.POST['group_request_recognitionform'+str(item)]
188
-
189
- grouprequestsanswer.append(literal_eval(aa))
190
-
191
- yeslist=[]
192
-
193
- nolist=[]
194
-
195
- for item in grouprequestsanswer:
196
-
197
- if item[0]=='yes':
198
-
199
- yeslist.append(item[1])
200
-
201
- else:
363
+ }
202
-
203
- nolist.append(item[1])
204
-
205
- yeswork=group_request.objects.filter(id__in=yeslist)
206
-
207
- for item in yeswork:
208
-
209
- user=item.owner
210
-
211
- group=item.groupname
212
-
213
- obj=groupmember(user=user, group=group)
214
-
215
- obj.save()
216
-
217
- """いまここ"""
218
-
219
- for item in yeswork:
220
-
221
- owner=item.owner
222
-
223
- groupowner=item.groupowner
224
-
225
- groupid=item.groupid
226
-
227
- groupname=item.groupname
228
-
229
- yesorno='グループ入会の申請は受理されました'
230
-
231
- objj=group_requestresponse(owner=owner, groupowner=groupowner, groupid=groupid, groupname=groupname, yesorno=yesorno)
232
-
233
- objj.save()
234
-
235
- yeswork.delete()
236
-
237
- nowork=group_request.objects.filter(id__in=nolist)
238
-
239
- for item in nowork:
240
-
241
- owner=item.owner
242
-
243
- groupowner=item.groupowner
244
-
245
- groupid=item.groupid
246
-
247
- groupname=item.groupname
248
-
249
- yesorno='グループ入会の申請は拒否されました'
250
-
251
- objj=group_requestresponse(owner=owner, groupowner=groupowner, groupid=groupid, groupname=groupname, yesorno=yesorno)
252
-
253
- objj.save()
254
-
255
- nowork.delete()
256
-
257
- return redirect(to='yoteihyo/')
258
364
 
259
365
 
260
366
 
261
- if request.POST['mode']=='__grouprequest_responseform__':
367
+
262
-
263
- if request.POST['yesorno']=='yes':
368
+
264
-
265
- ccc=group_requestresponse.objects.filter(requester=request.user)
266
-
267
- ccc.delete()
268
-
269
- return redirect(to='yoteihyo/')
369
+ return render(request, 'schedule_app/index.html', params)
370
+
270
-
371
+ ```
372
+
271
-
373
+ index.html
374
+
375
+ ```
376
+
377
+ {% extends 'base.html' %}
378
+
379
+ {% block content %}
380
+
381
+ <style>
382
+
383
+ .minute-wrapper {
384
+
385
+ border: 1px solid #eceeef;
386
+
387
+ }
388
+
389
+
390
+
391
+ .hour-name {
392
+
393
+ padding: 5px;
394
+
395
+ text-align: right;
396
+
397
+ border: 1px solid #eceeef;
398
+
399
+ }
400
+
401
+
402
+
403
+ .just-hour {
404
+
405
+ border-top: 1px solid #eceeef;
406
+
407
+ }
408
+
409
+ </style>
410
+
411
+ <div class="container">
412
+
413
+ <div class="row mt-5">
414
+
415
+ <div class="col-sm-4">
416
+
417
+ {{ time_schedule }}
272
418
 
273
419
 
274
420
 
275
-
276
-
277
-
278
-
279
-
280
-
281
- else:
282
-
283
-
284
-
285
- Workrequest_recognition='2'
286
-
287
- schedulekari=work.objects.filter(owner=request.user)
288
-
289
- schedules = schedulekari.order_by('start_time')
290
-
291
- time_schedule = TimeScheduleBS4(step=10, minute_height=0.5)
292
-
293
- time_schedule= mark_safe(time_schedule.format_schedule(schedules) )
294
-
295
- """仕事リクエスト処理"""
296
-
297
- gps=workrequest.objects.filter(worker=request.user)
298
-
299
- workrequests=[]
300
-
301
- for item in gps:
302
-
303
- workrequests.append(item.id)
304
-
305
- Workrequest_recognition=workrequest_recognition(workrequests)
306
-
307
-
308
-
309
-
310
-
311
- """仕事リクエスト承認処理"""
312
-
313
- requestresponsecount=workrequestresponse.objects.filter(requester=request.user).count()
314
-
315
- if requestresponsecount>0:
316
-
317
- requestresponsehtml=workrequestresponse.objects.filter(requester=request.user)
318
-
319
- requestresponseform=workrequest_responseform()
320
-
321
-
322
-
323
- else:
324
-
325
- requestresponsehtml='仕事依頼に対する返信はありません'
326
-
327
- requestresponseform=' '
328
-
329
-
330
-
331
- """グループリクエスト処理"""
332
-
333
- ggg=group_request.objects.filter(groupowner=request.user)
334
-
335
- grouprequests=[]
336
-
337
- for item in ggg:
338
-
339
- grouprequests.append(item.id)
340
-
341
- Grouprequest_recognition=group_request_recognition(grouprequests)
342
-
343
-
344
-
345
- """グループリクエスト承認処理"""
346
-
347
- grouprequestresponsecount=group_requestresponse.objects.filter(owner=request.user).count()
348
-
349
- if grouprequestresponsecount>0:
350
-
351
- grouprequestresponsehtml=group_requestresponse.objects.filter(owner=request.user)
352
-
353
- grouprequestresponseform=group_request_responseform()
354
-
355
-
356
-
357
- else:
358
-
359
- grouprequestresponsehtml='仕事依頼に対する返信はありません'
360
-
361
- grouprequestresponseform=' '
362
-
363
-
364
-
365
- params={
366
-
367
- 'getdata': Workrequest_recognition,
368
-
369
- 'time_schedule': time_schedule,
370
-
371
- 'requestresponsehtml':requestresponsehtml,
372
-
373
- 'requestresponseform':requestresponseform,
374
-
375
- 'Grouprequest_recognition':Grouprequest_recognition,
376
-
377
- 'grouprequestresponsehtml':grouprequestresponsehtml,
378
-
379
- 'grouprequestresponseform':grouprequestresponseform
380
-
381
- }
382
-
383
-
384
-
385
-
386
-
387
- return render(request, 'schedule_app/index.html', params)
421
+ </div>
422
+
423
+ <div class="col-sm-4 bg-info text-white">
424
+
425
+ <form action="{% url 'index' %}" method="post">
426
+
427
+ {% csrf_token %}
428
+
429
+ {{ getdata.as_table }}
430
+
431
+ <tr><td></td><td><input type="submit" value="click"></td></tr>
432
+
433
+ </form>
434
+
435
+ </div>
436
+
437
+ <div class="col-sm-4 bg-info text-white">
438
+
439
+ <form action="{% url 'index' %}" method="post">
440
+
441
+ {% csrf_token %}
442
+
443
+ {{ Grouprequest_recognition.as_table }}
444
+
445
+ <tr><td></td><td><input type="submit" value="click"></td></tr>
446
+
447
+ </form>
448
+
449
+ </div>
450
+
451
+ </div><!-- /.row -->
452
+
453
+ <div class="row mt-4">
454
+
455
+ <div class="col-sm-8 bg-info text-white">
456
+
457
+ {%for item in requestresponsehtml%}
458
+
459
+ <tr>
460
+
461
+ <td>{{item}}</td>
462
+
463
+ <tr>
464
+
465
+ {% endfor %}
466
+
467
+ </div>
468
+
469
+ <div class="col-sm-4 bg-info text-white">
470
+
471
+ <form action="{% url 'index' %}" method="post">
472
+
473
+ {% csrf_token %}
474
+
475
+ {{ requestresponseform }}
476
+
477
+ <tr><td></td><td><input type="submit" value="click"></td></tr>
478
+
479
+ </form>
480
+
481
+ </div><!-- /.row -->
482
+
483
+
484
+
485
+ <div class="row mt-4">
486
+
487
+ <div class="col-sm-8 bg-info text-white">
488
+
489
+ {%for item in grouprequestresponsehtml%}
490
+
491
+ <tr>
492
+
493
+ <td>{{item}}</td>
494
+
495
+ <tr>
496
+
497
+ {% endfor %}
498
+
499
+ </div>
500
+
501
+ <div class="col-sm-4 bg-info text-white">
502
+
503
+ <form action="{% url 'index' %}" method="post">
504
+
505
+ {% csrf_token %}
506
+
507
+ {{grouprequestresponseform}}
508
+
509
+ <tr><td></td><td><input type="submit" value="click"></td></tr>
510
+
511
+ </form>
512
+
513
+ </div><!-- /.row -->
514
+
515
+
516
+
517
+ <div class="row mt-2">
518
+
519
+ <div class="col-sm-4">
520
+
521
+ <P><a href="{% url 'newwork' %}">予定の追加</a></P>
522
+
523
+ </div>
524
+
525
+ <div class="col-sm-4">
526
+
527
+ <P><a href="{% url 'newworkrequest' %}">仕事リクエスト作成</a></P>
528
+
529
+ </div>
530
+
531
+ <div class="col-sm-4">
532
+
533
+ <P><a href="{% url 'makeorapplygroup' %}">グループ作成、申請</a></P>
534
+
535
+ </div>
536
+
537
+ </div><!-- /.row -->
538
+
539
+ </div><!-- /.container -->
540
+
541
+ {% endblock %}
542
+
543
+
544
+
545
+
388
546
 
389
547
  ```

1

ご指摘いただき誠にありがとうございます。コード部分を```で囲みました。```で囲まないとコードとして認識されないのですね。これから気を付けます。

2020/02/23 06:25

投稿

ponitaro
ponitaro

スコア5

test CHANGED
File without changes
test CHANGED
@@ -30,6 +30,8 @@
30
30
 
31
31
 
32
32
 
33
+ ```
34
+
33
35
  @login_required
34
36
 
35
37
  def mainpage(request):
@@ -383,3 +385,5 @@
383
385
 
384
386
 
385
387
  return render(request, 'schedule_app/index.html', params)
388
+
389
+ ```