Esempio n. 1
0
def management_user_manage():
    get_mongo_db("manage", DBConnFactory.TYPE_MONGOENGINE)
    users = MongoUser.objects()

    if request.method == 'POST':
        #
        # check for selection
        #
        if 'selectedusers' in request.form:
            data = dict(request.form)
            usernames = data['selectedusers']
            action = str(data['button'][0])

            if action == 'delete':

                for username in usernames:
                    user = MongoUser.objects(username=username)[0]
                    user.delete()

            else:

                for username in usernames:
                    user = MongoUser.objects(username=username)[0]
                    user.status = action
                    user.save()

    users = MongoUser.objects()
    return render_template('management/user_manage.html',
                           users=users,
                           with_edit="True",
                           states=['approve', 'pending', 'deny', 'block', 'delete'],
                           title="User Management")
Esempio n. 2
0
def management_user_manage():
    get_mongo_db("manage", DBConnFactory.TYPE_MONGOENGINE)
    users = MongoUser.objects()

    if request.method == 'POST':
        #
        # check for selection
        #
        if 'selectedusers' in request.form:
            data = dict(request.form)
            usernames = data['selectedusers']
            action = str(data['button'][0])

            if action == 'delete':

                for username in usernames:
                    user = MongoUser.objects(username=username)[0]
                    user.delete()

            else:

                for username in usernames:
                    user = MongoUser.objects(username=username)[0]
                    user.status = action
                    user.save()

    users = MongoUser.objects()
    return render_template(
        'management/user_manage.html',
        users=users,
        with_edit="True",
        states=['approve', 'pending', 'deny', 'block', 'delete'],
        title="User Management")
Esempio n. 3
0
def management_project_manage():
    get_mongo_db("manage", DBConnFactory.TYPE_MONGOENGINE)
    projects = MongoProject.objects()

    if request.method == 'POST':
        #
        # check for selection
        #
        if 'selectedprojects' in request.form:
            data = dict(request.form)
            project_ids = data['selectedprojects']
            action = str(data['button'][0])

            for projectid in project_ids:
                project = MongoProject.objects(projectid=projectid)[0]
                project.status = action
                project.save()
    get_mongo_db("manage", DBConnFactory.TYPE_MONGOENGINE)
    projects = MongoProject.objects()

    return render_template('management/project_manage.html',
                           projects=projects,
                           with_edit="True",
                           title="Project Management",
                           states=ProjectSTATUS)
Esempio n. 4
0
def management_project_list():
    get_mongo_db("manage", DBConnFactory.TYPE_MONGOENGINE)
    projects = MongoProject.objects()

    return render_template('management/project_list.html',
                           projects=projects,
                           with_edit="False",
                           title="Project List")
Esempio n. 5
0
def management_user_list():
    get_mongo_db("manage", DBConnFactory.TYPE_MONGOENGINE)

    users = MongoUser.objects()
    return render_template('management/user_manage.html',
                           users=users,
                           with_edit="False",
                           title="User List")
Esempio n. 6
0
    def __init__(self):
        config = ConfigDict(filename=config_file("/cloudmesh_server.yaml"))
        port = config['cloudmesh']['server']['mongo']['port']

        get_mongo_db("manage", DBConnFactory.TYPE_MONGOENGINE)
        #db = connect('manage', port=port)
        self.users = User.objects()

        # thism may be wrong
        meta = {"db_alias": "default"}
Esempio n. 7
0
    def validate_email_in_form(form, field):
        if ("@" not in field.data) or ("." not in field.data):
            raise ValidationError('The email address is not valid')

        for domain in exclude_email_domains:
            if domain in field.data:
                raise ValidationError(
                    'Email form the domain {0} are not alloed'.format(field.data))
        get_mongo_db("manage", DBConnFactory.TYPE_MONGOENGINE)
        users = Users()
        if not users.validate_email(field.data):
            raise ValidationError('A user with this email already exists')
