Showing with 684 additions and 381 deletions.
  1. +92 −0 gnowsys-ndf/gnowsys_ndf/ndf/management/commands/fetch_data.py
  2. +39 −4 gnowsys-ndf/gnowsys_ndf/ndf/management/commands/fetch_syncdata.py
  3. +4 −3 gnowsys-ndf/gnowsys_ndf/ndf/management/commands/send_syncdata.py
  4. +24 −1 gnowsys-ndf/gnowsys_ndf/ndf/management/commands/sync_existing_documents.py
  5. +10 −3 gnowsys-ndf/gnowsys_ndf/ndf/models.py
  6. +5 −0 gnowsys-ndf/gnowsys_ndf/ndf/static/ndf/css/themes/metastudio/styles.css
  7. +5 −0 gnowsys-ndf/gnowsys_ndf/ndf/static/ndf/css/themes/nroer/styles.css
  8. +5 −0 gnowsys-ndf/gnowsys_ndf/ndf/static/ndf/css/themes/tiss/styles.css
  9. +3 −0 gnowsys-ndf/gnowsys_ndf/ndf/static/ndf/scss/_app_styles.scss
  10. +5 −1 gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/Uploader_Form.html
  11. +1 −1 gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/base.html
  12. +25 −22 gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/card.html
  13. +2 −0 gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/course_event_group.html
  14. +3 −3 gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/data_review_tbody.html
  15. +1 −0 gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/discussion.html
  16. +25 −43 gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/ebook.html
  17. +16 −19 gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/file.html
  18. +4 −0 gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/file_list_tab.html
  19. +3 −2 gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/footer.html
  20. +2 −0 gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/groupdashboard.html
  21. +2 −2 gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/header.html
  22. +42 −21 gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/node_ajax_content.html
  23. +0 −4 gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/node_ajax_view.html
  24. +54 −49 gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/node_edit_base.html
  25. +2 −0 gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/res_node_ajax_view.html
  26. +20 −3 gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/theme.html
  27. +1 −1 gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/theme_create_edit.html
  28. +34 −1 gnowsys-ndf/gnowsys_ndf/ndf/templatetags/ndf_tags.py
  29. +24 −2 gnowsys-ndf/gnowsys_ndf/ndf/templatetags/simple_filters.py
  30. +2 −1 gnowsys-ndf/gnowsys_ndf/ndf/urls/e-book.py
  31. +1 −1 gnowsys-ndf/gnowsys_ndf/ndf/views/adminDesignerDashboard.py
  32. +21 −20 gnowsys-ndf/gnowsys_ndf/ndf/views/analytics.py
  33. +15 −29 gnowsys-ndf/gnowsys_ndf/ndf/views/e-book.py
  34. +3 −2 gnowsys-ndf/gnowsys_ndf/ndf/views/file.py
  35. +14 −24 gnowsys-ndf/gnowsys_ndf/ndf/views/mailclient.py
  36. +135 −84 gnowsys-ndf/gnowsys_ndf/ndf/views/methods.py
  37. +1 −1 gnowsys-ndf/gnowsys_ndf/ndf/views/page.py
  38. +39 −34 gnowsys-ndf/gnowsys_ndf/settings.py
@@ -0,0 +1,92 @@
import subprocess
from django.core.management.base import BaseCommand, CommandError
from gnowsys_ndf.factory_type import *
from gnowsys_ndf.ndf.models import *
from bson.json_util import dumps,loads
from bson import json_util
from gnowsys_ndf.ndf.models import NodeJSONEncoder
from gnowsys_ndf.ndf.rcslib import RCS
from gnowsys_ndf.ndf.views.methods import capture_data
from gnowsys_ndf.local_settings import SYNCDATA_KEY_PUB
import json
import datetime
rcs = RCS()
hr = HistoryManager()
Parent_collection_ids = []
child_collection_ids = []
processing_list_ids = []

class Command(BaseCommand):

