<commit_before># imports from python libraries #######################################################################################################
import os
import hashlib
import datetime
import json

from random import random
from random import choice

# imports from installed packages #####################################################################################################
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.auth.models import check_password
from django.core.validators import RegexValidator
from django.db import models

from djangoratings.fields import RatingField

from django_mongokit import connection
from django_mongokit import get_database
from django_mongokit.document import DjangoDocument

from mongokit import CustomType
from mongokit import IS
from mongokit import OR

try:
    from bson import ObjectId
except ImportError:  # old pymongo
    from pymongo.objectid import ObjectId


# imports from application folders/files ##############################################################################################
from gnowsys_ndf.settings import RCS_REPO_DIR
from gnowsys_ndf.settings import RCS_REPO_DIR_HASH_LEVEL
from gnowsys_ndf.settings import MARKUP_LANGUAGE
from gnowsys_ndf.settings import MARKDOWN_EXTENSIONS

from gnowsys_ndf.ndf.rcslib import RCS

#######################################################################################################################################

NODE_TYPE_CHOICES = (
    ('Nodes'),
    ('Attribute Types'),
    ('Attributes'),
    ('Relation Types'),
    ('Relations'),
    ('GSystem Types'),
    ('GSystems'),
    ('Node Specification'),
    ('Attribute Specification'),
    ('Relation Specification'),
    ('Intersection'),
    ('Complement'),
    ('Union'),
    ('Process Types'),
    ('Process')
)

TYPES_OF_GROUP = (
    ('ANONYMOUS'),
    ('PUBLIC'),
    ('PRIVATE')
)

EDIT_POLICY = (
    ('NON_EDITABLE'),
    ('EDITABLE_MODERATED'),
    ('EDITABLE_NON_MODERATED')
)

SUBSCRIPTION_POLICY = (
    ('OPEN'),
    ('BY_REQUEST'),
    ('BY_INVITATION'),
)

EXISTANCE_POLICY = (
    ('ANNOUNCED'),
    ('NOT_ANNOUNCED')
)

LIST_MEMBER_POLICY = (
    ('DISCLOSED_TO_MEM'),
    ('NOT_DISCLOSED_TO_MEM')
)

ENCRYPTION_POLICY=(
    ('ENCRYPTED'),
    ('NOT_ENCRYPTED')
)

DATA_TYPE_CHOICES = (
    'None',
    'bool',
    'int',
    'float',
    'long',
    'basestring',
    'unicode',
    'list',
    'dict',
    'datetime.datetime',
    'bson.binary.Binary',
    'pymongo.objectid.ObjectId',
    'bson.dbref.DBRef',
    'bson.code.Code',
    'type(re.compile(""))',
    'uuid.UUID',
    'CustomType'
)

#######################################################################################################################################
# CUSTOM DATA-TYPE DEFINITIONS
#######################################################################################################################################

STATUS_CHOICES_TU = IS(u'DRAFT', u'HIDDEN', u'PUBLISHED')
STATUS_CHOICES = tuple(str(qtc) for qtc in STATUS_CHOICES_TU)

QUIZ_TYPE_CHOICES_TU = IS(u'Short-Response', u'Single-Choice', u'Multiple-Choice')
QUIZ_TYPE_CHOICES = tuple(str(qtc) for qtc in QUIZ_TYPE_CHOICES_TU)

class RatingField(CustomType):
    mongo_type = unicode
    python_type = int
    def to_bson(self, value):
        """convert type to a mongodb type"""
        return unicode(value)

    def to_python(self, value):
        """convert type to a python object"""
        if value is not None:
            return value
        # else:
        #     return "value must be between 0 and 5"


#######################################################################################################################################
# FRAME CLASS DEFINITIONS
#######################################################################################################################################

@connection.register
class Node(DjangoDocument):

    objects = models.Manager()

    collection_name = 'Nodes'
    structure = {
        '_type': unicode,
        'name': unicode,
        'altnames': unicode,
        'plural': unicode,
        'prior_node': [ObjectId],
        'post_node': [ObjectId],
        
        'language': unicode,

        'type_of': ObjectId,        # To define type_of GSystemType for particular node              
        'member_of': [ObjectId],
        'access_policy': unicode,               # To Create Public or Private node

      	'created_at': datetime.datetime,
        'last_update': datetime.datetime,
        # 'rating': RatingField(),
        'created_by': int,			# Primary Key of User(django's) Class
        'modified_by': [int],		        # List of Primary Keys of User(django's) Class
        'location': dict,

        'start_publication': datetime.datetime,

        'content': unicode,
        'content_org': unicode,

        'collection_set': [ObjectId],		# List of ObjectId's of different GTypes/GSystems

        'tags': [unicode],
        'featured': bool,
        'url': unicode,
        'comment_enabled': bool,
      	'login_required': bool,
      	# 'password': <PASSWORD>,

        'status': STATUS_CHOICES_TU
    }
    <commit_msg>location field's data-type changed from 'dict' to '[dict]'<commit_after># imports from python libraries #######################################################################################################
import os
import hashlib
import datetime
import json