Esempio n. 8
0
    def validate_email_in_form(form, field):
        if ("@" not in field.data) or ("." not in field.data):
            raise ValidationError('The email address is not valid')

        for domain in exclude_email_domains:
            if domain in field.data:
                raise ValidationError(
                    'Email form the domain {0} are not alloed'.format(
                        field.data))
        get_mongo_db("manage", DBConnFactory.TYPE_MONGOENGINE)
        users = Users()
        if not users.validate_email(field.data):
            raise ValidationError('A user with this email already exists')
Esempio n. 9
0
    def __init__(self, collection="cloudmesh"):
        """initializes the cloudmesh mongo db. The name of the collection os passed."""

        defaults_collection = 'defaults'
        passwd_collection = 'password'
        user_collection = "user"
        self.userdb_passwd = get_mongo_db(passwd_collection)
        self.db_defaults = get_mongo_db(defaults_collection)
        self.db_user = get_mongo_db(user_collection)

        self.db_clouds = get_mongo_db(collection)

        self.config = cm_config()
Esempio n. 10
0
    def __init__(self, collection="cloudmesh"):
        """initializes the cloudmesh mongo db. The name of the collection os passed."""

        defaults_collection = 'defaults'
        passwd_collection = 'password'
        user_collection = "user"
        self.userdb_passwd = get_mongo_db(passwd_collection)
        self.db_defaults = get_mongo_db(defaults_collection)
        self.db_user = get_mongo_db(user_collection)

        self.db_clouds = get_mongo_db(collection)

        self.config = cm_config()
Esempio n. 11
0
    def connect_db(self):
        """ Connect to the mongo db."""

        if not self.from_yaml:

            ldap_collection = 'user'
            cloud_collection = 'cloudmesh'
            defaults_collection = 'defaults'
            passwd_collection = 'password'

            self.db_clouds = get_mongo_db(cloud_collection)
            self.db_users = get_mongo_db(ldap_collection)
            self.db_defaults = get_mongo_db(defaults_collection)
            self.userdb_passwd = get_mongo_db(passwd_collection)
Esempio n. 12
0
    def connect_db(self):
        """ Connect to the mongo db."""

        if not self.from_yaml:

            ldap_collection = 'user'
            cloud_collection = 'cloudmesh'
            defaults_collection = 'defaults'
            passwd_collection = 'password'

            self.db_clouds = get_mongo_db(cloud_collection)
            self.db_users = get_mongo_db(ldap_collection)
            self.db_defaults = get_mongo_db(defaults_collection)
            self.userdb_passwd = get_mongo_db(passwd_collection)
Esempio n. 13
0
def project_profile(projectid):
    get_mongo_db("manage", DBConnFactory.TYPE_MONGOENGINE)
    try:
        project = MongoProject.objects(projectid=projectid)
        if project.count() == 1:

            return render_template('management/project_profile.html',
                                   project=project[0],
                                   title="Project Management")
        else:
            raise Exception
    except:
        print "Error: Project not found"
        return render_template('management/error.html',
                               error="The project does not exist")
Esempio n. 14
0
def project_profile(projectid):
    get_mongo_db("manage", DBConnFactory.TYPE_MONGOENGINE)
    try:
        project = MongoProject.objects(projectid=projectid)
        if project.count() == 1:

            return render_template('management/project_profile.html',
                                   project=project[0],
                                   title="Project Management")
        else:
            raise Exception
    except:
        print "Error: Project not found"
        return render_template('management/error.html',
                               error="The project does not exist")
Esempio n. 15
0
    def validate_username_in_form(form, field):
        if not re.match("^[a-z0-9]*$", field.data):
            raise ValidationError(
                'Only lower case characters a-z and numbers 0-9 allowed.')

        if not field.data.islower():
            raise ValidationError('The username must be lower case')

        get_mongo_db("manage", DBConnFactory.TYPE_MONGOENGINE)
        username = MongoUser.objects(username=field.data)
        if username.count() > 0:
            users = Users()
            proposal = users.get_unique_username(field.data)
            raise ValidationError(
                'A user with name already exists. Suggestion: {0}'.format(proposal))