def handle(self,*args,**options):
#temprory time stamp
t = "2015-09-25T14:29:16"
print t
#Read time stamp from the file
root_path = os.path.abspath(os.path.dirname(os.pardir))
tym_scan = os.path.join(root_path, 'Last_Scan.txt')
file_output = open(tym_scan)
last_scan = file_output.readline()
if last_scan:
index = last_scan.find(":")
str1 = last_scan[index+1:]
t = str1.strip("\t\n\r ")
else:
print "itha"
t = str(datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%S"))
print " \"%s\"" % t

log_output = os.popen("cat /var/log/mongodb/mongod.log|awk '$0 > \"%s\" '|grep 'WRITE'|grep '.Nodes\|.Triples'" % str(t))
print "somgin here"
for line in log_output:
'''raw string processing code'''
str_start = line.find('_id')
str_start = (line[str_start:].find('ObjectId')) + str_start
if str_start != -1:
try:
str_end = (line[str_start:].find(')')) + str_start
raw_string = line[str_start:str_end+1]

'''
if line.find('.Triples') != -1:
if raw_string not in child_collection_ids:
processing_list_ids.append(raw_string)
if line.find('.Nodes') != -1:
if raw_string not in Parent_collection_ids:
Parent_collection_ids.append(raw_string)
'''
if line.find("ToReduceDocs") == -1:
if line.find('.Triples') != -1 or line.find('.Nodes') != -1 :
if raw_string not in processing_list_ids:
processing_list_ids.append(raw_string)
except Exception as e:
print e

process_parent_node(processing_list_ids)
#process_dependent_collection(child_collection_ids)
datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%S")
with open("Last_Scan.txt","w") as outfile:
outfile.write(str("Last Scan time:" + str(datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%S"))))
def process_parent_node(Parent_collection_ids):
for i in Parent_collection_ids:
i = (i[i.find('\''):i[i.find('\''):].find(')') + i.find('\'')]).strip('\'')
if i != '':
node = node_collection.find_one({"_id":ObjectId(str(i))})
if node:
capture_data(file_object=node, file_data=None, content_type='Genral')
else:
node = triple_collection.find_one({"_id":ObjectId(str(i))})
capture_data(file_object=node, file_data=None, content_type='Genral')
#create log file
if node:
with open("Registry.txt", 'a') as outfile:
outfile.write(str("_id:" + str(node["_id"]) + "," +"Snapshot"+ str(node.get("snapshot",0)) + ", Public key:" +SYNCDATA_KEY_PUB + ",Synced:{0}" +"\n" ))


def process_dependent_collection(dependent_collection):
for i in dependent_collection:
i = (i[i.find('\''):i[i.find('\''):].find(')') + i.find('\'')]).strip('\'')
if i != '':
node = triple_collection.find_one({"_id":ObjectId(str(i))})
capture_data(file_object=node, file_data=None, content_type='Genral')

@@ -7,6 +7,7 @@
from subprocess import call
from django.core.mail import EmailMessage
from imaplib import IMAP4
import subprocess
from django_mailbox.models import Mailbox
from gnowsys_ndf.settings import SYNCDATA_FETCHING_EMAIL_ID, SYNCDATA_FETCHING_EMAIL_ID_PASSWORD, SYNCDATA_FETCHING_IMAP_SERVER_ADDRESS
from gnowsys_ndf.ndf.views.mailclient import server_sync
@@ -26,7 +27,8 @@ class Command(BaseCommand):
def handle(self, *args, **kwargs):
if connected_to_internet() is False:
return None

received_registries = []
received_data = []
email = SYNCDATA_FETCHING_EMAIL_ID.replace('@','%40')
metabox = Mailbox()
metabox.name = 'Metabox'
@@ -49,13 +51,46 @@ def handle(self, *args, **kwargs):
syncdata_mails_list = metabox.get_new_mail()
if syncdata_mails_list:
for mail in syncdata_mails_list:
print '**'*30; print mail; print ''
server_sync(mail)
text,data = process_mails(mail)
received_registries += text
received_data += data
chain_registry(received_registries)
print received_data
server_sync(received_data)
else:
print 'No new mails received'
metabox.delete()
except Exception as error:
#delete temporary mailbox from database
metabox.delete()
print "The following error occured while fetching syncdata mails: "
print str(error)
print str(error)

def process_mails(mail):
all_attachments = mail.attachments.all()
all_attachments_path = []
json_file_path = ''
file_object_path = ''


''' Code reads all the attachmnet of the single mail '''
''' Code to decrypt every attachment and create a list with the file paths of decrypted attachments'''
list_of_decrypted_attachments = []
for attachment in all_attachments:
filename = attachment.document.path
op_file_name = filename.split('_sig')[0]
print 'output file name of decrypted attachment : \n %s' % op_file_name
command = 'gpg --output ' + op_file_name + ' --decrypt ' + filename
print "error point croseed"
std_out= subprocess.call([command],shell=True)
list_of_decrypted_attachments.append(op_file_name)
return fetch_registry(list_of_decrypted_attachments)

def fetch_registry(file_list):
registryfile = [i for i in file_list if i.find(".txt")!= -1]
datafile = [ i for i in file_list if i.find(".json") != -1]
print "the datafile",datafile
return registryfile,datafile
def chain_registry(file_list):
print file_list

@@ -47,7 +47,9 @@ def handle(self, *args, **kwargs):
syncdata_folder_path = os.path.dirname(__file__).split('/management')[0] + '/MailClient/syncdata'
list_of_syncdata_folders = []
sent_folder_path = os.path.dirname(__file__).split('/management')[0] + '/MailClient/sent_syncdata_files'


registry_path = os.path.abspath(os.path.dirname(os.pardir))
registry_path = os.path.join(registry_path, 'Registry.txt')
if not os.path.exists(sent_folder_path):
os.makedirs(sent_folder_path)

@@ -58,9 +60,8 @@ def handle(self, *args, **kwargs):
except Exception as error:
print 'File name and location is: ', str(__file__)
print 'Error is : ', error

for folder_name in list_of_syncdata_folders:
print '**'*30
path = syncdata_folder_path + '/' + folder_name
list_of_syncdata_files = os.listdir(path)
if connected_to_internet() is True:
@@ -11,7 +11,7 @@
''' imports from application folders/files '''
from gnowsys_ndf.ndf.models import node_collection, triple_collection
from gnowsys_ndf.ndf.models import Node
from gnowsys_ndf.settings import GSTUDIO_AUTHOR_AGENCY_TYPES
from gnowsys_ndf.settings import GSTUDIO_AUTHOR_AGENCY_TYPES, LANGUAGES, OTHER_COMMON_LANGUAGES
from gnowsys_ndf.ndf.views.methods import create_gattribute, create_grelation
from gnowsys_ndf.ndf.templatetags.ndf_tags import get_relation_value, get_attribute_value

@@ -24,6 +24,29 @@ class Command(BaseCommand):
def handle(self, *args, **options):
# Keep latest changes in field(s) to be added at top

# Updating language fields data type:
# - Firstly, replacing None to ('en', 'English')
node_collection.collection.update({ '_type': {'$in': ['AttributeType', 'RelationType', 'MetaType', 'ProcessType', 'GSystemType', 'GSystem', 'File', 'Group', 'Author']}, 'language': {'$in': [None, '', u'']} }, {"$set": {"language": ('en', 'English')}}, upsert=False, multi=True)

all_nodes = node_collection.find({'_type': {'$in': ['AttributeType', 'RelationType', 'MetaType', 'ProcessType', 'GSystemType', 'GSystem', 'File', 'Group', 'Author']} })

all_languages = list(LANGUAGES) + OTHER_COMMON_LANGUAGES
all_languages_concanated = reduce(lambda x, y: x+y, all_languages)

# iterating over each document in the cursor:
# - Secondly, replacing invalid language values to valid tuple from settings
for each_node in all_nodes:
if each_node.language and (each_node.language in all_languages_concanated):
for each_lang in all_languages:
if each_node.language in each_lang:
# printing msg without checking update result for performance.
print "Updated language field of: ", each_node.name
print "\tFrom", each_node.language, " to: ", each_lang, '\n'
node_collection.collection.update({'_id': each_node._id}, {"$set": {"language": each_lang}}, upsert=False, multi=False)

# --- END of Language processing ---


# adding all activated and logged-in user's id into author_set of "home" group ---
all_authors = node_collection.find({"_type": "Author"})
authors_list = [auth.created_by for auth in all_authors]
@@ -179,7 +179,9 @@ class Node(DjangoDocument):
'prior_node': [ObjectId],
'post_node': [ObjectId],

'language': unicode,
# 'language': unicode, # previously it was unicode.
'language': (basestring, basestring), # Tuple are converted into a simple list
# ref: https://github.com/namlook/mongokit/wiki/Structure#tuples

'type_of': [ObjectId], # check required: only ObjectIDs of GSystemType
'member_of': [ObjectId], # check required: only ObjectIDs of
@@ -233,7 +235,11 @@ class Node(DjangoDocument):
# here after the default
# 'Administration' group is
# ready.
default_values = {'created_at': datetime.datetime.utcnow, 'status': u'DRAFT'}
default_values = {
'created_at': datetime.datetime.utcnow,
'status': u'DRAFT',
'language': ('en', 'English')
}
use_dot_notation = True

########## Setter(@x.setter) & Getter(@property) ##########
@@ -1206,7 +1212,8 @@ class Author(Group):
'preferred_languages': dict, # preferred languages for users like preferred lang. , fall back lang. etc.
'group_affiliation': basestring,
'language_proficiency':basestring,
'subject_proficiency':basestring
'subject_proficiency':basestring #,
# TODO: add a field: preffered_display_name, 22-39-15, kedar2a
}

use_dot_notation = True
@@ -10304,3 +10304,8 @@ aside#help p, aside#help h5, aside#help h6 {
color: red;
font-size: smaller;
}

/* line 1304, ../../../scss/_app_styles.scss */
.text-gray {
color: gray;
}
@@ -10397,3 +10397,8 @@ aside#help p, aside#help h5, aside#help h6 {
color: red;
font-size: smaller;
}

/* line 1304, ../../../scss/_app_styles.scss */
.text-gray {
color: gray;
}
@@ -10304,3 +10304,8 @@ aside#help p, aside#help h5, aside#help h6 {
color: red;
font-size: smaller;
}

