root/galaxy-central/lib/galaxy/web/controllers/mobile.py @ 3

リビジョン 2, 2.5 KB (コミッタ: hatakeyama, 14 年 前)

import galaxy-central

行番号 
1from galaxy.web.base.controller import *
2
3class Mobile( BaseController ):
4    @web.expose
5    def index( self, trans, **kwargs ):
6        return trans.fill_template( "mobile/index.mako" )
7       
8    @web.expose
9    def history_list( self, trans ):
10        return trans.fill_template( "mobile/history/list.mako" )
11       
12    @web.expose
13    def history_detail( self, trans, id ):
14        history = trans.sa_session.query( trans.app.model.History ).get( id )
15        assert history.user == trans.user
16        return trans.fill_template( "mobile/history/detail.mako", history=history )
17
18    @web.expose
19    def dataset_detail( self, trans, id ):
20        dataset = trans.sa_session.query( trans.app.model.HistoryDatasetAssociation ).get( id )
21        assert dataset.history.user == trans.user
22        return trans.fill_template( "mobile/dataset/detail.mako", dataset=dataset )
23
24    @web.expose
25    def dataset_peek( self, trans, id ):
26        dataset = trans.sa_session.query( trans.app.model.HistoryDatasetAssociation ).get( id )
27        assert dataset.history.user == trans.user
28        return trans.fill_template( "mobile/dataset/peek.mako", dataset=dataset )
29       
30    @web.expose
31    def settings( self, trans, email=None, password=None ):
32        message = None
33        if email is not None and password is not None:
34            if email == "":
35                self.__logout( trans )
36                message = "Logged out"
37            else:
38                error = self.__login( trans, email, password )
39                message = error or "Login changed"
40        return trans.fill_template( "mobile/settings.mako", message=message )
41       
42    def __logout( self, trans ):
43        trans.log_event( "User logged out" )
44        trans.handle_user_logout()
45
46    def __login( self, trans, email="", password="" ):
47        error = password_error = None
48        user = trans.sa_session.query( model.User ).filter_by( email = email ).first()
49        if not user:
50            error = "No such user"
51        elif user.deleted:
52            error = "This account has been marked deleted, contact your Galaxy administrator to restore the account."
53        elif user.external:
54            error = "This account was created for use with an external authentication method, contact your local Galaxy administrator to activate it."
55        elif not user.check_password( password ):
56            error = "Invalid password"
57        else:
58            trans.handle_user_login( user, 'galaxy' )
59            trans.log_event( "User logged in" )
60        return error
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。