Esempio n. 16
0
def management_user_edit(username):
    get_mongo_db("manage", DBConnFactory.TYPE_MONGOENGINE)

    try:
        user = MongoUser.objects(username=username)
    except:
        print "Error: Username not found"
        return render_template('error.html',
                               form=None,
                               type="exists",
                               msg="The user does not exist")

    if request.method == 'GET':

        return render_template('management/user_edit.html', user=user[0], states=['save', 'cancel'])

    elif request.method == 'POST':

        data = dict(request.form)

        action = str(data['button'][0])
        del data['button']
        for key in data:
            data[key] = data[key][0]

        user = MongoUser.objects(username=username)[0]
        if action == 'save':

            keys = ["bio",
                    "citizenship",
                    "firstname",
                    "lastname",
                    "title",
                    "url",
                    "address",
                    "institution",
                    "phone",
                    "advisor",
                    "department",
                    "country",
                    "email"]

            for key in keys:
                user[key] = data[key]

            user.save()

        return render_template('management/user_edit.html', user=user, states=['save', 'cancel'])
Esempio n. 17
0
    def validate_username_in_form(form, field):
        if not re.match("^[a-z0-9]*$", field.data):
            raise ValidationError(
                'Only lower case characters a-z and numbers 0-9 allowed.')

        if not field.data.islower():
            raise ValidationError('The username must be lower case')

        get_mongo_db("manage", DBConnFactory.TYPE_MONGOENGINE)
        username = MongoUser.objects(username=field.data)
        if username.count() > 0:
            users = Users()
            proposal = users.get_unique_username(field.data)
            raise ValidationError(
                'A user with name already exists. Suggestion: {0}'.format(
                    proposal))
Esempio n. 18
0
    def __init__(self):
        # read the host file definition from cloudmesh_cluster.yaml
        self.server_config = cm_config_server()

        self.config = ConfigDict(filename=self.CONFIG_FILE)

        collection = "inventory"
        self.db_inventory = get_mongo_db(collection)
Esempio n. 19
0
    def __init__(self):
        # read the host file definition from cloudmesh_cluster.yaml
        self.server_config = cm_config_server()

        self.config = ConfigDict(filename=self.CONFIG_FILE)

        collection = "inventory"
        self.db_inventory = get_mongo_db(collection)
Esempio n. 20
0
    def __init__(self, collection="profile"):

        self.data = {}
        self.server = cm_config_server()
        self.config = cm_config()

        self.db_clouds = get_mongo_db(collection)
        self._get_usernames_from_config()
    def __init__(self, collection="profile"):

        self.data = {}
        self.server = cm_config_server()
        self.config = cm_config()

        self.db_clouds = get_mongo_db(collection)
        self._get_usernames_from_config()
Esempio n. 22
0
def main():
    '''
    a test function to create 10 users and 3 projects
    '''
    # get a connection first
    get_mongo_db("manage", DBConnFactory.TYPE_MONGOENGINE)
    generate_users(10)
    generate_projects(3)

    print 70 * "="
    print users.find()
    print 70 * "="
    print 70 * "&"
    print users.find()[0]

    projects = Project.objects()
    print projects.count()
    pprint(projects[0])
Esempio n. 23
0
def main():
    '''
    a test function to create 10 users and 3 projects
    '''
    # get a connection first
    get_mongo_db("manage", DBConnFactory.TYPE_MONGOENGINE)
    generate_users(10)
    generate_projects(3)

    print 70 * "="
    print users.find()
    print 70 * "="
    print 70 * "&"
    print users.find()[0]

    projects = Project.objects()
    print projects.count()
    pprint(projects[0])
Esempio n. 24
0
def management_user_edit(username):
    get_mongo_db("manage", DBConnFactory.TYPE_MONGOENGINE)

    try:
        user = MongoUser.objects(username=username)
    except:
        print "Error: Username not found"
        return render_template('error.html',
                               form=None,
                               type="exists",
                               msg="The user does not exist")

    if request.method == 'GET':

        return render_template('management/user_edit.html',
                               user=user[0],
                               states=['save', 'cancel'])

    elif request.method == 'POST':

        data = dict(request.form)

        action = str(data['button'][0])
        del data['button']
        for key in data:
            data[key] = data[key][0]

        user = MongoUser.objects(username=username)[0]
        if action == 'save':

            keys = [
                "bio", "citizenship", "firstname", "lastname", "title", "url",
                "address", "institution", "phone", "advisor", "department",
                "country", "email"
            ]

            for key in keys:
                user[key] = data[key]

            user.save()

        return render_template('management/user_edit.html',
                               user=user,
                               states=['save', 'cancel'])
