# Path: UniShared_python/website/models.py
# class Training(django_models.Model):
#     type = django_models.CharField(max_length=30)
#     resource_id = django_models.CharField(max_length=100, db_index=True)
#     is_live = django_models.BooleanField()
#     is_displayed = django_models.BooleanField()
#     is_featured = django_models.BooleanField()
#     is_deleted = django_models.BooleanField()
#     last_updated = django_models.IntegerField(default=1327217400)
#     title = django_models.CharField(max_length=256, db_index=True)
#     creator = django_models.ForeignKey(User, related_name='creator')
#     cowriters = django_models.ManyToManyField(User, related_name='cowriters')
#     participants = django_models.ManyToManyField(User, related_name='participants')
#     total_views = django_models.IntegerField(default=0)
#     total_views_open25 = django_models.IntegerField(default=0)
# 
#     objects = BatchManager()
# 
# class UserProfile(django_models.Model):
#     user = django_models.ForeignKey(User, unique=True)
#     
#     organization = django_models.ForeignKey(Organization, null=True)
#     is_organization_verified=django_models.BooleanField(default=True)
#     isUniStar = django_models.BooleanField()
#     is_student = django_models.NullBooleanField(default=True)
#     is_email_verified = django_models.BooleanField()
#     enable_notifications = django_models.BooleanField()
#     about_me = django_models.TextField(blank=True)
#     facebook_id = django_models.BigIntegerField(blank=True, unique=True, null=True)
#     facebook_profile_url = django_models.TextField(blank=True)
#     twitter_profile_url = django_models.TextField(blank=True)
#     linkedin_profile_url = django_models.TextField(blank=True)
#     website_url = django_models.TextField(blank=True)
#     image = django_models.ImageField(upload_to='profile_images')
#     last_seen = django_models.DateTimeField(null=True)
#     last_activity_ip = django_models.IPAddressField(null=True)
#     drive_folder_id = django_models.CharField(max_length=250, null=True)
#     can_create = django_models.BooleanField(default=False)
# 
# class Organization(django_models.Model):
#     name = django_models.CharField(max_length=100)
#     country = django_models.ForeignKey(Country, null=True)
#     members_role = django_models.CharField(max_length=30)
#     
#     def natural_key(self):
#         return (self.name,)
# 
#     def natural_key(self):
#         return (self.name,)
# 
# class CredentialsModel(django_models.Model):
#     id = django_models.ForeignKey(User, primary_key=True)
#     credential = CredentialsField()


import multiprocessing
import operator
import httplib2
import logging
import random
import time
import dns.resolver
import re
from collections import Iterable
from apiclient import errors
from apiclient.discovery import build
from apiclient.http import BatchHttpRequest
from django.core.urlresolvers import reverse
from oauth2client.django_orm import Storage
from django import forms
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.sessions.backends.db import SessionStore
from django.contrib.sessions.models import Session
from django.core.paginator import Paginator, EmptyPage, InvalidPage
from django.db.models import Q
from sorl.thumbnail import get_thumbnail
from UniShared_python.website.models import Training, UserProfile, Organization, CredentialsModel
from django.core.files.images import ImageFile
#!/usr/bin/python
# -*- coding: utf-8 -*-



__author__ = 'Arnaud'




class GoogleDriveHelper:
    __clientInstance = None

    DOCUMENTS_LIST_API_BATCH_URL = 'https://docs.google.com/feeds/default/private/full/batch'
    DOCUMENT_LIST_API_ITEM_TEMPLATE = 'https://docs.google.com/feeds/id/%s'
    RESOURCE_ID_REGEX = re.compile(DOCUMENT_LIST_API_ITEM_TEMPLATE % "document:([a-z0-9_-]+)", re.IGNORECASE)

    TITLE_FILTER = ['your new unishared\'s class', 'document title', 'untitled document', 'test', 'copy of template', 'unishared template', 'template']

    MAX_DOCUMENTS = 50

    @staticmethod
    def get_docs_client():
        """
        Return the unique instance of the Docs client
        """
        if GoogleDriveHelper.__clientInstance is None:
            user = User.objects.get(username='arnaud.breton')