from random import random
from random import choice

# imports from installed packages #####################################################################################################
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.auth.models import check_password
from django.core.validators import RegexValidator
from django.db import models

from djangoratings.fields import RatingField

from django_mongokit import connection
from django_mongokit import get_database
from django_mongokit.document import DjangoDocument

from mongokit import CustomType
from mongokit import IS
from mongokit import OR

try:
    from bson import ObjectId
except ImportError:  # old pymongo
    from pymongo.objectid import ObjectId


# imports from application folders/files ##############################################################################################
from gnowsys_ndf.settings import RCS_REPO_DIR
from gnowsys_ndf.settings import RCS_REPO_DIR_HASH_LEVEL
from gnowsys_ndf.settings import MARKUP_LANGUAGE
from gnowsys_ndf.settings import MARKDOWN_EXTENSIONS

from gnowsys_ndf.ndf.rcslib import RCS

#######################################################################################################################################

NODE_TYPE_CHOICES = (
    ('Nodes'),
    ('Attribute Types'),
    ('Attributes'),
    ('Relation Types'),
    ('Relations'),
    ('GSystem Types'),
    ('GSystems'),
    ('Node Specification'),
    ('Attribute Specification'),
    ('Relation Specification'),
    ('Intersection'),
    ('Complement'),
    ('Union'),
    ('Process Types'),
    ('Process')
)

TYPES_OF_GROUP = (
    ('ANONYMOUS'),
    ('PUBLIC'),
    ('PRIVATE')
)

EDIT_POLICY = (
    ('NON_EDITABLE'),
    ('EDITABLE_MODERATED'),
    ('EDITABLE_NON_MODERATED')
)

SUBSCRIPTION_POLICY = (
    ('OPEN'),
    ('BY_REQUEST'),
    ('BY_INVITATION'),
)

EXISTANCE_POLICY = (
    ('ANNOUNCED'),
    ('NOT_ANNOUNCED')
)

LIST_MEMBER_POLICY = (
    ('DISCLOSED_TO_MEM'),
    ('NOT_DISCLOSED_TO_MEM')
)

ENCRYPTION_POLICY=(
    ('ENCRYPTED'),
    ('NOT_ENCRYPTED')
)

DATA_TYPE_CHOICES = (
    'None',
    'bool',
    'int',
    'float',
    'long',
    'basestring',
    'unicode',
    'list',
    'dict',
    'datetime.datetime',
    'bson.binary.Binary',
    'pymongo.objectid.ObjectId',
    'bson.dbref.DBRef',
    'bson.code.Code',
    'type(re.compile(""))',
    'uuid.UUID',
    'CustomType'
)

#######################################################################################################################################
# CUSTOM DATA-TYPE DEFINITIONS
#######################################################################################################################################

STATUS_CHOICES_TU = IS(u'DRAFT', u'HIDDEN', u'PUBLISHED')
STATUS_CHOICES = tuple(str(qtc) for qtc in STATUS_CHOICES_TU)

QUIZ_TYPE_CHOICES_TU = IS(u'Short-Response', u'Single-Choice', u'Multiple-Choice')
QUIZ_TYPE_CHOICES = tuple(str(qtc) for qtc in QUIZ_TYPE_CHOICES_TU)

class RatingField(CustomType):
    mongo_type = unicode
    python_type = int
    def to_bson(self, value):
        """convert type to a mongodb type"""
        return unicode(value)

    def to_python(self, value):
        """convert type to a python object"""
        if value is not None:
            return value
        # else:
        #     return "value must be between 0 and 5"


#######################################################################################################################################
# FRAME CLASS DEFINITIONS
#######################################################################################################################################

@connection.register
class Node(DjangoDocument):

    objects = models.Manager()

    collection_name = 'Nodes'
    structure = {
        '_type': unicode,
        'name': unicode,
        'altnames': unicode,
        'plural': unicode,
        'prior_node': [ObjectId],
        'post_node': [ObjectId],
        
        'language': unicode,

        'type_of': ObjectId,        # To define type_of GSystemType for particular node              
        'member_of': [ObjectId],
        'access_policy': unicode,               # To Create Public or Private node

      	'created_at': datetime.datetime,
        'created_by': int,			# Primary Key of User(django's) Class

        'last_update': datetime.datetime,
        'modified_by': [int],		        # List of Primary Keys of User(django's) Class

        # 'rating': RatingField(),

        'location': [dict],

        'content': unicode,
        'content_org': unicode,

        'collection_set': [ObjectId],		# List of ObjectId's of different GTypes/GSystems

        'start_publication': datetime.datetime,
        'tags': [unicode],
        'featured': bool,
        'url': unicode,
        'comment_enabled': bool,
      	'login_required': bool,
      	# 'password': <PASSWORD>,

        'status': STATUS_CHOICES_TU
    }
    
{'fraction_non_alphanumeric': 0.28047732696897376, 'fraction_numerical': 0.00038186157517899763, 'mean_word_length': 4.058425881216803, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5509755', 'n_tokens_mistral': 3026, 'n_tokens_neox': 2835, 'n_words': 673}