Esempio n. 1
0
import sys
import cog
path = os.path.dirname(cog.__file__)
sys.path.append(path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

from django.conf import settings
from django.contrib.auth.models import User
from django.core.exceptions import ObjectDoesNotExist

from django_openid_auth.models import UserOpenID

from cog.models import UserProfile
from cog.plugins.esgf.security import ESGFDatabaseManager

esgfDatabaseManager = ESGFDatabaseManager()

if settings.ESGF_CONFIG:

    # loop over CoG users
    for user in User.objects.all():

        # make sure user profile exists
        try:
            userp = user.profile
        except ObjectDoesNotExist:
            userp = UserProfile.objects.create(user=user)

        # select local users:
        if userp.type == 1:
Esempio n. 2
0
import sys
import cog
path = os.path.dirname(cog.__file__)
sys.path.append( path )
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

from django.contrib.auth.models import User
from cog.models import UserProfile

# cleanup from previous executions
for user in User.objects.filter(username='******'):
    user.delete()

# insert given user
from cog.plugins.esgf.security import ESGFDatabaseManager
esgfDatabaseManager = ESGFDatabaseManager()

user = User.objects.create(first_name='Test', last_name='User', username='******', email='*****@*****.**', password='******')
userProfile = UserProfile.objects.create(user=user, institution='Institution', city='City', state='State', country='Country')

#esgfUser = esgfDatabaseManager.insertUser(userProfile)
openid = ''
for userOpenID in user.useropenid_set.all():
    openid = userOpenID.claimed_id
    print 'User openid=%s' % openid

# verify user was inserted
esgfUser2 = esgfDatabaseManager.getUserByOpenid( openid )
print "Retrieved user with openid=%s" % esgfUser2.openid

# cleanup tgis execution
Esempio n. 3
0
import sys
import cog
path = os.path.dirname(cog.__file__)
sys.path.append( path )
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

from django.conf import settings
from django.contrib.auth.models import User
from django.core.exceptions import ObjectDoesNotExist

from django_openid_auth.models import UserOpenID

from cog.models import UserProfile
from cog.plugins.esgf.security import ESGFDatabaseManager

esgfDatabaseManager = ESGFDatabaseManager()

if settings.ESGF_CONFIG:
    
    # loop over CoG users
    for user in User.objects.all():
        
        # make sure user profile exists
        try:
            userp = user.profile
        except ObjectDoesNotExist:
            userp = UserProfile.objects.create(user=user)
            
        # select local users:
        if userp.type==1: