source: indico/indico/MaKaC/webinterface/rh/api.py @ fa6e07

hello-world-walkthroughipv6v0.98-seriesv0.98.2v0.98.3v0.98b2v0.99v1.0v1.1
Last change on this file since fa6e07 was fa6e07, checked in by Jose Benito <jose.benito.gonzalez@…>, 21 months ago

Add userid arg to api key management

  • Property mode set to 100644
File size: 1.6 KB
Line 
1# -*- coding: utf-8 -*-
2##
3##
4## This file is part of CDS Indico.
5## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 CERN.
6##
7## CDS Indico is free software; you can redistribute it and/or
8## modify it under the terms of the GNU General Public License as
9## published by the Free Software Foundation; either version 2 of the
10## License, or (at your option) any later version.
11##
12## CDS Indico is distributed in the hope that it will be useful, but
13## WITHOUT ANY WARRANTY; without even the implied warranty of
14## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15## General Public License for more details.
16##
17## You should have received a copy of the GNU General Public License
18## along with CDS Indico; if not, write to the Free Software Foundation, Inc.,
19## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
20
21from indico.web.http_api.auth import APIKey
22from MaKaC.webinterface.rh.users import RHUserBase
23from MaKaC.webinterface import urlHandlers
24from MaKaC.webinterface.pages.api import WPUserAPI
25from MaKaC.errors import AccessError
26
27class RHUserAPI(RHUserBase):
28    def _process(self):
29        p = WPUserAPI(self, self._avatar)
30        return p.display()
31
32class RHUserAPICreate(RHUserBase):
33    def _checkProtection(self):
34        RHUserBase._checkProtection(self)
35        ak = self._avatar.getAPIKey()
36        if ak and ak.isBlocked():
37            raise AccessError()
38
39    def _process(self):
40        ak = self._avatar.getAPIKey()
41        if not ak:
42            ak = APIKey(self._avatar)
43            ak.create()
44        else:
45            ak.newKey()
46        self._redirect(urlHandlers.UHUserAPI.getURL(self._avatar))
Note: See TracBrowser for help on using the repository browser.