/* line 1304, ../../../scss/_app_styles.scss */
.text-gray {
color: gray;
}
@@ -1301,3 +1301,6 @@ aside#help{
}
}

.text-gray{
color: gray;
}
@@ -10,7 +10,11 @@ <h3>{% trans "Contribute File" %}</h3>
<ul class="text-justify subheader">
<li>
{% trans "You can contribute only Open Educational Resources" %}
({% trans "Copyrighted material cannot be contributed" %})
({% trans "Resources copyrighted by others must be cited including OER" %}.)
</li>
<li>
{% trans "What constitutes OER" %}?
<!-- TODO: make one info page and link it with anchor, 22-09-15, kedar2a -->
</li>
<li>
{% trans "You can upload files of any format" %}
@@ -246,7 +246,7 @@
$(document).ready(function() {
try{

$('select option[value="{{request.LANGUAGE_CODE}}"]').attr("selected",true);
// $('select option[value="{{request.LANGUAGE_CODE}}"]').attr("selected",true);

{% block document_ready %} {% endblock %}

@@ -13,9 +13,9 @@
{% endif %}

<div class="image">
<div class="{{resource.status|lower}} card-label">
<div class="label-text"></div>
</div>
<div class="{{resource.status|lower}} card-label">
<div class="label-text"></div>
</div>
{% get_dict_from_list_of_dicts resource.attribute_set as attr_set_dict %}
{% if resource.fs_file_ids.1 %}
<img src="{% url 'get_gridfs_resource' resource.fs_file_ids.1 %}" alt="">
@@ -49,19 +49,8 @@ <h4 class="text-center card-content-title"><small>Description</small></h4>
{% if resource.tags %}
<div>
<h4 class="text-center card-content-title"><small>Tags</small></h4>
{# {{resource.tags.0}} #}
<div>
{% comment %}

{# <div class="label secondary">{{resource.tags.0}}</div>
<div class="label secondary">{{resource.tags.1}}</div>
<div class="label secondary">{{resource.tags.2}}</div>
<div class="label secondary">{{resource.tags.3}}</div>
<div class="label secondary">{{resource.tags.4}}</div>
<div class="label secondary">{{resource.tags.5}}</div>
{% if resource.tags.6 %} ... {% endif %}
#}
{% endcomment %}

{% for each_tag in resource.tags %}
{% if forloop.counter < 7 %}
<div class="label secondary"><a href="{% url 'tag_info' group_id each_tag %}">
@@ -77,6 +66,8 @@ <h4 class="text-center card-content-title"><small>Tags</small></h4>
{% endif %}

<!-- properties -->

{% comment %}
{% if resource.attribute_set %}
<div>
<h4 class="text-center card-content-title"><small>Properties</small></h4>
@@ -94,15 +85,18 @@ <h4 class="text-center card-content-title"><small>Properties</small></h4>

</div>
{% endif %}
{% endcomment %}

<!-- file info data -->
{% if "File" in resource.member_of_names_list %}
<div>
<h4 class="text-center card-content-title"><small>Resource Metadata</small></h4>
<div><b>Type</b>: {{resource.mime_type}}</div>
<div><b>Size</b>: {{resource.file_size.size}} {{resource.file_size.unit}}</div>
</div>
{% endif %}
{% comment %}
{% if "File" in resource.member_of_names_list %}
<div>
<h4 class="text-center card-content-title"><small>Resource Metadata</small></h4>
<div><b>Type</b>: {{resource.mime_type}}</div>
<div><b>Size</b>: {{resource.file_size.size}} {{resource.file_size.unit}}</div>
</div>
{% endif %}
{% endcomment %}

</div>
<!-- end of content -->
@@ -116,3 +110,12 @@ <h4 class="text-center card-content-title"><small>Resource Metadata</small></h4>
</span>
</div>
</div>

<script type="text/javascript">
$(document).ready(function () {
$('.rcard .content').slick({
// dots: true, fade: true,
infinite: true, arrows: true, speed: 500, cssEase: 'linear'
});
})
</script>