~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to services/usrmgt-server

  • Committer: chadnickbok
  • Date: 2009-01-19 22:56:46 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:1170
This commit fixes issue #10 and part of issue #9

There are now two options for moving files with their
svn history intact; svn move and svn copy. These
use the svn commands to move the files, allowing students
to move and rename files without their histories being
lost.

This commit also shows the svn status of a dir, if it is
the 'head' of an svn repository.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
import logging
6
6
 
7
7
import ivle.conf
8
 
import ivle.database
 
8
import ivle.db
9
9
import ivle.chat
10
10
import ivle.makeuser
11
11
 
27
27
#   - Rebuild svn auth file
28
28
#   - Rebuild passwd + push to nodes.
29
29
 
30
 
def activate_user(store, props):
 
30
def activate_user(props):
31
31
    """Create the on-disk stuff for the given user.
32
32
       Sets the state of the user in the db from pending to enabled.
33
33
       Expected properties:
40
40
 
41
41
    login = props['login']
42
42
 
43
 
    # FIXME: check we're pending
44
 
 
45
 
    # Get the full User object from the db associated with this
46
 
    user = ivle.database.User.get_by_login(store, login)
47
 
 
48
 
    # make svn config/auth
49
 
    repopath = os.path.join(ivle.conf.svn_repo_path, 'users', login)
50
 
    logging.debug("Creating user's Subversion repository")
51
 
    ivle.makeuser.make_svn_repo(repopath, throw_on_error=True)
52
 
 
53
 
    rebuild_svn_config(store, props)
54
 
 
55
 
    logging.debug("Adding Subversion authentication")
56
 
    passwd = ivle.makeuser.make_svn_auth(store, login,
57
 
                                         throw_on_error=True)
58
 
 
59
 
    logging.debug("Creating jail")
60
 
    ivle.makeuser.make_jail(user)
61
 
 
62
 
    logging.info("Enabling user")
63
 
    user.state = u'enabled'
64
 
 
65
 
    return {"response": "okay"}
66
 
 
67
 
def rebuild_svn_config(store, props):
 
43
    db = ivle.db.DB()
 
44
 
 
45
    try:
 
46
 
 
47
        # FIXME: check we're pending
 
48
 
 
49
        details = db.get_user(login)
 
50
 
 
51
        # make svn config/auth
 
52
 
 
53
        repopath = os.path.join(ivle.conf.svn_repo_path, 'users', login)
 
54
        logging.debug("Creating user's Subversion repository")
 
55
        ivle.makeuser.make_svn_repo(repopath, throw_on_error=True)
 
56
 
 
57
        rebuild_svn_config(props)
 
58
 
 
59
        logging.debug("Adding Subversion authentication")
 
60
        passwd = ivle.makeuser.make_svn_auth(login, throw_on_error=True)
 
61
        logging.debug("passwd: %s" % passwd)
 
62
 
 
63
        logging.debug("Creating jail")
 
64
        ivle.makeuser.make_jail(login, details.unixid, svn_pass=passwd)
 
65
 
 
66
        logging.info("Enabling user")
 
67
        db.update_user(login, state='enabled')
 
68
 
 
69
        return {"response": "okay"}
 
70
 
 
71
    finally:
 
72
        db.close()
 
73
 
 
74
def rebuild_svn_config(props):
68
75
    """Rebuilds the svn config file
69
76
    Return value:
70
77
        response (okay, failure)
71
78
    """
72
79
    try:
73
 
        ivle.makeuser.rebuild_svn_config(store)
 
80
        ivle.makeuser.rebuild_svn_config()
74
81
    except Exception, e:
75
82
        logging.warning('Rebuild of Subversion authorization config failed!')
76
83
        return{'response': 'failure', 'msg': repr(e)}
77
84
 
78
85
    return {'response': 'okay'}
79
86
 
80
 
def rebuild_svn_group_config(store, props):
 
87
def rebuild_svn_group_config(props):
81
88
    """Rebuilds the svn group config file
82
89
    Return value:
83
90
        response (okay, failure)
84
91
    """
85
92
    try:
86
 
        ivle.makeuser.rebuild_svn_group_config(store)
 
93
        ivle.makeuser.rebuild_svn_group_config()
87
94
    except Exception, e:
88
95
        logging.warning(
89
96
            'Rebuild of Subversion group authorization config failed!')
91
98
 
92
99
    return {'response': 'okay'}
93
100
 
94
 
def create_group_repository(store, props):
 
101
def create_group_repository(props):
95
102
    """Creates on disk repository for the given group
96
103
    Expected properties:
97
104
        subj_short_name, year, semester, groupnm
134
141
 
135
142
def dispatch(props):
136
143
    logging.debug(repr(props))
137
 
 
138
 
    store = ivle.database.get_store()
139
144
    action = props.keys()[0]
140
 
    res = actions[action](store, props[action])
141
 
 
142
 
    if res['response'] == 'okay':
143
 
        store.commit()
144
 
    else:
145
 
        store.rollback()
146
 
    store.close()
147
 
    return res
 
145
    return actions[action](props[action])
148
146
 
149
147
if __name__ == "__main__":
150
148
    pid = os.getpid()