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
|
''' -- imports from python libraries -- '''
# import os -- Keep such imports here
import json
''' -- imports from installed packages -- '''
from django.contrib.auth.models import User
from django.http import HttpResponse
from django.shortcuts import render_to_response # , render
from django.template import RequestContext
try:
from bson import ObjectId
except ImportError: # old pymongo
from pymongo.objectid import ObjectId
''' -- imports from application folders/files -- '''
from gnowsys_ndf.settings import META_TYPE, GAPPS, GSTUDIO_SITE_DEFAULT_LANGUAGE, GSTUDIO_SITE_NAME
from gnowsys_ndf.settings import GSTUDIO_RESOURCES_CREATION_RATING, GSTUDIO_RESOURCES_REGISTRATION_RATING, GSTUDIO_RESOURCES_REPLY_RATING
from gnowsys_ndf.ndf.models import *
from gnowsys_ndf.ndf.models import node_collection, triple_collection, gridfs_collection
from gnowsys_ndf.ndf.models import *
from django.contrib.auth.models import User
from gnowsys_ndf.ndf.views.methods import get_drawers, get_execution_time
from gnowsys_ndf.ndf.views.methods import create_grelation, create_gattribute
from gnowsys_ndf.ndf.views.methods import get_user_group, get_user_task, get_user_notification, get_user_activity,get_execution_time
from gnowsys_ndf.ndf.views.file import *
from gnowsys_ndf.ndf.views.forum import *
from gnowsys_ndf.ndf.views.ajax_views import set_drawer_widget
from gnowsys_ndf.notification import models as notification
from gnowsys_ndf.ndf.templatetags.ndf_tags import get_all_user_groups
#######################################################################################################################################
gapp_mt = node_collection.one({'_type': "MetaType", 'name': META_TYPE[0]})
GST_IMAGE = node_collection.one({'member_of': gapp_mt._id, 'name': GAPPS[3]})
at_user_pref = node_collection.one({'_type': 'AttributeType', 'name': 'user_preference_off'})
ins_objectid = ObjectId()
#######################################################################################################################################
# V I E W S D E F I N E D F O R U S E R D A S H B O A R D
#######################################################################################################################################
@get_execution_time
def userpref(request,group_id):
usrid = int(group_id)
auth = node_collection.one({'_type': "Author", 'created_by': usrid})
# auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
lan_dict={}
pref=request.POST["pref"]
fall_back=request.POST["fallback"]
if pref:
lan_dict['primary']=pref
lan_dict['secondary']=fall_back
lan_dict['default']=GSTUDIO_SITE_DEFAULT_LANGUAGE
auth.preferred_languages=lan_dict
auth.modified_by=request.user.id
auth.save()
return HttpResponse("Success")
@login_required
@get_execution_time
def uDashboard(request, group_id):
usrid = int(group_id)
auth = node_collection.one({'_type': "Author", 'created_by': usrid})
group_id = auth._id
# Fetching user group of current user & then reassigning group_id with it's corresponding ObjectId value
group_name = auth.name
usrname = auth.name
date_of_join = auth['created_at']
current_user = request.user.pk
has_profile_pic = None
profile_pic_image = None
is_already_selected = None
task_gst = node_collection.one(
{'_type': "GSystemType", 'name': "Task"}
)
if current_user:
exclued_from_public = ""
if int(current_user) == int(usrid):
Access_policy=["PUBLIC","PRIVATE"]
if int(current_user) != int(usrid):
Access_policy=["PUBLIC"]
else:
Access_policy=["PUBLIC"]
exclued_from_public = ObjectId(task_gst._id)
if request.method == "POST" :
"""
This will take the image uploaded by user and it searches if its already availale in gridfs
using its md5
"""
has_profile_pic_str = "has_profile_pic"
pp = None
if has_profile_pic_str in request.FILES:
pp = request.FILES[has_profile_pic_str]
has_profile_pic = node_collection.one({'_type': "RelationType", 'name': has_profile_pic_str})
# Find md5
pp_md5 = hashlib.md5(pp.read()).hexdigest()
pp.seek(0)
# Check whether this md5 exists in file collection
gridfs_node = gridfs_collection.one({'md5': pp_md5})
if gridfs_node:
# md5 exists
right_subject = gridfs_node["docid"]
# Check whether already selected
is_already_selected = triple_collection.one(
{'subject': auth._id, 'status': u"PUBLISHED", 'right_subject': right_subject}
)
if is_already_selected:
# Already selected found
# Signify already selected
is_already_selected = gridfs_node["filename"]
else:
# Already uploaded found
# Reset already uploaded as to be selected
profile_pic_image = create_grelation(auth._id, has_profile_pic, right_subject)
profile_pic_image = node_collection.one({'_type': "File", '_id': right_subject})
else:
# Otherwise (md5 doesn't exists)
# Upload image
# submitDoc(request, group_id)
#save_file(each,title,userid,group_object._id, content_org, tags, img_type, language, usrname, access_policy, oid=True)
field_value = save_file(pp, pp, request.user.id, group_id, "", "", oid=True)[0]
if field_value:
profile_pic_image = node_collection.one({'_type': "File", '_id': ObjectId(field_value)})
# Create new grelation and append it to that along with given user
if profile_pic_image:
gr_node = create_grelation(auth._id, has_profile_pic, profile_pic_image._id)
dashboard_count = {}
group_list = []
user_activity = []
page_gst = node_collection.one({'_type': "GSystemType", 'name': 'Page'})
page_cur = node_collection.find({'member_of': {'$all': [page_gst._id]},
'created_by': int(usrid), "status": {"$nin": ["HIDDEN"]}})
file_cur = node_collection.find({'_type': u"File", 'created_by': int(usrid),
"status": {"$nin": ["HIDDEN"]}})
forum_gst = node_collection.one({"_type": "GSystemType", "name": "Forum"})
forum_count = node_collection.find({"_type": "GSystem",
"member_of": forum_gst._id, 'created_by': int(usrid),
"status": {"$nin": ["HIDDEN"]}})
quiz_gst = node_collection.one({"_type": "GSystemType", "name": "Quiz"})
quiz_count = node_collection.find({"_type": "GSystem",
"member_of": quiz_gst._id, 'created_by': int(usrid),
"status": {"$nin": ["HIDDEN"]}})
thread_gst = node_collection.one({"_type": "GSystemType", "name": "Twist"})
thread_count =node_collection.find({"_type": "GSystem",
"member_of": thread_gst._id, 'created_by': int(usrid),
"status": {"$nin": ["HIDDEN"]}})
reply_gst = node_collection.one({"_type": "GSystemType", "name": "Reply"})
reply_count = node_collection.find({"_type": "GSystem",
"member_of": reply_gst._id, 'created_by': int(usrid),
"status": {"$nin": ["HIDDEN"]}})
task_cur = ""
if current_user:
if int(current_user) == int(usrid):
task_cur = node_collection.find(
{'member_of': task_gst._id, 'attribute_set.Status': {'$in': ["New", "In Progress"]}, 'attribute_set.Assignee':usrid}
).sort('last_update', -1).limit(10)
dashboard_count.update({'Task': task_cur.count()})
group_cur = node_collection.find(
{'_type': "Group", 'name': {'$nin': ["home", auth.name]},"access_policy":{"$in":Access_policy},
'$or': [{'group_admin': int(usrid)}, {'author_set': int(usrid)}]}).sort('last_update', -1).limit(10)
dashboard_count.update({'group':group_cur.count()})
# user activity gives all the activities of the users
activity = ""
activity_user = node_collection.find(
{'$and': [{'$or': [{'_type': 'GSystem'}, {'_type': 'group'},
{'_type': 'File'}]}, {"access_policy": {"$in": Access_policy}},{'status':{'$in':[u"DRAFT",u"PUBLISHED"]}},
{'member_of': {'$nin': [exclued_from_public]}},
{'$or': [{'created_by': int(usrid)}, {'modified_by': int(usrid)}]}]
}).sort('last_update', -1).limit(10)
a_user = []
dashboard_count.update({'activity': activity_user.count()})
#for i in activity_user:
# if i._type != 'Batch' or i._type != 'Course' or i._type != 'Module':
# a_user.append(i)
#loop replaced by a list comprehension
a_user=[i for i in activity_user if (i._type != 'Batch' or i._type != 'Course' or i._type != 'Module')]
#a temp. variable which stores the lookup for append method
user_activity_append_temp=user_activity.append
for each in a_user:
if each.created_by == each.modified_by:
if each.last_update == each.created_at:
activity = 'created'
else:
activity = 'modified'
else:
activity = 'created'
if each._type == 'Group':
user_activity_append_temp(each)
else:
member_of = node_collection.find_one({"_id": each.member_of[0]})
user_activity_append_temp(each)
'''
notification_list=[]
notification_object = notification.NoticeSetting.objects.filter(user_id=int(ID))
for each in notification_object:
ntid = each.notice_type_id
ntype = notification.NoticeType.objects.get(id=ntid)
label = ntype.label.split("-")[0]
notification_list.append(label)
Retrieving Tasks Assigned for User (Only "New" and "In Progress")
user_assigned = []
attributetype_assignee = node_collection.find_one({"_type":'AttributeType', 'name':'Assignee'})
attr_assignee = triple_collection.find(
{"_type": "GAttribute", "attribute_type.$id": attributetype_assignee._id, "object_value": request.user.id}
).sort('last_update', -1).limit(10)
dashboard_count.update({'Task':attr_assignee.count()})
for attr in attr_assignee :
task_node = node_collection.one({'_id':attr.subject})
if task_node:
user_assigned.append(task_node)
task_cur gives the task asigned to users
'''
obj = node_collection.find(
{'_type': {'$in': [u"GSystem", u"File"]}, 'contributors': int(usrid),
'group_set': {'$all': [ObjectId(group_id)]}}
)
collab_drawer = []
#a temp. variable which stores the lookup for append method
collab_drawer_append_temp=collab_drawer.append
"""
To populate collaborators according
to their latest modification of particular resource:
"""
for each in obj.sort('last_update', -1):
for val in each.contributors:
name = User.objects.get(pk=val).username
collab_drawer_append_temp({'usrname': name, 'Id': val,
'resource': each.name})
shelves = []
datavisual = []
shelf_list = {}
show_only_pie = True
if not profile_pic_image:
if auth:
for each in auth.relation_set:
if "has_profile_pic" in each:
profile_pic_image = node_collection.one(
{'_type': "File", '_id': each["has_profile_pic"][0]}
)
break
forum_create_rate = forum_count.count() * GSTUDIO_RESOURCES_CREATION_RATING
file_create_rate = file_cur.count() * GSTUDIO_RESOURCES_CREATION_RATING
page_create_rate = page_cur.count() * GSTUDIO_RESOURCES_CREATION_RATING
quiz_create_rate = quiz_count.count() * GSTUDIO_RESOURCES_CREATION_RATING
reply_create_rate = reply_count.count() * GSTUDIO_RESOURCES_REPLY_RATING
thread_create_rate = thread_count.count() * GSTUDIO_RESOURCES_CREATION_RATING
datavisual.append({"name": "Forum", "count": forum_create_rate})
datavisual.append({"name": "File", "count": file_create_rate})
datavisual.append({"name": "Page", "count": page_create_rate})
datavisual.append({"name": "Quiz", "count": quiz_create_rate})
datavisual.append({"name": "Reply", "count": reply_create_rate})
datavisual.append({"name": "Thread", "count": thread_create_rate})
datavisual.append({"name": "Registration", "count": GSTUDIO_RESOURCES_REGISTRATION_RATING})
total_activity_rating = GSTUDIO_RESOURCES_REGISTRATION_RATING + (page_cur.count() + file_cur.count() + forum_count.count() + quiz_count.count()) * GSTUDIO_RESOURCES_CREATION_RATING + (thread_count.count() + reply_count.count()) * GSTUDIO_RESOURCES_REPLY_RATING
return render_to_response(
"ndf/uDashboard.html",
{
'usr': current_user, 'username': usrname, 'user_id': usrid,
'DOJ': date_of_join, 'author': auth, 'group_id': group_id,
'groupid': group_id, 'group_name': group_name,
'already_set': is_already_selected, 'user_groups': group_cur,
'prof_pic_obj': profile_pic_image, 'user_task': task_cur,
'group_count': group_cur.count(), 'page_count': page_cur.count(),
'file_count': file_cur.count(), 'user_activity': user_activity,
'dashboard_count': dashboard_count, 'show_only_pie': show_only_pie,
'datavisual': json.dumps(datavisual),
'total_activity_rating': total_activity_rating,
'site_name': GSTUDIO_SITE_NAME,
},
context_instance=RequestContext(request)
)
@get_execution_time
def user_preferences(request,group_id,auth_id):
try:
grp = node_collection.one({'_id': ObjectId(auth_id)})
if request.method == "POST":
lst = []
pref_to_set = request.POST['pref_to_set']
pref_list=pref_to_set.split(",")
if pref_list:
for each in pref_list:
if each:
obj = node_collection.one({'_id':ObjectId(each)})
lst.append(obj);
if lst:
ga_node = create_gattribute(grp._id, at_user_pref, lst)
# gattribute = triple_collection.one({'$and':[{'_type':'GAttribute'},{'attribute_type.$id':at_user_pref._id},{'subject':grp._id}]})
# if gattribute:
# gattribute.delete()
# if lst:
# create_attribute=collection.GAttribute()
# create_attribute.attribute_type=at_user_pref
# create_attribute.subject=grp._id
# create_attribute.object_value=lst
# create_attribute.save()
return HttpResponse("Success")
else:
list_at_pref=[]
user_id=request.user.id
if not at_user_pref:
return HttpResponse("Failure")
poss_attrs=grp.get_possible_attributes(at_user_pref._id)
if poss_attrs:
list_at_pref=poss_attrs['user_preference_off']['object_value']
all_user_groups=[]
for each in get_all_user_groups():
all_user_groups.append(each.name)
st = node_collection.find({'$and':[{'_type':'Group'},{'author_set':{'$in':[user_id]}},{'name':{'$nin':all_user_groups}}]})
data_list=set_drawer_widget(st,list_at_pref)
return HttpResponse(json.dumps(data_list))
except Exception as e:
print "Exception in userpreference view "+str(e)
return HttpResponse("Failure")
@get_execution_time
def user_template_view(request,group_id):
auth_group = None
group_list=[]
group_cur = node_collection.find({'_type': "Group", 'name': {'$nin': ["home", request.user.username]}}).limit(4)
for i in group_cur:
group_list.append(i)
blank_list = []
attributetype_assignee = node_collection.find_one({"_type": 'AttributeType', 'name':'Assignee'})
attr_assignee = triple_collection.find({"_type": "GAttribute", "attribute_type.$id":attributetype_assignee._id, "object_value":request.user.username})
for attr in attr_assignee :
task_node = node_collection.find_one({'_id': attr.subject})
blank_list.append(task_node)
notification_object = notification.NoticeSetting.objects.filter(user_id=request.user.id)
for each in notification_object:
ntid = each.notice_type_id
ntype = notification.NoticeType.objects.get(id=ntid)
label = ntype.label.split("-")[0]
blank_list.append({'label':label, 'display': ntype.display})
blank_list.reverse()
blank_list = []
activity = ""
activity_user = node_collection.find({'$and':[{'$or':[{'_type':'GSystem'},{'_type':'Group'},{'_type':'File'}]},
{'$or':[{'created_by':request.user.id}, {'modified_by':request.user.id}]}] }).sort('last_update', -1).limit(4)
for each in activity_user:
if each.created_by == each.modified_by :
if each.last_update == each.created_at:
activity = 'created'
else :
activity = 'modified'
else :
activity = 'created'
if each._type == 'Group':
blank_list.append(each)
else :
member_of = node_collection.find_one({"_id": each.member_of[0]})
blank_list.append(each)
template = "ndf/task_card_view.html"
#variable = RequestContext(request, {'TASK_inst': self_task,'group_name':group_name,'group_id': group_id, 'groupid': group_id,'send':send})
variable = RequestContext(request, {'TASK_inst':blank_list,'group_name':group_id,'group_id': group_id, 'groupid': group_id})
return render_to_response(template, variable)
@login_required
@get_execution_time
def user_activity(request, group_id):
activity_user = node_collection.find({'$and':[{'$or':[{'_type':'GSystem'},{'_type':'group'},{'_type':'File'}]},
{'$or':[{'created_by':request.user.id}, {'modified_by':request.user.id}]}]
}).sort('last_update', -1)
blank_list=[]
for each in activity_user:
if each.created_by == each.modified_by :
if each.last_update == each.created_at:
activity = 'created'
else :
activity = 'modified'
else :
activity = 'created'
if each._type == 'Group':
blank_list.append(each)
else :
member_of = node_collection.find_one({"_id":each.member_of[0]})
blank_list.append(each)
template = "ndf/User_Activity.html"
#variable = RequestContext(request, {'TASK_inst': self_task,'group_name':group_name,'group_id': group_id, 'groupid': group_id,'send':send})
variable = RequestContext(request, {'user_activity':blank_list,'group_name':group_id,'group_id': group_id, 'groupid': group_id})
return render_to_response(template, variable)
@get_execution_time
def group_dashboard(request, group_id):
"""
This view returns data required for group's dashboard.
"""
profile_pic_image = None
has_profile_pic_str = ""
if ObjectId.is_valid(group_id) is False :
group_ins = node_collection.find_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 :
group_ins = node_collection.find_one({'_type': "Group", "_id": ObjectId(group_id)})
if group_ins:
group_id = group_ins._id
if request.method == "POST" :
"""
This will take the image uploaded by user and it searches if its already availale in gridfs
using its md5
"""
if (request.POST.get('type','')=='banner_pic'):
has_profile_pic_str = "has_Banner_pic"
if (request.POST.get('type','')=='profile_pic'):
has_profile_pic_str="has_profile_pic"
pp = None
profile_pic_image=""
if has_profile_pic_str in request.FILES:
pp = request.FILES[has_profile_pic_str]
has_profile_pic = node_collection.one({'_type': "RelationType", 'name': has_profile_pic_str})
# Find md5
pp_md5 = hashlib.md5(pp.read()).hexdigest()
pp.seek(0)
# Check whether this md5 exists in file collection
gridfs_node = gridfs_collection.one({'md5': pp_md5})
if gridfs_node:
# md5 exists
right_subject = gridfs_node["docid"]
# Check whether already selected
is_already_selected = triple_collection.one(
{'subject': group_id, 'right_subject': right_subject, 'status': u"PUBLISHED"}
)
if is_already_selected:
# Already selected found
# Signify already selected
is_already_selected = gridfs_node["filename"]
else:
# Already uploaded found
# Reset already uploaded as to be selected
profile_pic_image = create_grelation(ObjectId(group_id), has_profile_pic, right_subject)
profile_pic_image = node_collection.one({'_type': "File", '_id': right_subject})
else:
# Otherwise (md5 doesn't exists)
# Upload image
# submitDoc(request, group_id)
field_value = save_file(pp, pp, request.user.id, group_id, "", "", oid=True)[0]
profile_pic_image = node_collection.one({'_type': "File", 'name': unicode(pp)})
# Create new grelation and append it to that along with given user
if profile_pic_image:
gr_node = create_grelation(group_id, has_profile_pic, profile_pic_image._id)
banner_pic=""
group = node_collection.one({"_id": ObjectId(group_id)})
for each in group.relation_set:
if "has_profile_pic" in each:
if each["has_profile_pic"]:
profile_pic_image = node_collection.one(
{'_type': "File", '_id': each["has_profile_pic"][0]}
)
if "has_Banner_pic" in each:
if each["has_Banner_pic"]:
banner_pic = node_collection.one(
{'_type': "File", '_id': each["has_Banner_pic"][0]}
)
# Approve StudentCourseEnrollment view
approval = False
enrollment_details = []
enrollment_columns = []
sce_gst = node_collection.one({'_type': "GSystemType", 'name': "StudentCourseEnrollment"})
if sce_gst:
# Get StudentCourseEnrollment nodes which are there for approval
sce_cur = node_collection.find({
'member_of': sce_gst._id, 'group_set': ObjectId(group_id),
# "attribute_set.enrollment_status": {"$nin": [u"OPEN"]},
"attribute_set.enrollment_status": {"$in": [u"PENDING", "APPROVAL"]},
'status': u"PUBLISHED"
}, {
'member_of': 1
})
if sce_cur.count():
approval = True
enrollment_columns = ["College", "Course", "Status", "Enrolled", "Remaining", "Approved", "Rejected"]
for sce_gs in sce_cur:
sce_gs.get_neighbourhood(sce_gs.member_of)
data = {}
# approve_task = sce_gs.has_corresponding_task[0]
approve_task = sce_gs.has_current_approval_task[0]
approve_task.get_neighbourhood(approve_task.member_of)
data["Status"] = approve_task.Status
# Check for corresponding task's status
# Continue with next if status is found as "Closed"
# As we listing only 'In Progress'/'New' task(s)
if data["Status"] == "Closed":
continue
data["_id"] = str(sce_gs._id)
data["College"] = sce_gs.for_college[0].name
if len(sce_gs.for_acourse) > 1:
# It means it's a Foundation Course's (FC) enrollment
start_enroll = None
end_enroll = None
for each in sce_gs.for_acourse[0].attribute_set:
if not each:
pass
elif "start_time" in each:
start_time = each["start_time"]
elif "end_time" in each:
end_time = each["end_time"]
data["Course"] = "Foundation_Course" + "_" + start_time.strftime("%d-%b-%Y") + "_" + end_time.strftime("%d-%b-%Y")
else:
# Courses other than FC
data["Course"] = sce_gs.for_acourse[0].name
# data["Completed On"] = sce_gs.completed_on.strftime("%d/%m/%Y")
remaining_count = None
enrolled_list = []
approved_list = []
rejected_list = []
if sce_gs.has_key("has_enrolled"):
if sce_gs["has_enrolled"]:
enrolled_list = sce_gs["has_enrolled"]
if sce_gs.has_key("has_approved"):
if sce_gs["has_approved"]:
approved_list = sce_gs["has_approved"]
if sce_gs.has_key("has_rejected"):
if sce_gs["has_rejected"]:
rejected_list = sce_gs["has_rejected"]
data["Enrolled"] = len(enrolled_list)
data["Approved"] = len(approved_list)
data["Rejected"] = len(rejected_list)
remaining_count = len(enrolled_list) - (len(approved_list) + len(rejected_list))
data["Remaining"] = remaining_count
enrollment_details.append(data)
page = '1'
return render_to_response (
"ndf/group_dashboard.html",
{
'group_id': group_id, 'groupid': group_id,
'approval': approval, 'enrollment_columns': enrollment_columns, 'enrollment_details': enrollment_details,'prof_pic_obj': profile_pic_image,'banner_pic':banner_pic,'page':page
},
context_instance=RequestContext(request)
)
|