# Path: UniShared_python/website/models.py
# class Training(django_models.Model):
#     type = django_models.CharField(max_length=30)
#     resource_id = django_models.CharField(max_length=100, db_index=True)
#     is_live = django_models.BooleanField()
#     is_displayed = django_models.BooleanField()
#     is_featured = django_models.BooleanField()
#     is_deleted = django_models.BooleanField()
#     last_updated = django_models.IntegerField(default=1327217400)
#     title = django_models.CharField(max_length=256, db_index=True)
#     creator = django_models.ForeignKey(User, related_name='creator')
#     cowriters = django_models.ManyToManyField(User, related_name='cowriters')
#     participants = django_models.ManyToManyField(User, related_name='participants')
#     total_views = django_models.IntegerField(default=0)
#     total_views_open25 = django_models.IntegerField(default=0)
# 
#     objects = BatchManager()
# 
# class UserProfile(django_models.Model):
#     user = django_models.ForeignKey(User, unique=True)
#     
#     organization = django_models.ForeignKey(Organization, null=True)
#     is_organization_verified=django_models.BooleanField(default=True)
#     isUniStar = django_models.BooleanField()
#     is_student = django_models.NullBooleanField(default=True)
#     is_email_verified = django_models.BooleanField()
#     enable_notifications = django_models.BooleanField()
#     about_me = django_models.TextField(blank=True)
#     facebook_id = django_models.BigIntegerField(blank=True, unique=True, null=True)
#     facebook_profile_url = django_models.TextField(blank=True)
#     twitter_profile_url = django_models.TextField(blank=True)
#     linkedin_profile_url = django_models.TextField(blank=True)
#     website_url = django_models.TextField(blank=True)
#     image = django_models.ImageField(upload_to='profile_images')
#     last_seen = django_models.DateTimeField(null=True)
#     last_activity_ip = django_models.IPAddressField(null=True)
#     drive_folder_id = django_models.CharField(max_length=250, null=True)
#     can_create = django_models.BooleanField(default=False)
# 
# class Organization(django_models.Model):
#     name = django_models.CharField(max_length=100)
#     country = django_models.ForeignKey(Country, null=True)
#     members_role = django_models.CharField(max_length=30)
#     
#     def natural_key(self):
#         return (self.name,)
# 
#     def natural_key(self):
#         return (self.name,)
# 
# class CredentialsModel(django_models.Model):
#     id = django_models.ForeignKey(User, primary_key=True)
#     credential = CredentialsField()


# Path: UniShared_python/website/helpers/helpers.py
import multiprocessing
import operator
import httplib2
import logging
import random
import time
import dns.resolver
import re
from collections import Iterable
from apiclient import errors
from apiclient.discovery import build
from apiclient.http import BatchHttpRequest
from django.core.urlresolvers import reverse
from oauth2client.django_orm import Storage
from django import forms
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.sessions.backends.db import SessionStore
from django.contrib.sessions.models import Session
from django.core.paginator import Paginator, EmptyPage, InvalidPage
from django.db.models import Q
from sorl.thumbnail import get_thumbnail
from UniShared_python.website.models import Training, UserProfile, Organization, CredentialsModel
from django.core.files.images import ImageFile

#!/usr/bin/python
# -*- coding: utf-8 -*-



__author__ = 'Arnaud'




class GoogleDriveHelper:
    __clientInstance = None

    DOCUMENTS_LIST_API_BATCH_URL = 'https://docs.google.com/feeds/default/private/full/batch'
    DOCUMENT_LIST_API_ITEM_TEMPLATE = 'https://docs.google.com/feeds/id/%s'
    RESOURCE_ID_REGEX = re.compile(DOCUMENT_LIST_API_ITEM_TEMPLATE % "document:([a-z0-9_-]+)", re.IGNORECASE)

    TITLE_FILTER = ['your new unishared\'s class', 'document title', 'untitled document', 'test', 'copy of template', 'unishared template', 'template']

    MAX_DOCUMENTS = 50

    @staticmethod
    def get_docs_client():
        """
        Return the unique instance of the Docs client
        """
        if GoogleDriveHelper.__clientInstance is None:
            user = User.objects.get(username='arnaud.breton')

            storage = Storage(CredentialsModel, 'id', user, 'credential')