Esempio n. 25
0
    def __init__(self, collection="cloudmesh"):
        """initializes the cloudmesh mongo db. The name of the collection os passed."""

        # DEBUG
        try:
            _args = locals()
            del (_args['self'])
            log.debug("[{0}()] called with [{1}]".format(
                sys._getframe().f_code.co_name, str(_args)))
        except:
            pass

        defaults_collection = 'defaults'
        passwd_collection = 'password'
        user_collection = "user"
        self.userdb_passwd = get_mongo_db(passwd_collection)
        self.db_defaults = get_mongo_db(defaults_collection)
        self.db_user = get_mongo_db(user_collection)
        self.db_clouds = get_mongo_db(collection)

        self.config = cm_config()
Esempio n. 26
0
    def __init__(self, collection="cloudmesh"):
        """initializes the cloudmesh mongo db. The name of the collection os passed."""

        # DEBUG
        try:
            _args = locals()
            del (_args['self'])
            log.debug("[{0}()] called with [{1}]".format(sys._getframe().f_code.co_name,
                                                         str(_args)))
        except:
            pass

        defaults_collection = 'defaults'
        passwd_collection = 'password'
        user_collection = "user"
        self.userdb_passwd = get_mongo_db(passwd_collection)
        self.db_defaults = get_mongo_db(defaults_collection)
        self.db_user = get_mongo_db(user_collection)
        self.db_clouds = get_mongo_db(collection)

        self.config = cm_config()
Esempio n. 27
0
def management_user_profile(username):
    get_mongo_db("manage", DBConnFactory.TYPE_MONGOENGINE)
    try:
        user = MongoUser.objects(username=username)
        if user.count() == 1:
            for item in user:
                print item
            pprint(user[0])
            print user[0].username
            print user[0].firstname
            print user[0].lastname
            print user[0].country

            return render_template('management/user_profile.html', user=user[0])

        else:
            raise Exception
    except:
        print "Error: Username not found"
        return render_template('error.html',
                               form=None,
                               type="exists",
                               msg="The user does not exist")
Esempio n. 28
0
def management_user_profile(username):
    get_mongo_db("manage", DBConnFactory.TYPE_MONGOENGINE)
    try:
        user = MongoUser.objects(username=username)
        if user.count() == 1:
            for item in user:
                print item
            pprint(user[0])
            print user[0].username
            print user[0].firstname
            print user[0].lastname
            print user[0].country

            return render_template('management/user_profile.html',
                                   user=user[0])

        else:
            raise Exception
    except:
        print "Error: Username not found"
        return render_template('error.html',
                               form=None,
                               type="exists",
                               msg="The user does not exist")
Esempio n. 29
0
def management_project_manage():
    get_mongo_db("manage", DBConnFactory.TYPE_MONGOENGINE)
    projects = MongoProject.objects()

    if request.method == 'POST':
        #
        # check for selection
        #
        if 'selectedprojects' in request.form:
            data = dict(request.form)
            project_ids = data['selectedprojects']
            action = str(data['button'][0])

            for projectid in project_ids:
                project = MongoProject.objects(projectid=projectid)[0]
                project.status = action
                project.save()
    get_mongo_db("manage", DBConnFactory.TYPE_MONGOENGINE)
    projects = MongoProject.objects()

    return render_template('management/project_manage.html',
                           projects=projects, with_edit="True",
                           title="Project Management",
                           states=ProjectSTATUS)
Esempio n. 30
0
def display_usres_ldap():

    time_now = datetime.now().strftime("%Y-%m-%d %H:%M")

    collection = "user"
    db_users = get_mongo_db(collection)

    result = db_users.find({})
    data = {}
    for entry in result:
        id = entry['cm_user_id']
        data[id] = entry

    print data

    # print data

    return render_template('user/users_ldap.html',
                           updated=time_now,
                           users=data)
