1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
|
''' -- imports from python libraries -- '''
# from datetime import datetime
''' -- imports from installed packages -- '''
from django.http import HttpResponseRedirect #, HttpResponse uncomment when to use
from django.http import HttpResponse
from django.http import Http404
from django.shortcuts import render_to_response #, render uncomment when to use
from django.template import RequestContext
from django.template import TemplateDoesNotExist
from django.template.loader import render_to_string
from django.core.urlresolvers import reverse
from django.contrib.auth.models import User
from django.contrib.sites.models import Site
from django.contrib.auth.decorators import login_required
from django.template.defaultfilters import slugify
try:
from bson import ObjectId
except ImportError: # old pymongo
from pymongo.objectid import ObjectId
''' -- imports from application folders/files -- '''
from gnowsys_ndf.ndf.models import Node, AttributeType, RelationType
from gnowsys_ndf.ndf.models import node_collection
from gnowsys_ndf.ndf.views.methods import get_node_common_fields, parse_template_data
from gnowsys_ndf.ndf.views.methods import get_property_order_with_value,get_execution_time
from gnowsys_ndf.ndf.views.methods import create_gattribute, create_grelation
from gnowsys_ndf.notification import models as notification
@get_execution_time
def event(request, group_id):
if ObjectId.is_valid(group_id) is False :
group_ins = node_collection.one({'_type': "Group","name": group_id})
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
if group_ins:
group_id = str(group_ins._id)
else :
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
if auth :
group_id = str(auth._id)
else :
pass
#view written just to show the landing page of the events
group_inverse_rel_id = []
Group_type=node_collection.one({'_id':ObjectId(group_id)})
for i in Group_type.relation_set:
if unicode("group_of") in i.keys():
group_inverse_rel_id = i['group_of']
Group_name = node_collection.one({'_type':'GSystem','_id':{'$in':group_inverse_rel_id}})
Eventtype='Eventtype'
if Group_name:
if (any( unicode('has_group') in d for d in Group_name.relation_set)) == True:
Eventtype='CollegeEvents'
else:
Eventtype='Eventtype'
Glisttype=node_collection.find({"_type": "GSystemType", "name":"GList"})
#bug
#Event_Types = node_collection.one({"member_of":ObjectId(Glisttype[0]["_id"]),"name":"Eventtype"},{'collection_set': 1})
#buggy
Event_Types = node_collection.one({"member_of":ObjectId(Glisttype[0]["_id"]),"name":unicode(Eventtype)},{'collection_set': 1})
app_collection_set=[]
Mis_admin_list=[]
#check for the mis group Admin
#check for exam session to be created only by the Mis_Admin
Add=""
Mis_admin=node_collection.one({"_type":"Group","name":"MIS_admin"})
if Mis_admin:
Mis_admin_list=Mis_admin.group_admin
Mis_admin_list.append(Mis_admin.created_by)
if request.user.id in Mis_admin_list:
Add="Allow"
else:
Add= "Stop"
else:
Add="Stop"
if Event_Types:
for eachset in Event_Types.collection_set:
app_collection_set.append(node_collection.one({"_id": eachset}, {'_id': 1, 'name': 1, 'type_of': 1}))
return render_to_response('ndf/event.html',{'app_collection_set':app_collection_set,
'groupid':group_id,
'group_id':group_id,
'group_name':group_id,
'Add':Add
},
context_instance = RequestContext(request)
)
@get_execution_time
def event_detail(request, group_id, app_id=None, app_set_id=None, app_set_instance_id=None):
"""
View for handling Event and it's sub-types detail-view
"""
auth = None
if ObjectId.is_valid(group_id) is False :
group_ins = node_collection.one({'_type': "Group","name": group_id})
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
if group_ins:
group_id = str(group_ins._id)
else :
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
if auth :
group_id = str(auth._id)
else :
pass
session_node = ""
app = None
session_node = ""
'''if app_id is None:
app = node_collection.one({'_type': "GSystemType", 'name': app_name})
if app:
app_id = str(app._id)
else:'''
app = node_collection.one({'_id': ObjectId(app_id)})
#app_name = app.name
app_set = ""
app_collection_set = []
title = ""
marks_enter= ""
session_node = ""
event_gst = None
event_gs = None
reschedule = True
reschedule_time = ""
event_task_date_reschedule = ""
event_task_Attendance_reschedule = ""
marks=""
property_order_list = []
#template_prefix = "mis"
if request.user:
if auth is None:
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username)})
''' agency_type = auth.agency_type
Event_Types = node_collection.one({'_type': "GSystemType", 'name': agency_type}, {'collection_set': 1})
if Event_Types:
for eachset in Event_Types.collection_set:
app_collection_set.append(node_collection.one({"_id": eachset}, {'_id': 1, 'name': 1, 'type_of': 1}))
'''
# for eachset in app.collection_set:
# app_collection_set.append(node_collection.one({"_id":eachset}, {'_id': 1, 'name': 1, 'type_of': 1}))
group_inverse_rel_id = []
Group_type=node_collection.one({'_id':ObjectId(group_id)})
for i in Group_type.relation_set:
if unicode("group_of") in i.keys():
group_inverse_rel_id = i['group_of']
Group_name = node_collection.one({'_type':'GSystem','_id':{'$in':group_inverse_rel_id}})
Eventtype='Eventtype'
if Group_name:
if (any( unicode('has_group') in d for d in Group_name.relation_set)) == True:
Eventtype='CollegeEvents'
else:
Eventtype='Eventtype'
Glisttype=node_collection.find({"name":"GList"})
Event_Types = node_collection.one({"member_of":ObjectId(Glisttype[0]["_id"]),"name":Eventtype},{'collection_set': 1})
app_collection_set=[]
if Event_Types:
for eachset in Event_Types.collection_set:
app_collection_set.append(node_collection.one({"_id": eachset}, {'_id': 1, 'name': 1, 'type_of': 1}))
nodes = None
if app_set_id:
event_gst = node_collection.one({'_type': "GSystemType", '_id': ObjectId(app_set_id)}, {'name': 1, 'type_of': 1})
title = event_gst.name
template = "ndf/event_list.html"
if request.method=="POST":
search = request.POST.get("search","")
classtype = request.POST.get("class","")
# nodes = list(node_collection.find({'name':{'$regex':search, '$options': 'i'},'member_of': {'$all': [event_gst._id]}}))
nodes = node_collection.find({'member_of': event_gst._id, 'name': {'$regex': search, '$options': 'i'}})
else:
nodes = node_collection.find({'member_of': event_gst._id, 'group_set': ObjectId(group_id)}).sort('last_update', -1)
node = None
event_reschedule_check = False
marks_list=[]
Assesslist=[]
batch=[]
session_node = ""
if app_set_instance_id :
template = "ndf/event_details.html"
node = node_collection.one({'_type': "GSystem", '_id': ObjectId(app_set_instance_id)})
# property_order_list = get_property_order_with_value(node)
# print "\n property_order_list: ", property_order_list, "\n"
node.get_neighbourhood(node.member_of)
course=[]
val=False
for i in node.attribute_set:
if unicode('event_edit_reschedule') in i.keys():
try:
if (unicode('reschedule_till') in i['event_edit_reschedule']) == True:
reschedule_time = i['event_edit_reschedule']['reschedule_till']
if (unicode('reschedule_allow') in i['event_edit_reschedule']):
reschedule = i['event_edit_reschedule']['reschedule_allow']
except:
pass
if (unicode('event_attendance_task')) in i.keys():
event_task_Attendance_reschedule = i['event_attendance_task']['Reschedule_Task']
if(unicode('event_date_task')) in i.keys():
event_task_date_reschedule = i['event_date_task']['Reschedule_Task']
if(unicode('marks_entry_completed')) in i.keys():
event_reschedule_check = i['marks_entry_completed']
for i in node.relation_set:
if unicode('event_has_batch') in i.keys():
batch=node_collection.one({'_type':"GSystem",'_id':ObjectId(i['event_has_batch'][0])})
batch_relation=node_collection.one({'_type':"GSystem",'_id':ObjectId(batch._id)},{'relation_set':1})
for i in batch_relation['relation_set']:
if unicode('has_course') in i.keys():
announced_course =node_collection.one({"_type":"GSystem",'_id':ObjectId(i['has_course'][0])})
for i in announced_course.relation_set:
if unicode('announced_for') in i.keys():
course=node_collection.one({"_type":"GSystem",'_id':ObjectId(i['announced_for'][0])})
batch=batch.name
if unicode('session_of') in i.keys():
event_has_session = node_collection.one({'_type':"GSystem",'_id':ObjectId(i['session_of'][0])})
session_node = node_collection.one({'_id':ObjectId(event_has_session._id)},{'attribute_set':1})
# print "\n node.keys(): ", node.keys(), "\n"
# default_template = "ndf/"+template_prefix+"_create_edit.html"
Mis_admin=node_collection.one({"_type":"Group","name":"MIS_admin"})
if Mis_admin:
Mis_admin_list=Mis_admin.group_admin
Mis_admin_list.append(Mis_admin.created_by)
if request.user.id in Mis_admin_list:
Add = "Allow"
else:
Add = "Stop"
else:
Add="Stop"
#fecth the data
context_variables = { 'groupid': group_id,
'app_id': app_id,'app_collection_set': app_collection_set,
'app_set_id': app_set_id,
'title':title,
'nodes': nodes, 'node': node,
'event_gst':event_gst.name,
'Add':Add,
'reschedule_time' : reschedule_time,
'reschedule' : reschedule,
'task_date' : event_task_date_reschedule,
'task_attendance' : event_task_Attendance_reschedule,
'event_reschedule_check' :event_reschedule_check,
'Eventtype':Eventtype,
# 'property_order_list': property_order_list
}
if batch :
context_variables.update({'batch':batch})
if course:
context_variables.update({'course':course})
else :
context_variables.update({'Assesslist':Assesslist})
# print "\n template-list: ", [template, default_template]
# template = "ndf/fgh.html"
# default_template = "ndf/dsfjhk.html"
# return render_to_response([template, default_template],
if session_node:
session_min_marks = ""
session_max_marks = ""
for attr in session_node.attribute_set:
if attr and u"min_marks" in attr:
session_min_marks = attr[u"min_marks"]
elif attr and u"max_marks" in attr:
session_max_marks = attr[u"max_marks"]
context_variables.update({'session_min_marks':session_min_marks})
context_variables.update({'session_max_marks':session_max_marks})
return render_to_response(template,
context_variables,
context_instance = RequestContext(request)
)
@login_required
@get_execution_time
def event_create_edit(request, group_id, app_set_id=None, app_set_instance_id=None):
"""
View for handling Event and it's sub-types create-edit-view
"""
auth = None
if ObjectId.is_valid(group_id) is False :
group_ins = node_collection.one({'_type': "Group","name": group_id})
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
if group_ins:
group_id = str(group_ins._id)
else :
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
if auth :
group_id = str(auth._id)
else :
pass
'''
app = None
if app_id is None:
app = node_collection.one({'_type': "GSystemType", 'name': app_name})
if app:
app_id = str(app._id)
else:
app = node_collection.one({'_id': ObjectId(app_id)})
app_name = app.name
'''
app_set = ""
app_collection_set = []
title = ""
session_of=""
module=""
Add=""
announced_course =""
batch =""
event_gst = None
event_gs = None
property_order_list = []
template_prefix = "mis"
'''if request.user:
if auth is None:
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username)})
agency_type = auth.agency_type
Event_Types = node_collection.one({'_type': "GSystemType", 'name': agency_type}, {'collection_set': 1})
if Event_Types:
for eachset in Event_Types.collection_set:
app_collection_set.append(node_collection.one({"_id": eachset}, {'_id': 1, 'name': 1, 'type_of': 1}))
'''
group_inverse_rel_id = []
Group_type=node_collection.one({'_id':ObjectId(group_id)})
for i in Group_type.relation_set:
if unicode("group_of") in i.keys():
group_inverse_rel_id = i['group_of']
Group_name = node_collection.one({'_type':'GSystem','_id':{'$in':group_inverse_rel_id}})
Eventtype='Eventtype'
if Group_name:
if (any( unicode('has_group') in d for d in Group_name.relation_set)) == True:
Eventtype='CollegeEvents'
else:
Eventtype='Eventtype'
Glisttype=node_collection.find({"_type": "GSystemType", "name":"GList"})
Event_Types = node_collection.one({"member_of":ObjectId(Glisttype[0]["_id"]),"name":Eventtype},{'collection_set': 1})
app_collection_set=[]
if Event_Types:
for eachset in Event_Types.collection_set:
app_collection_set.append(node_collection.one({"_id": eachset}, {'_id': 1, 'name': 1, 'type_of': 1}))
# for eachset in app.collection_set:
# app_collection_set.append(node_collection.one({"_id":eachset}, {'_id': 1, 'name': 1, 'type_of': 1}))
iteration=request.POST.get("iteration","")
if iteration == "":
iteration=1
for i in range(int(iteration)):
if app_set_id:
event_gst = node_collection.one({'_type': "GSystemType", '_id': ObjectId(app_set_id)}, {'name': 1, 'type_of': 1})
title = event_gst.name
event_gs = node_collection.collection.GSystem()
event_gs.member_of.append(event_gst._id)
if app_set_instance_id:
event_gs = node_collection.one({'_type': "GSystem", '_id': ObjectId(app_set_instance_id)})
property_order_list = get_property_order_with_value(event_gs)#.property_order
if request.method == "POST":
# [A] Save event-node's base-field(s)
# print "\n Going before....", type(event_gs), "\n event_gs.keys(): ", event_gs.keys()
# get_node_common_fields(request, event_gs, group_id, event_gst)
# print "\n Going after....", type(event_gs), "\n event_gs.keys(): ", event_gs.keys()
# print "\n event_gs: \n", event_gs.keys()
# for k, v in event_gs.items():
# print "\n ", k, " -- ", v
is_changed = get_node_common_fields(request, event_gs, group_id, event_gst)
if is_changed:
# Remove this when publish button is setup on interface
event_gs.status = u"PUBLISHED"
if (request.POST.get("name","")) == "":
if i>0:
field_value=request.POST.get('start_time'+"_"+str(i),'')
else:
field_value = request.POST.get('start_time','')
if event_gst.name == "Exam":
name = "Exam" + "--" + slugify(request.POST.get("batch_name","")) + "--" + field_value
else:
name= "Class" + "--"+ slugify(request.POST.get("course_name","")) + "--" + field_value
event_gs.name=name
event_gs.save(is_changed=is_changed)
# print "\n Event: ", event_gs._id, " -- ", event_gs.name, "\n"
# [B] Store AT and/or RT field(s) of given event-node (i.e., event_gs)
for tab_details in property_order_list:
for field_set in tab_details[1]:
# field_set pattern -- {[field_set[0]:node_structure, field_set[1]:field_base/AT/RT_instance{'_id':, 'name':, 'altnames':}, field_set[2]:node_value]}
# field_set pattern -- {'_id', 'data_type', 'name', 'altnames', 'value'}
# print " ", field_set["name"]
# * Fetch only Attribute field(s) / Relation field(s)
print "getting some thing****"
if field_set.has_key('_id'):
field_instance = node_collection.one({'_id': field_set['_id']})
field_instance_type = type(field_instance)
if field_instance_type in [AttributeType, RelationType]:
if field_instance["name"] == "attendees":
continue
field_data_type = field_set['data_type']
# Fetch field's value depending upon AT/RT and Parse fetched-value depending upon that field's data-type
if field_instance_type == AttributeType:
if "File" in field_instance["validators"]:
# Special case: AttributeTypes that require file instance as it's value in which case file document's ObjectId is used
if field_instance["name"] in request.FILES:
field_value = request.FILES[field_instance["name"]]
else:
field_value = ""
# Below 0th index is used because that function returns tuple(ObjectId, bool-value)
if field_value != '' and field_value != u'':
file_name = event_gs.name + " -- " + field_instance["altnames"]
content_org = ""
tags = ""
field_value = save_file(field_value, file_name, request.user.id, group_id, content_org, tags, access_policy="PRIVATE", count=0, first_object="", oid=True)[0]
if "date_month_day_year" in field_instance["validators"]:
if i>0:
field_value=request.POST.get(field_instance["name"]+"_"+str(i))
else:
field_value = request.POST[field_instance["name"]]
else:
# Other AttributeTypes
field_value = request.POST[field_instance["name"]]
# field_instance_type = "GAttribute"
# print "\n Parsing data for: ", field_instance["name"]
if field_instance["name"] in ["12_passing_year", "degree_passing_year"]: #, "registration_year"]:
field_value = parse_template_data(field_data_type, field_value, date_format_string="%Y")
elif field_instance["name"] in ["dob", "registration_date"]:
field_value = parse_template_data(field_data_type, field_value, date_format_string="%d/%m/%Y")
else:
field_value = parse_template_data(field_data_type, field_value, date_format_string="%d/%m/%Y %H:%M")
if field_value:
event_gs_triple_instance = create_gattribute(event_gs._id, node_collection.collection.AttributeType(field_instance), field_value)
# print "\n event_gs_triple_instance: ", event_gs_triple_instance._id, " -- ", event_gs_triple_instance.name
else:
field_value_list = request.POST.getlist(field_instance["name"])
# field_instance_type = "GRelation"
#code for creation of relation Session of
for i, field_value in enumerate(field_value_list):
field_value = parse_template_data(field_data_type, field_value, field_instance=field_instance, date_format_string="%d/%m/%Y %H:%M")
field_value_list[i] = field_value
if field_value_list:
event_gs_triple_instance = create_grelation(event_gs._id, node_collection.collection.RelationType(field_instance), field_value_list)
# if isinstance(event_gs_triple_instance, list):
# print "\n"
# for each in event_gs_triple_instance:
# print " event_gs_triple_instance: ", each._id, " -- ", each.name
# print "\n"
# else:
# print "\n event_gs_triple_instance: ", event_gs_triple_instance._id, " -- ", event_gs_triple_instance.name
# return HttpResponseRedirect(reverse('page_details', kwargs={'group_id': group_id, 'app_id': page_node._id }))
'''return HttpResponseRedirect(reverse(app_name.lower()+":"+template_prefix+'_app_detail', kwargs={'group_id': group_id, "app_id":app_id, "app_set_id":app_set_id}))'''
if event_gst.name == u'Classroom Session' or event_gst.name == u'Exam':
if i==( (int(iteration))-1):
#code to send mail to every one
return HttpResponseRedirect(reverse('event_app_instance_detail', kwargs={'group_id': group_id,"app_set_id":app_set_id,"app_set_instance_id":event_gs._id}))
else:
to_user_list = []
event_organizer_str = ""
event_coordinator_str = ""
event_organized_by = []
event_coordinator = []
event_node = node_collection.one({'_id':ObjectId(event_gs._id)})
for i in event_node.relation_set:
if unicode('event_organised_by') in i.keys():
event_organized_by = i['event_organised_by']
if unicode('has_attendees') in i.keys():
event_attendees = i['has_attendees']
if unicode('event_coordinator') in i.keys():
event_coordinator = i['event_coordinator']
event_url = "/"+str(group_id)+"/event/"+str(app_set_id) +"/"+str(event_node._id)
site = Site.objects.get(pk=1)
site = site.name.__str__()
event_link = "http://" + site + event_url
event_organized_by_cur = node_collection.find({"_id":{'$in':event_organized_by}})
event_coordinator_cur = node_collection.find({"_id":{'$in':event_coordinator}})
for i in event_coordinator_cur:
event_coordinator_str = event_coordinator_str + i.name + " "
for i in event_organized_by_cur:
event_organizer_str = event_coordinator_str + i.name + " "
for j in event_attendees:
auth = node_collection.one({"_id":ObjectId(j)})
user_obj = User.objects.get(id=auth.created_by)
if user_obj not in to_user_list:
to_user_list.append(user_obj)
render_label = render_to_string(
"notification/label.html",
{
"sender": "metaStudio",
"activity": "Event Created",
"conjunction": "-"
})
if event_organized_by:
msg_string = "\n Event is organized by " + str ( event_organizer_str )
else:
msg_string = ""
notification.create_notice_type(render_label,"Invitation for Event"+ " " + str(event_node.name) + msg_string + "\n Event will be co-ordinated by " +str (event_coordinator_str)
+ "\n- Please click [[" + event_link + "][here]] to view the details of the event" , "notification")
notification.send(to_user_list, render_label, {"from_user":"metaStudio"})
return HttpResponseRedirect(reverse('event_app_instance_detail', kwargs={'group_id': group_id,"app_set_id":app_set_id,"app_set_instance_id":event_node._id}))
event_attendees = request.POST.getlist('has_attendees','')
event_gs.get_neighbourhood(event_gs.member_of)
course=[]
val=False
for i in event_gs.relation_set:
if unicode('event_has_batch') in i.keys():
batch=node_collection.one({'_type':"GSystem",'_id':ObjectId(i['event_has_batch'][0])})
batch_relation=node_collection.one({'_type':"GSystem",'_id':ObjectId(batch._id)},{'relation_set':1})
for i in batch_relation['relation_set']:
if unicode('has_course') in i.keys():
announced_course =node_collection.one({"_type":"GSystem",'_id':ObjectId(i['has_course'][0])})
for i in announced_course.relation_set:
if unicode('announced_for') in i.keys():
course=node_collection.one({"_type":"GSystem",'_id':ObjectId(i['announced_for'][0])})
if unicode('session_of') in i.keys():
session_of=node_collection.one({'_type':"GSystem",'_id':ObjectId(i['session_of'][0])})
module=node_collection.one({'_type':"GSystem",'_id':{'$in':session_of.prior_node}})
event_gs.event_coordinator
Mis_admin=node_collection.one({"_type":"Group","name":"MIS_admin"})
if Mis_admin:
Mis_admin_list=Mis_admin.group_admin
Mis_admin_list.append(Mis_admin.created_by)
if request.user.id in Mis_admin_list:
Add="Allow"
else:
Add= "Stop"
else:
Add="Stop"
if event_gst.name == u'Classroom Session' or event_gst.name == u'Exam':
template="ndf/Nussd_event_Schedule.html"
else:
template = "ndf/event_create_edit.html"
# default_template = "ndf/"+template_prefix+"_create_edit.html"
context_variables = { 'group_id': group_id, 'groupid': group_id,
'app_collection_set': app_collection_set,
'app_set_id': app_set_id,
'title':title,
'property_order_list': property_order_list,
'Add':Add
}
if app_set_instance_id:
event_detail={}
events={}
if event_gs.event_coordinator:
event_detail["cordinatorname"]=str(event_gs.event_coordinator[0].name)
event_detail["cordinatorid"]=str(event_gs.event_coordinator[0]._id)
events["cordinator"]=event_detail
if announced_course:
event_detail["course"]=str(announced_course.name)
event_detail["course_id"]=str(announced_course._id)
events["course"]=event_detail
event_detail={}
if batch:
event_detail["batchname"]=str(batch.name)
event_detail["batchid"]=str(batch._id)
events["batch"]=event_detail
event_detail={}
if session_of:
event_detail["sessionname"]=str(session_of.name)
event_detail["sessionid"]=str(session_of._id)
for i in session_of.attribute_set:
if unicode('course_structure_minutes') in i.keys():
event_detail["sessionminutes"] = str(i['course_structure_minutes'])
events["session"]=event_detail
event_detail={}
if module:
event_detail["Modulename"]=str(module.name)
event_detail["Moduleid"]=str(module._id)
events["Module"]=event_detail
context_variables['node'] = event_gs
context_variables['edit_details']=events
# print "\n template-list: ", [template, default_template]
# template = "ndf/fgh.html"
# default_template = "ndf/dsfjhk.html"
# return render_to_response([template, default_template],
return render_to_response(template,
context_variables,
context_instance = RequestContext(request)
)
|