Exemplo n.º 1
0
def import_one(folder) :
  
    print ('%s, %s, %s, %s, %s' % (folder['title'], folder['mainparentuid'], folder['mainparenttype'], folder['parentuid'], folder['parenttype'])).encode('utf-8')
    if reverse.has_key(folder['mainparentuid']) :
        mainpar = folder['mainparentuid']
        print ("main parent: (%s,%s)" % (e_type(mainpar),title(mainpar))).encode('utf-8')
        if title(mainpar) != 'RESOURCES' :
            print title(mainpar).encode('utf-8')

        path  = []
        tags = []
        main = get_top_container(folder['uid'],path,tags)
        print (','.join(path)).encode('utf-8')
        print (','.join(['%s'% t for t in tags])).encode('utf-8')

        if main.__class__ == User :
            container = TgGroup.objects.get(group_name='resources')
            creator = main
            f_name=make_file_name(folder['id'],folder['uid']) 

            try :
                create_resource(container, creator, folder['id'], f_name, folder, tags)
            except Exception, e:
                print e
                import ipdb
                ipdb.set_trace()
                log.append(folder['uid'])

        elif main.__class__ == TgGroup :
            print "((()))",tags
            container = main
            creator_uid= folder['creatoruid']
            try:
                creator = get_user_for(creator_uid)
            except:
                print "No user corresponds to %s" % creator_uid
                print maps[creator_uid]

                creator = get_admin_user()
                print creator
                ipdb.set_trace()

            site_hosts = get_all_members_group().get_admin_group()
            if not creator.is_member_of(site_hosts) :
                site_hosts.add_member(creator)
                flag = True
            else :
                flag = False

            f_name = make_file_name(folder['id'],folder['uid'])
            try :
                create_resource(container, creator, folder['id'], f_name, folder, tags)
            except Exception, e :
                print e
                import ipdb
                ipdb.set_trace()
                log.append(folder['uid'])

            if flag :
                site_hosts.remove_member(creator)
def check_documents(lst):
    missing = []
    accounted = 0
    misplaced = []
    well_placed = 0
    for doc in lst:
        try:
            container = get_top_container(doc['uid'], [], [])
            title = doc['title']
            name = doc_name_from_title(title)
            match = match_page_and_document(doc)
            if not match:
                missing.append({'title': title})
            else:
                accounted = accounted + 1
                if match.in_agent.obj != container:
                    misplaced.append({
                        'doc': match,
                        'is': match.in_agent.obj,
                        'ought': container
                    })
                else:
                    well_placed = well_placed + 1
        except Exception, e:
            print e
            ipdb.set_trace()
def check_files(lst):
    missing = []
    misplaced = []
    accounted = 0
    well_placed = 0

    for file in lst:
        match = get_matching_id(file)

        uid = file['uid']
        container = get_top_container(uid, [], [])
        print file['state']

        if not match:

            missing.append({
                'uid': uid,
                'title': file['title'],
                'mainparentuid': file['mainparentuid']
            })
            print container, e_title(file['mainparentuid'])
            print file['title'].encode('utf-8')

        else:

            accounted = accounted + 1
            real_container = match.in_agent.obj
            if real_container != container:
                print real_container, container
                misplaced.append({
                    'upload': match,
                    'owner': match.created_by,
                    'in': real_container,
                    'ought': container
                })
            else:
                well_placed = well_placed + 1

    for m in missing:
        print m
    print "There are %s uploads missing" % len(missing)
    print "%s are ok" % accounted
    for m in misplaced:
        print m
    print "There are %s uploads misplaced" % len(misplaced)
    print "%s are well placed" % well_placed
def check_documents(lst) :
    missing = []
    accounted = 0
    misplaced = []
    well_placed = 0
    for doc in lst :
        try:
            container = get_top_container(doc['uid'],[],[])
            title = doc['title']
            name = doc_name_from_title(title)
            match = match_page_and_document(doc)
            if not match :
                missing.append({'title':title})
            else :
                accounted = accounted + 1
                if match.in_agent.obj != container :
                    misplaced.append({'doc':match,'is':match.in_agent.obj,'ought':container})
                else :
                    well_placed = well_placed+1
        except Exception, e:
            print e
            ipdb.set_trace()
def check_files(lst) :
    missing = []
    misplaced = []
    accounted = 0
    well_placed=0

    for file in lst :
        match = get_matching_id(file)

        uid = file['uid']
        container = get_top_container(uid,[],[])
        print file['state']
        

        if not match :

            missing.append({'uid':uid,'title':file['title'],'mainparentuid':file['mainparentuid']})
            print container, e_title(file['mainparentuid'])
            print file['title'].encode('utf-8')

        else :

            accounted=accounted+1
            real_container = match.in_agent.obj
            if real_container != container :
                print real_container, container
                misplaced.append({'upload':match,'owner':match.created_by, 'in':real_container,'ought':container})
            else :
                well_placed = well_placed + 1

    for m in missing :
        print m
    print "There are %s uploads missing" % len(missing)
    print "%s are ok" % accounted
    for m in misplaced :
        print m
    print "There are %s uploads misplaced" % len(misplaced)
    print "%s are well placed" % well_placed