Esempio n. 31
0
def display_usres_ldap():

    time_now = datetime.now().strftime("%Y-%m-%d %H:%M")

    collection = "user"
    db_users = get_mongo_db(collection)

    result = db_users.find({})
    data = {}
    for entry in result:
        id = entry['cm_user_id']
        data[id] = entry

    print data

    # print data

    return render_template('user/users_ldap.html',
                           updated=time_now,
                           users=data)
Esempio n. 32
0
def management_user_list():
    get_mongo_db("manage", DBConnFactory.TYPE_MONGOENGINE)
    
    users = MongoUser.objects()
    return render_template('management/user_manage.html', users=users, with_edit="False", title="User List")
Esempio n. 33
0
 def __init__(self, coll_name="inventory"):
     """Construction
     :param string coll_name: the collection name
     """
     self.coll_name = coll_name
     self.db_client = get_mongo_db(coll_name)
Esempio n. 34
0
 def __init__(self, username):
     self.username = username
     get_mongo_db("experiment", DBConnFactory.TYPE_MONGOENGINE)
Esempio n. 35
0
 def __init__(self, coll_name="inventory"):
     """Construction
     :param string coll_name: the collection name
     """
     self.coll_name = coll_name
     self.db_client = get_mongo_db(coll_name)
Esempio n. 36
0
    def __init__(self, userid, label):

        self.userid = userid
        self.label = label
        get_mongo_db("experiment", DBConnFactory.TYPE_MONGOENGINE)
Esempio n. 37
0
def management_project_list():
    get_mongo_db("manage", DBConnFactory.TYPE_MONGOENGINE)
    projects = MongoProject.objects()

    return render_template('management/project_list.html', projects=projects, with_edit="False", title="Project List")
    def __init__(self, collection=None):

        if collection is None:
            collection = "metric"

        self.db_qstat = get_mongo_db(collections)
Esempio n. 39
0
 def __init__(self, collection="user"):
     """initializes the cloudmesh mongo db. The name of the collection os passed."""
     self.db_clouds = get_mongo_db(collection)
Esempio n. 40
0
 def __init__(self, username):
     self.username = username
     get_mongo_db("experiment", DBConnFactory.TYPE_MONGOENGINE)