Exemplo n.º 6
0
def import_one(folder):

    print('%s, %s, %s, %s, %s' %
          (folder['title'], folder['mainparentuid'], folder['mainparenttype'],
           folder['parentuid'], folder['parenttype'])).encode('utf-8')
    if reverse.has_key(folder['mainparentuid']):
        mainpar = folder['mainparentuid']
        print("main parent: (%s,%s)" %
              (e_type(mainpar), title(mainpar))).encode('utf-8')
        if title(mainpar) != 'RESOURCES':
            print title(mainpar).encode('utf-8')

        path = []
        tags = []
        main = get_top_container(folder['uid'], path, tags)
        print(','.join(path)).encode('utf-8')
        print(','.join(['%s' % t for t in tags])).encode('utf-8')

        if main.__class__ == User:
            container = TgGroup.objects.get(group_name='resources')
            creator = main
            f_name = make_file_name(folder['id'], folder['uid'])

            try:
                create_resource(container, creator, folder['id'], f_name,
                                folder, tags)
            except Exception, e:
                print e
                import ipdb
                ipdb.set_trace()
                log.append(folder['uid'])

        elif main.__class__ == TgGroup:
            print "((()))", tags
            container = main
            creator_uid = folder['creatoruid']
            try:
                creator = get_user_for(creator_uid)
            except:
                print "No user corresponds to %s" % creator_uid
                print maps[creator_uid]

                creator = get_admin_user()
                print creator
                ipdb.set_trace()

            site_hosts = get_all_members_group().get_admin_group()
            if not creator.is_member_of(site_hosts):
                site_hosts.add_member(creator)
                flag = True
            else:
                flag = False

            f_name = make_file_name(folder['id'], folder['uid'])
            try:
                create_resource(container, creator, folder['id'], f_name,
                                folder, tags)
            except Exception, e:
                print e
                import ipdb
                ipdb.set_trace()
                log.append(folder['uid'])

            if flag:
                site_hosts.remove_member(creator)
Exemplo n.º 7
0
from apps.plus_wiki.models import WikiPage
from psn_import.utils import load_all,maps, reverse, get_top_container, get_user_for, e_type, get_resources_group,tag_with, create_page
from apps.plus_permissions.default_agents import get_admin_user
from apps.plus_groups.models import name_from_title

load_all()

docs = maps['Document']
print docs[0].keys()

log= []
related_dict = {}
for doc in docs :
    path, tags = [],[]
    try :
        container = get_top_container(doc['uid'],path,tags)
        print
        print doc['title'].encode('utf-8'), container.get_display_name()
        creator_id = doc['creatoruid']
        if creator_id == -1 or creator_id == '-1' :
            user = get_admin_user()
        else :
            #print creator_id,e_type(creator_id)

            try :
                user = get_user_for(creator_id)
            except Exception, e:
                print e
                user = get_admin_user()

        #print doc['creators'],creator_id,user
Exemplo n.º 8
0
    print group['groupname'], group['uid']

for folder in maps['folders']:
    parent_uid = folder['mainparentuid']
    print
    print folder['title'], parent_uid

    print folder.keys()
    print folder['mainparenttype']
    if reverse.has_key(parent_uid):
        parent_type = reverse[parent_uid][0]
        if parent_type == 'groups':
            parent_group = reverse[parent_uid][1]
            print parent_type, parent_group['groupname']
            print "_)))", folder['children']
            top = get_top_container(folder['parentuid'])
            creator = get_creator(folder)

            for key, val in folder['children'].iteritems():
                print key, val
                if '.' in val:
                    f_name = '%s.%s' % (key, val.split('.', 1)[1])
                    print "Filename %s" % f_name
                    if create_resource(top, creator, val, f_name, folder):
                        good.append((top, creator, f_name))
                    else:
                        bad.append((top, creator, f_name))
                else:
                    import ipdb
                    ipdb.set_trace()
Exemplo n.º 9
0
    print group['groupname'],group['uid']

for folder in maps['folders'] :
    parent_uid = folder['mainparentuid']
    print 
    print folder['title'], parent_uid
    
    print folder.keys()
    print folder['mainparenttype']
    if reverse.has_key(parent_uid) :
        parent_type = reverse[parent_uid][0]
        if parent_type == 'groups' :
            parent_group = reverse[parent_uid][1]
            print parent_type, parent_group['groupname']
            print "_)))",folder['children']
            top = get_top_container(folder['parentuid'])
            creator = get_creator(folder)

            for key,val in folder['children'].iteritems() :
                print key, val
                if '.' in val :
                    f_name = '%s.%s' % (key, val.split('.',1)[1])
                    print "Filename %s"%f_name
                    if create_resource(top, creator, val, f_name, folder) :
                        good.append((top,creator,f_name))
                    else :
                        bad.append((top,creator,f_name))
                else :
                    import ipdb
                    ipdb.set_trace()
Exemplo n.º 10
0
from psn_import.utils import maps, reverse, load_all, get_top_container, psn_group_name, e_type
from psn_import.utils import title as e_title

from apps.plus_resources.models import Resource
import ipdb

userlog = []
if __name__ == '__main__' :
    load_all()
    for upload in maps['File'] :
        print 
        uid = upload['uid']
        title = upload['title']
        related = upload['related']        
            
        container = get_top_container(uid,[],[])
        
        print container, title.encode('utf-8'), related
        
        mainparentuid =  upload['mainparentuid']
        if reverse.has_key(mainparentuid) :
            print "mainparent %s, %s" % (e_type(mainparentuid),e_title(mainparentuid))
            mainparent = reverse[mainparentuid]
            try :
                if mainparent[1]['groupname'] != 'RESOURCES' :
                    print "Main parent title %s" % mainparent[1]['groupname']
            except Exception, e :
                print e
                if e_type(mainparentuid) == 'User' :
                    userlog.append({'uid':uid,'mainparentuid':mainparentuid,'owner':e_title(mainparentuid)})
                else :