Esempio n. 41
0
class User(CloudmeshObject):
    """This class is sued to represent a user"""

    get_mongo_db("manage", DBConnFactory.TYPE_MONGOENGINE)

    def order(self):
        '''
        order of the attribute to be printed
        '''
        try:
            return [
                ("username", self.username),
                ("status", self.status),
                ("title", self.title),
                ("firstname", self.firstname),
                ("lastname", self.lastname),
                ("email", self.email),
                ("url", self.url),
                ("citizenship", self.citizenship),
                ("bio", self.bio),
                ("password", self.password),
                ("phone", self.phone),
                ("projects", self.projects),
                ("institution", self.institution),
                ("institutionrole",self.institutionrole)
                ("department", self.department),
                ("address", self.address),
                ("country", self.country),
                ("advisor", self.advisor),
                ("date_modified", self.date_modified),
                ("date_created", self.date_created),
                ("date_approved", self.date_approved),
                ("date_deactivated", self.date_deactivated),
            ]
        except:
            return None

    def hidden(self):
        '''
        hidden attributes
        '''
        return [
            "userid",
            "active",
            "message",
        ]
    #
    # User Information
    #
    status = StringField(required=True, default='pending')
    username = StringField(required=True)
    password = StringField(required=True)
    #confirmpassword = StringField(required=True)
    title = StringField()
    firstname = StringField(required=True)
    lastname = StringField(required=True)
    email = EmailField(required=True)
    phone = StringField(required=True)
    url = StringField()
    citizenship = StringField(required=True)
    bio = StringField(required=True)

    userid = UUIDField()
    phone = StringField(required=True)


    projects = StringField()
    #
    # Affiliation
    #
    institution = StringField(required=True)
    institutionrole = StringField(required=True)
    department = StringField(required=True)
    address = StringField(required=True)
    country = StringField(required=True)
    advisor = StringField()
    # advisor = pointer to another user


    '''
    OpenID oAuth, Google ID, FacebookID, LinkedIn ID, 
    Bibliography ID, Researcher ID, ScopeUS ID, IEEE ID, Google Scholar ID

    Previous names, Previous Organizations, Optional Dates, Current Advisor Names & Emails 
    '''

    #
    # Message received from either reviewers,
    # committee or other users. It is a list because
    # there might be more than one message
    #
    message = ListField(StringField())

    # def save(self,db):
    # 	db.put({"firname":user.firname,...})

    def is_active(self):
        '''
        check if the user is active
        '''
        """finds if a user is active or not"""
        d1 = datetime.datetime.now()
        return (self.active == True) and (datetime.datetime.now() < self.date_deactivate)

    def set_password(self, password):
        '''
        not implemented

        :param password:
        :type password:
        '''
        #self.password_hash = generate_password_hash(password)
        pass

    def check_password(self, password):
        '''
        not implemented

        :param password:
        :type password:
        '''
        # return check_password_hash(self.password_hash, password)
        pass

    def json(self):
        '''
        returns a json representation of the object
        '''
        """prints the user as a json object"""
        d = {}
        for (field, value) in self.order():
            try:
                d[field] = value
            except:
                pass
        return d

    def yaml(self):
        '''
        returns the yaml object of the object.
        '''
        """prints the user as a json object"""
        return self.__str__(fields=True, all=True)
    """
Esempio n. 42
0
    def __init__(self, collection=None):

        if collection is None:
            collection = "metric"

        self.db_qstat = get_mongo_db(collections)
Esempio n. 43
0
                            style=3.0,
                            password="******")

    pprint(store)

    print store["gvonlasz"]["hp"]["credentials"]
    print store.credential("gvonlasz", "hp")

    #
    # experimenting to store yaml to mongo
    #

    collection = 'store'
    username = '******'

    db = get_mongo_db(collection)

    d = {'cm_user_id': username}

    # db.remove({'cm_user_id': username})
    db.update({'cm_user_id': username},
              {'cm_user_id': username,
               'clouds': store[username]},
              upsert=True)

    entries = db.find({})

    for e in entries:
        pprint(e)

    print entries.count()
Esempio n. 44
0
 def __init__(self):
     get_mongo_db("manage", DBConnFactory.TYPE_MONGOENGINE)
     self.projects = Project.objects()
     self.users = User.objects()
Esempio n. 45
0
    def __init__(self, userid, label):

        self.userid = userid
        self.label = label
        get_mongo_db("experiment", DBConnFactory.TYPE_MONGOENGINE)
Esempio n. 46
0
                            style=3.0,
                            password="******")

    pprint(store)

    print store["gvonlasz"]["hp"]["credentials"]
    print store.credential("gvonlasz", "hp")

    #
    # experimenting to store yaml to mongo
    #

    collection = 'store'
    username = '******'

    db = get_mongo_db(collection)

    d = {'cm_user_id': username}

    # db.remove({'cm_user_id': username})
    db.update({'cm_user_id': username}, {
        'cm_user_id': username,
        'clouds': store[username]
    },
              upsert=True)

    entries = db.find({})

    for e in entries:
        pprint(e)
Esempio n. 47
0
 def connect(self):
     self.db_mongo = get_mongo_db(self.cm_type)
Esempio n. 48
0
 def connect_db(self, coll_name):
     return get_mongo_db(coll_name)
Esempio n. 49
0
 def __init__(self, password=None):
     self.password = password
     collection = 'store'
     self.db = get_mongo_db(collection)
Esempio n. 50
0
 def connect_db(self, coll_name):
     return get_mongo_db(coll_name)
Esempio n. 51
0
    def __init__(self, collections=["qstat", "pbsnodes", "qinfo"]):

        self.db_qstat = get_mongo_db(collections[0])
        self.db_pbsnodes = get_mongo_db(collections[1])
        self.db_qinfo = get_mongo_db(collections[2])
Esempio n. 52
0
 def __init__(self, collections=["qstat", "pbsnodes", "qinfo"]):
     self.db_qstat = get_mongo_db(collections[0])
     self.db_pbsnodes = get_mongo_db(collections[1])
     self.db_qinfo = get_mongo_db(collections[2])
 def __init__(self, collection="user"):
     """initializes the cloudmesh mongo db. The name of the collection os passed."""
     self.db_clouds = get_mongo_db(collection)
Esempio n. 54
0
 def connect(cls):
     get_mongo_db("qsub", DBConnFactory.TYPE_MONGOENGINE)
Esempio n. 55
0
def project_edit(projectid):
    get_mongo_db("manage", DBConnFactory.TYPE_MONGOENGINE)

    try:
        project = MongoProject.objects(projectid=projectid)
    except:
        print "Error: pojectid not found"
        return render_template('management/error.html',
                               error="The project does not exist")

    if request.method == 'GET':

        return render_template('management/project_edit.html',
                               project=project[0], states=['save', 'cancel'],
                               title="Project Management")

    elif request.method == 'POST':

        data = dict(request.form)
        action = str(data['button'][0])
        # del data['button']
        for key in data:
            data[key] = data[key][0]

        project = project[0]

        if action == 'save':
            for d in data:
                print d, ":", data[d]
            try:
                project.title = data["title"]
                project.abstract = data["abstract"]
                project.intellectual_merit = data["intellectual_merit"]
                project.broader_impact = data["broader_impact"]
                project.use_of_fg = data["use_of_fg"]
                project.scale_of_use = data["scale_of_use"]
                """

                #
                # things that should not be changed
                #
                #project.active = data["active"]
                #project.status = data["status"]
                #project.projectid = data["projectid"]

                #
                # after apoproval this should not be changed either
                #
                project.agreement_use = data["agreement_use"]
                project.agreement_slides = data["agreement_slides"]
                project.agreement_support = data["agreement_support"]
                project.agreement_software = data["agreement_software"]
                project.agreement_documentation = data["agreement_documentation"]

                project.categories = data["categories"]
                project.keywords = data["keywords"]
                project.primary_discipline = data["primary_discipline"]
                project.orientation = data["orientation"]
                project.contact = data["contact"]
                project.url = data["url"]
                project.comment = data["comment"]


                project.lead = data["lead"]
                project.managers = data["managers"]
                project.members = data["members"]
                project.alumni = data["alumni"]
                project.grant_orgnization = data["grant_orgnization"]
                project.grant_id = data["grant_id"]
                project.grant_url = data["grant_url"]
                project.results = data["results"]
                project.comments = data["comments"]
                project.join_open = data["join_open"]
                project.join_notification = data["join_notification"]
                project.resources_services = data["resources_services"]
                project.resources_software = data["resources_software"]
                project.resources_clusters = data["resources_clusters"]
                project.resources_provision = data["resources_provision"]
                """
                project.save()

            except Exception, e:
                print "ERROR", e

        return render_template('management/project_edit.html',
                               project=project, states=['save', 'cancel'],
                               title="Project Management")
Esempio n. 56
0
# generates test users and projects

from mongoengine import *
# from other.user_dict import *
from cloudmesh.management.user import User, Users
from cloudmesh.management.project import Project, Projects
import sys
from faker import Factory
import uuid
from pprint import pprint

from cloudmesh.config.cm_config import get_mongo_db, DBConnFactory

# This is not encourged, as importing this file will try to establish a connection
get_mongo_db("manage", DBConnFactory.TYPE_MONGOENGINE)
# However this file was developed as an executable test/entrance so we leave it like this
# alternatively, change this to more Object Oriented way so the connection is
# only established when the object is instantiated.

# ----------------------------------------------------------
# The generate class generates 10 random users
# ----------------------------------------------------------

users = Users()
projects = Projects()

# http://www.joke2k.net/faker/

fake = Factory.create()

Esempio n. 57
0
 def connect(self):
     self.db_mongo = get_mongo_db(self.cm_type)
Esempio n. 58
0
 def __init__(self, password=None):
     self.password = password
     collection = 'store'
     self.db = get_mongo_db(collection)