##// END OF EJS Templates
users: added SSH key management for user admin pages
marcink -
r1993:dab53d0e default
parent child Browse files
Show More
@@ -0,0 +1,173 b''
1 # -*- coding: utf-8 -*-
2
3 # Copyright (C) 2010-2017 RhodeCode GmbH
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License, version 3
7 # (only), as published by the Free Software Foundation.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 #
17 # This program is dual-licensed. If you wish to learn more about the
18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
21 import pytest
22
23 from rhodecode.model.db import User, UserSshKeys
24
25 from rhodecode.tests import TestController, assert_session_flash
26 from rhodecode.tests.fixture import Fixture
27
28 fixture = Fixture()
29
30
31 def route_path(name, params=None, **kwargs):
32 import urllib
33 from rhodecode.apps._base import ADMIN_PREFIX
34
35 base_url = {
36 'edit_user_ssh_keys':
37 ADMIN_PREFIX + '/users/{user_id}/edit/ssh_keys',
38 'edit_user_ssh_keys_generate_keypair':
39 ADMIN_PREFIX + '/users/{user_id}/edit/ssh_keys/generate',
40 'edit_user_ssh_keys_add':
41 ADMIN_PREFIX + '/users/{user_id}/edit/ssh_keys/new',
42 'edit_user_ssh_keys_delete':
43 ADMIN_PREFIX + '/users/{user_id}/edit/ssh_keys/delete',
44
45 }[name].format(**kwargs)
46
47 if params:
48 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
49 return base_url
50
51
52 class TestAdminUsersSshKeysView(TestController):
53 INVALID_KEY = """\
54 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDk+77sjDzVeB6vevJsuZds1iNU5
55 LANOa5CU5G/9JYIA6RYsWWMO7mbsR82IUckdqOHmxSykfR1D1TdluyIpQLrwgH5kb
56 n8FkVI8zBMCKakxowvN67B0R7b1BT4PPzW2JlOXei/m9W12ZY484VTow6/B+kf2Q8
57 cP8tmCJmKWZma5Em7OTUhvjyQVNz3v7HfeY5Hq0Ci4ECJ59hepFDabJvtAXg9XrI6
58 jvdphZTc30I4fG8+hBHzpeFxUGvSGNtXPUbwaAY8j/oHYrTpMgkj6pUEFsiKfC5zP
59 qPFR5HyKTCHW0nFUJnZsbyFT5hMiF/hZkJc9A0ZbdSvJwCRQ/g3bmdL
60 your_email@example.com
61 """
62 VALID_KEY = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDk+77sjDzVeB6vev' \
63 'JsuZds1iNU5LANOa5CU5G/9JYIA6RYsWWMO7mbsR82IUckdqOHmxSy' \
64 'kfR1D1TdluyIpQLrwgH5kbn8FkVI8zBMCKakxowvN67B0R7b1BT4PP' \
65 'zW2JlOXei/m9W12ZY484VTow6/B+kf2Q8cP8tmCJmKWZma5Em7OTUh' \
66 'vjyQVNz3v7HfeY5Hq0Ci4ECJ59hepFDabJvtAXg9XrI6jvdphZTc30' \
67 'I4fG8+hBHzpeFxUGvSGNtXPUbwaAY8j/oHYrTpMgkj6pUEFsiKfC5zPq' \
68 'PFR5HyKTCHW0nFUJnZsbyFT5hMiF/hZkJc9A0ZbdSvJwCRQ/g3bmdL ' \
69 'your_email@example.com'
70
71 def test_ssh_keys_default_user(self):
72 self.log_user()
73 user = User.get_default_user()
74 self.app.get(
75 route_path('edit_user_ssh_keys', user_id=user.user_id),
76 status=302)
77
78 def test_add_ssh_key_error(self, user_util):
79 self.log_user()
80 user = user_util.create_user()
81 user_id = user.user_id
82
83 key_data = self.INVALID_KEY
84
85 desc = 'MY SSH KEY'
86 response = self.app.post(
87 route_path('edit_user_ssh_keys_add', user_id=user_id),
88 {'description': desc, 'key_data': key_data,
89 'csrf_token': self.csrf_token})
90 assert_session_flash(response, 'An error occurred during ssh '
91 'key saving: Unable to decode the key')
92
93 def test_ssh_key_duplicate(self, user_util):
94 self.log_user()
95 user = user_util.create_user()
96 user_id = user.user_id
97
98 key_data = self.VALID_KEY
99
100 desc = 'MY SSH KEY'
101 response = self.app.post(
102 route_path('edit_user_ssh_keys_add', user_id=user_id),
103 {'description': desc, 'key_data': key_data,
104 'csrf_token': self.csrf_token})
105 assert_session_flash(response, 'Ssh Key successfully created')
106 response.follow() # flush session flash
107
108 # add the same key AGAIN
109 desc = 'MY SSH KEY'
110 response = self.app.post(
111 route_path('edit_user_ssh_keys_add', user_id=user_id),
112 {'description': desc, 'key_data': key_data,
113 'csrf_token': self.csrf_token})
114 assert_session_flash(response, 'An error occurred during ssh key '
115 'saving: Such key already exists, '
116 'please use a different one')
117
118 def test_add_ssh_key(self, user_util):
119 self.log_user()
120 user = user_util.create_user()
121 user_id = user.user_id
122
123 key_data = self.VALID_KEY
124
125 desc = 'MY SSH KEY'
126 response = self.app.post(
127 route_path('edit_user_ssh_keys_add', user_id=user_id),
128 {'description': desc, 'key_data': key_data,
129 'csrf_token': self.csrf_token})
130 assert_session_flash(response, 'Ssh Key successfully created')
131
132 response = response.follow()
133 response.mustcontain(desc)
134
135 def test_delete_ssh_key(self, user_util):
136 self.log_user()
137 user = user_util.create_user()
138 user_id = user.user_id
139
140 key_data = self.VALID_KEY
141
142 desc = 'MY SSH KEY'
143 response = self.app.post(
144 route_path('edit_user_ssh_keys_add', user_id=user_id),
145 {'description': desc, 'key_data': key_data,
146 'csrf_token': self.csrf_token})
147 assert_session_flash(response, 'Ssh Key successfully created')
148 response = response.follow() # flush the Session flash
149
150 # now delete our key
151 keys = UserSshKeys.query().filter(UserSshKeys.user_id == user_id).all()
152 assert 1 == len(keys)
153
154 response = self.app.post(
155 route_path('edit_user_ssh_keys_delete', user_id=user_id),
156 {'del_ssh_key': keys[0].ssh_key_id,
157 'csrf_token': self.csrf_token})
158
159 assert_session_flash(response, 'Ssh key successfully deleted')
160 keys = UserSshKeys.query().filter(UserSshKeys.user_id == user_id).all()
161 assert 0 == len(keys)
162
163 def test_generate_keypair(self, user_util):
164 self.log_user()
165 user = user_util.create_user()
166 user_id = user.user_id
167
168 response = self.app.get(
169 route_path('edit_user_ssh_keys_generate_keypair', user_id=user_id))
170
171 response.mustcontain('Private key')
172 response.mustcontain('Public key')
173 response.mustcontain('-----BEGIN RSA PRIVATE KEY-----')
This diff has been collapsed as it changes many lines, (4172 lines changed) Show them Hide them
@@ -0,0 +1,4172 b''
1 # -*- coding: utf-8 -*-
2
3 # Copyright (C) 2010-2017 RhodeCode GmbH
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License, version 3
7 # (only), as published by the Free Software Foundation.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 #
17 # This program is dual-licensed. If you wish to learn more about the
18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
21 """
22 Database Models for RhodeCode Enterprise
23 """
24
25 import re
26 import os
27 import time
28 import hashlib
29 import logging
30 import datetime
31 import warnings
32 import ipaddress
33 import functools
34 import traceback
35 import collections
36
37
38 from sqlalchemy import *
39 from sqlalchemy.ext.declarative import declared_attr
40 from sqlalchemy.ext.hybrid import hybrid_property
41 from sqlalchemy.orm import (
42 relationship, joinedload, class_mapper, validates, aliased)
43 from sqlalchemy.sql.expression import true
44 from sqlalchemy.sql.functions import coalesce, count # noqa
45 from beaker.cache import cache_region
46 from zope.cachedescriptors.property import Lazy as LazyProperty
47
48 from pyramid.threadlocal import get_current_request
49
50 from rhodecode.translation import _
51 from rhodecode.lib.vcs import get_vcs_instance
52 from rhodecode.lib.vcs.backends.base import EmptyCommit, Reference
53 from rhodecode.lib.utils2 import (
54 str2bool, safe_str, get_commit_safe, safe_unicode, md5_safe,
55 time_to_datetime, aslist, Optional, safe_int, get_clone_url, AttributeDict,
56 glob2re, StrictAttributeDict, cleaned_uri)
57 from rhodecode.lib.jsonalchemy import MutationObj, MutationList, JsonType
58 from rhodecode.lib.ext_json import json
59 from rhodecode.lib.caching_query import FromCache
60 from rhodecode.lib.encrypt import AESCipher
61
62 from rhodecode.model.meta import Base, Session
63
64 URL_SEP = '/'
65 log = logging.getLogger(__name__)
66
67 # =============================================================================
68 # BASE CLASSES
69 # =============================================================================
70
71 # this is propagated from .ini file rhodecode.encrypted_values.secret or
72 # beaker.session.secret if first is not set.
73 # and initialized at environment.py
74 ENCRYPTION_KEY = None
75
76 # used to sort permissions by types, '#' used here is not allowed to be in
77 # usernames, and it's very early in sorted string.printable table.
78 PERMISSION_TYPE_SORT = {
79 'admin': '####',
80 'write': '###',
81 'read': '##',
82 'none': '#',
83 }
84
85
86 def display_sort(obj):
87 """
88 Sort function used to sort permissions in .permissions() function of
89 Repository, RepoGroup, UserGroup. Also it put the default user in front
90 of all other resources
91 """
92
93 if obj.username == User.DEFAULT_USER:
94 return '#####'
95 prefix = PERMISSION_TYPE_SORT.get(obj.permission.split('.')[-1], '')
96 return prefix + obj.username
97
98
99 def _hash_key(k):
100 return md5_safe(k)
101
102
103 class EncryptedTextValue(TypeDecorator):
104 """
105 Special column for encrypted long text data, use like::
106
107 value = Column("encrypted_value", EncryptedValue(), nullable=False)
108
109 This column is intelligent so if value is in unencrypted form it return
110 unencrypted form, but on save it always encrypts
111 """
112 impl = Text
113
114 def process_bind_param(self, value, dialect):
115 if not value:
116 return value
117 if value.startswith('enc$aes$') or value.startswith('enc$aes_hmac$'):
118 # protect against double encrypting if someone manually starts
119 # doing
120 raise ValueError('value needs to be in unencrypted format, ie. '
121 'not starting with enc$aes')
122 return 'enc$aes_hmac$%s' % AESCipher(
123 ENCRYPTION_KEY, hmac=True).encrypt(value)
124
125 def process_result_value(self, value, dialect):
126 import rhodecode
127
128 if not value:
129 return value
130
131 parts = value.split('$', 3)
132 if not len(parts) == 3:
133 # probably not encrypted values
134 return value
135 else:
136 if parts[0] != 'enc':
137 # parts ok but without our header ?
138 return value
139 enc_strict_mode = str2bool(rhodecode.CONFIG.get(
140 'rhodecode.encrypted_values.strict') or True)
141 # at that stage we know it's our encryption
142 if parts[1] == 'aes':
143 decrypted_data = AESCipher(ENCRYPTION_KEY).decrypt(parts[2])
144 elif parts[1] == 'aes_hmac':
145 decrypted_data = AESCipher(
146 ENCRYPTION_KEY, hmac=True,
147 strict_verification=enc_strict_mode).decrypt(parts[2])
148 else:
149 raise ValueError(
150 'Encryption type part is wrong, must be `aes` '
151 'or `aes_hmac`, got `%s` instead' % (parts[1]))
152 return decrypted_data
153
154
155 class BaseModel(object):
156 """
157 Base Model for all classes
158 """
159
160 @classmethod
161 def _get_keys(cls):
162 """return column names for this model """
163 return class_mapper(cls).c.keys()
164
165 def get_dict(self):
166 """
167 return dict with keys and values corresponding
168 to this model data """
169
170 d = {}
171 for k in self._get_keys():
172 d[k] = getattr(self, k)
173
174 # also use __json__() if present to get additional fields
175 _json_attr = getattr(self, '__json__', None)
176 if _json_attr:
177 # update with attributes from __json__
178 if callable(_json_attr):
179 _json_attr = _json_attr()
180 for k, val in _json_attr.iteritems():
181 d[k] = val
182 return d
183
184 def get_appstruct(self):
185 """return list with keys and values tuples corresponding
186 to this model data """
187
188 l = []
189 for k in self._get_keys():
190 l.append((k, getattr(self, k),))
191 return l
192
193 def populate_obj(self, populate_dict):
194 """populate model with data from given populate_dict"""
195
196 for k in self._get_keys():
197 if k in populate_dict:
198 setattr(self, k, populate_dict[k])
199
200 @classmethod
201 def query(cls):
202 return Session().query(cls)
203
204 @classmethod
205 def get(cls, id_):
206 if id_:
207 return cls.query().get(id_)
208
209 @classmethod
210 def get_or_404(cls, id_):
211 from pyramid.httpexceptions import HTTPNotFound
212
213 try:
214 id_ = int(id_)
215 except (TypeError, ValueError):
216 raise HTTPNotFound()
217
218 res = cls.query().get(id_)
219 if not res:
220 raise HTTPNotFound()
221 return res
222
223 @classmethod
224 def getAll(cls):
225 # deprecated and left for backward compatibility
226 return cls.get_all()
227
228 @classmethod
229 def get_all(cls):
230 return cls.query().all()
231
232 @classmethod
233 def delete(cls, id_):
234 obj = cls.query().get(id_)
235 Session().delete(obj)
236
237 @classmethod
238 def identity_cache(cls, session, attr_name, value):
239 exist_in_session = []
240 for (item_cls, pkey), instance in session.identity_map.items():
241 if cls == item_cls and getattr(instance, attr_name) == value:
242 exist_in_session.append(instance)
243 if exist_in_session:
244 if len(exist_in_session) == 1:
245 return exist_in_session[0]
246 log.exception(
247 'multiple objects with attr %s and '
248 'value %s found with same name: %r',
249 attr_name, value, exist_in_session)
250
251 def __repr__(self):
252 if hasattr(self, '__unicode__'):
253 # python repr needs to return str
254 try:
255 return safe_str(self.__unicode__())
256 except UnicodeDecodeError:
257 pass
258 return '<DB:%s>' % (self.__class__.__name__)
259
260
261 class RhodeCodeSetting(Base, BaseModel):
262 __tablename__ = 'rhodecode_settings'
263 __table_args__ = (
264 UniqueConstraint('app_settings_name'),
265 {'extend_existing': True, 'mysql_engine': 'InnoDB',
266 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
267 )
268
269 SETTINGS_TYPES = {
270 'str': safe_str,
271 'int': safe_int,
272 'unicode': safe_unicode,
273 'bool': str2bool,
274 'list': functools.partial(aslist, sep=',')
275 }
276 DEFAULT_UPDATE_URL = 'https://rhodecode.com/api/v1/info/versions'
277 GLOBAL_CONF_KEY = 'app_settings'
278
279 app_settings_id = Column("app_settings_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
280 app_settings_name = Column("app_settings_name", String(255), nullable=True, unique=None, default=None)
281 _app_settings_value = Column("app_settings_value", String(4096), nullable=True, unique=None, default=None)
282 _app_settings_type = Column("app_settings_type", String(255), nullable=True, unique=None, default=None)
283
284 def __init__(self, key='', val='', type='unicode'):
285 self.app_settings_name = key
286 self.app_settings_type = type
287 self.app_settings_value = val
288
289 @validates('_app_settings_value')
290 def validate_settings_value(self, key, val):
291 assert type(val) == unicode
292 return val
293
294 @hybrid_property
295 def app_settings_value(self):
296 v = self._app_settings_value
297 _type = self.app_settings_type
298 if _type:
299 _type = self.app_settings_type.split('.')[0]
300 # decode the encrypted value
301 if 'encrypted' in self.app_settings_type:
302 cipher = EncryptedTextValue()
303 v = safe_unicode(cipher.process_result_value(v, None))
304
305 converter = self.SETTINGS_TYPES.get(_type) or \
306 self.SETTINGS_TYPES['unicode']
307 return converter(v)
308
309 @app_settings_value.setter
310 def app_settings_value(self, val):
311 """
312 Setter that will always make sure we use unicode in app_settings_value
313
314 :param val:
315 """
316 val = safe_unicode(val)
317 # encode the encrypted value
318 if 'encrypted' in self.app_settings_type:
319 cipher = EncryptedTextValue()
320 val = safe_unicode(cipher.process_bind_param(val, None))
321 self._app_settings_value = val
322
323 @hybrid_property
324 def app_settings_type(self):
325 return self._app_settings_type
326
327 @app_settings_type.setter
328 def app_settings_type(self, val):
329 if val.split('.')[0] not in self.SETTINGS_TYPES:
330 raise Exception('type must be one of %s got %s'
331 % (self.SETTINGS_TYPES.keys(), val))
332 self._app_settings_type = val
333
334 def __unicode__(self):
335 return u"<%s('%s:%s[%s]')>" % (
336 self.__class__.__name__,
337 self.app_settings_name, self.app_settings_value,
338 self.app_settings_type
339 )
340
341
342 class RhodeCodeUi(Base, BaseModel):
343 __tablename__ = 'rhodecode_ui'
344 __table_args__ = (
345 UniqueConstraint('ui_key'),
346 {'extend_existing': True, 'mysql_engine': 'InnoDB',
347 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
348 )
349
350 HOOK_REPO_SIZE = 'changegroup.repo_size'
351 # HG
352 HOOK_PRE_PULL = 'preoutgoing.pre_pull'
353 HOOK_PULL = 'outgoing.pull_logger'
354 HOOK_PRE_PUSH = 'prechangegroup.pre_push'
355 HOOK_PRETX_PUSH = 'pretxnchangegroup.pre_push'
356 HOOK_PUSH = 'changegroup.push_logger'
357 HOOK_PUSH_KEY = 'pushkey.key_push'
358
359 # TODO: johbo: Unify way how hooks are configured for git and hg,
360 # git part is currently hardcoded.
361
362 # SVN PATTERNS
363 SVN_BRANCH_ID = 'vcs_svn_branch'
364 SVN_TAG_ID = 'vcs_svn_tag'
365
366 ui_id = Column(
367 "ui_id", Integer(), nullable=False, unique=True, default=None,
368 primary_key=True)
369 ui_section = Column(
370 "ui_section", String(255), nullable=True, unique=None, default=None)
371 ui_key = Column(
372 "ui_key", String(255), nullable=True, unique=None, default=None)
373 ui_value = Column(
374 "ui_value", String(255), nullable=True, unique=None, default=None)
375 ui_active = Column(
376 "ui_active", Boolean(), nullable=True, unique=None, default=True)
377
378 def __repr__(self):
379 return '<%s[%s]%s=>%s]>' % (self.__class__.__name__, self.ui_section,
380 self.ui_key, self.ui_value)
381
382
383 class RepoRhodeCodeSetting(Base, BaseModel):
384 __tablename__ = 'repo_rhodecode_settings'
385 __table_args__ = (
386 UniqueConstraint(
387 'app_settings_name', 'repository_id',
388 name='uq_repo_rhodecode_setting_name_repo_id'),
389 {'extend_existing': True, 'mysql_engine': 'InnoDB',
390 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
391 )
392
393 repository_id = Column(
394 "repository_id", Integer(), ForeignKey('repositories.repo_id'),
395 nullable=False)
396 app_settings_id = Column(
397 "app_settings_id", Integer(), nullable=False, unique=True,
398 default=None, primary_key=True)
399 app_settings_name = Column(
400 "app_settings_name", String(255), nullable=True, unique=None,
401 default=None)
402 _app_settings_value = Column(
403 "app_settings_value", String(4096), nullable=True, unique=None,
404 default=None)
405 _app_settings_type = Column(
406 "app_settings_type", String(255), nullable=True, unique=None,
407 default=None)
408
409 repository = relationship('Repository')
410
411 def __init__(self, repository_id, key='', val='', type='unicode'):
412 self.repository_id = repository_id
413 self.app_settings_name = key
414 self.app_settings_type = type
415 self.app_settings_value = val
416
417 @validates('_app_settings_value')
418 def validate_settings_value(self, key, val):
419 assert type(val) == unicode
420 return val
421
422 @hybrid_property
423 def app_settings_value(self):
424 v = self._app_settings_value
425 type_ = self.app_settings_type
426 SETTINGS_TYPES = RhodeCodeSetting.SETTINGS_TYPES
427 converter = SETTINGS_TYPES.get(type_) or SETTINGS_TYPES['unicode']
428 return converter(v)
429
430 @app_settings_value.setter
431 def app_settings_value(self, val):
432 """
433 Setter that will always make sure we use unicode in app_settings_value
434
435 :param val:
436 """
437 self._app_settings_value = safe_unicode(val)
438
439 @hybrid_property
440 def app_settings_type(self):
441 return self._app_settings_type
442
443 @app_settings_type.setter
444 def app_settings_type(self, val):
445 SETTINGS_TYPES = RhodeCodeSetting.SETTINGS_TYPES
446 if val not in SETTINGS_TYPES:
447 raise Exception('type must be one of %s got %s'
448 % (SETTINGS_TYPES.keys(), val))
449 self._app_settings_type = val
450
451 def __unicode__(self):
452 return u"<%s('%s:%s:%s[%s]')>" % (
453 self.__class__.__name__, self.repository.repo_name,
454 self.app_settings_name, self.app_settings_value,
455 self.app_settings_type
456 )
457
458
459 class RepoRhodeCodeUi(Base, BaseModel):
460 __tablename__ = 'repo_rhodecode_ui'
461 __table_args__ = (
462 UniqueConstraint(
463 'repository_id', 'ui_section', 'ui_key',
464 name='uq_repo_rhodecode_ui_repository_id_section_key'),
465 {'extend_existing': True, 'mysql_engine': 'InnoDB',
466 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
467 )
468
469 repository_id = Column(
470 "repository_id", Integer(), ForeignKey('repositories.repo_id'),
471 nullable=False)
472 ui_id = Column(
473 "ui_id", Integer(), nullable=False, unique=True, default=None,
474 primary_key=True)
475 ui_section = Column(
476 "ui_section", String(255), nullable=True, unique=None, default=None)
477 ui_key = Column(
478 "ui_key", String(255), nullable=True, unique=None, default=None)
479 ui_value = Column(
480 "ui_value", String(255), nullable=True, unique=None, default=None)
481 ui_active = Column(
482 "ui_active", Boolean(), nullable=True, unique=None, default=True)
483
484 repository = relationship('Repository')
485
486 def __repr__(self):
487 return '<%s[%s:%s]%s=>%s]>' % (
488 self.__class__.__name__, self.repository.repo_name,
489 self.ui_section, self.ui_key, self.ui_value)
490
491
492 class User(Base, BaseModel):
493 __tablename__ = 'users'
494 __table_args__ = (
495 UniqueConstraint('username'), UniqueConstraint('email'),
496 Index('u_username_idx', 'username'),
497 Index('u_email_idx', 'email'),
498 {'extend_existing': True, 'mysql_engine': 'InnoDB',
499 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
500 )
501 DEFAULT_USER = 'default'
502 DEFAULT_USER_EMAIL = 'anonymous@rhodecode.org'
503 DEFAULT_GRAVATAR_URL = 'https://secure.gravatar.com/avatar/{md5email}?d=identicon&s={size}'
504
505 user_id = Column("user_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
506 username = Column("username", String(255), nullable=True, unique=None, default=None)
507 password = Column("password", String(255), nullable=True, unique=None, default=None)
508 active = Column("active", Boolean(), nullable=True, unique=None, default=True)
509 admin = Column("admin", Boolean(), nullable=True, unique=None, default=False)
510 name = Column("firstname", String(255), nullable=True, unique=None, default=None)
511 lastname = Column("lastname", String(255), nullable=True, unique=None, default=None)
512 _email = Column("email", String(255), nullable=True, unique=None, default=None)
513 last_login = Column("last_login", DateTime(timezone=False), nullable=True, unique=None, default=None)
514 last_activity = Column('last_activity', DateTime(timezone=False), nullable=True, unique=None, default=None)
515
516 extern_type = Column("extern_type", String(255), nullable=True, unique=None, default=None)
517 extern_name = Column("extern_name", String(255), nullable=True, unique=None, default=None)
518 _api_key = Column("api_key", String(255), nullable=True, unique=None, default=None)
519 inherit_default_permissions = Column("inherit_default_permissions", Boolean(), nullable=False, unique=None, default=True)
520 created_on = Column('created_on', DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
521 _user_data = Column("user_data", LargeBinary(), nullable=True) # JSON data
522
523 user_log = relationship('UserLog')
524 user_perms = relationship('UserToPerm', primaryjoin="User.user_id==UserToPerm.user_id", cascade='all')
525
526 repositories = relationship('Repository')
527 repository_groups = relationship('RepoGroup')
528 user_groups = relationship('UserGroup')
529
530 user_followers = relationship('UserFollowing', primaryjoin='UserFollowing.follows_user_id==User.user_id', cascade='all')
531 followings = relationship('UserFollowing', primaryjoin='UserFollowing.user_id==User.user_id', cascade='all')
532
533 repo_to_perm = relationship('UserRepoToPerm', primaryjoin='UserRepoToPerm.user_id==User.user_id', cascade='all')
534 repo_group_to_perm = relationship('UserRepoGroupToPerm', primaryjoin='UserRepoGroupToPerm.user_id==User.user_id', cascade='all')
535 user_group_to_perm = relationship('UserUserGroupToPerm', primaryjoin='UserUserGroupToPerm.user_id==User.user_id', cascade='all')
536
537 group_member = relationship('UserGroupMember', cascade='all')
538
539 notifications = relationship('UserNotification', cascade='all')
540 # notifications assigned to this user
541 user_created_notifications = relationship('Notification', cascade='all')
542 # comments created by this user
543 user_comments = relationship('ChangesetComment', cascade='all')
544 # user profile extra info
545 user_emails = relationship('UserEmailMap', cascade='all')
546 user_ip_map = relationship('UserIpMap', cascade='all')
547 user_auth_tokens = relationship('UserApiKeys', cascade='all')
548 user_ssh_keys = relationship('UserSshKeys', cascade='all')
549
550 # gists
551 user_gists = relationship('Gist', cascade='all')
552 # user pull requests
553 user_pull_requests = relationship('PullRequest', cascade='all')
554 # external identities
555 extenal_identities = relationship(
556 'ExternalIdentity',
557 primaryjoin="User.user_id==ExternalIdentity.local_user_id",
558 cascade='all')
559
560 def __unicode__(self):
561 return u"<%s('id:%s:%s')>" % (self.__class__.__name__,
562 self.user_id, self.username)
563
564 @hybrid_property
565 def email(self):
566 return self._email
567
568 @email.setter
569 def email(self, val):
570 self._email = val.lower() if val else None
571
572 @hybrid_property
573 def first_name(self):
574 from rhodecode.lib import helpers as h
575 if self.name:
576 return h.escape(self.name)
577 return self.name
578
579 @hybrid_property
580 def last_name(self):
581 from rhodecode.lib import helpers as h
582 if self.lastname:
583 return h.escape(self.lastname)
584 return self.lastname
585
586 @hybrid_property
587 def api_key(self):
588 """
589 Fetch if exist an auth-token with role ALL connected to this user
590 """
591 user_auth_token = UserApiKeys.query()\
592 .filter(UserApiKeys.user_id == self.user_id)\
593 .filter(or_(UserApiKeys.expires == -1,
594 UserApiKeys.expires >= time.time()))\
595 .filter(UserApiKeys.role == UserApiKeys.ROLE_ALL).first()
596 if user_auth_token:
597 user_auth_token = user_auth_token.api_key
598
599 return user_auth_token
600
601 @api_key.setter
602 def api_key(self, val):
603 # don't allow to set API key this is deprecated for now
604 self._api_key = None
605
606 @property
607 def reviewer_pull_requests(self):
608 return PullRequestReviewers.query() \
609 .options(joinedload(PullRequestReviewers.pull_request)) \
610 .filter(PullRequestReviewers.user_id == self.user_id) \
611 .all()
612
613 @property
614 def firstname(self):
615 # alias for future
616 return self.name
617
618 @property
619 def emails(self):
620 other = UserEmailMap.query()\
621 .filter(UserEmailMap.user == self) \
622 .order_by(UserEmailMap.email_id.asc()) \
623 .all()
624 return [self.email] + [x.email for x in other]
625
626 @property
627 def auth_tokens(self):
628 auth_tokens = self.get_auth_tokens()
629 return [x.api_key for x in auth_tokens]
630
631 def get_auth_tokens(self):
632 return UserApiKeys.query()\
633 .filter(UserApiKeys.user == self)\
634 .order_by(UserApiKeys.user_api_key_id.asc())\
635 .all()
636
637 @property
638 def feed_token(self):
639 return self.get_feed_token()
640
641 def get_feed_token(self):
642 feed_tokens = UserApiKeys.query()\
643 .filter(UserApiKeys.user == self)\
644 .filter(UserApiKeys.role == UserApiKeys.ROLE_FEED)\
645 .all()
646 if feed_tokens:
647 return feed_tokens[0].api_key
648 return 'NO_FEED_TOKEN_AVAILABLE'
649
650 @classmethod
651 def extra_valid_auth_tokens(cls, user, role=None):
652 tokens = UserApiKeys.query().filter(UserApiKeys.user == user)\
653 .filter(or_(UserApiKeys.expires == -1,
654 UserApiKeys.expires >= time.time()))
655 if role:
656 tokens = tokens.filter(or_(UserApiKeys.role == role,
657 UserApiKeys.role == UserApiKeys.ROLE_ALL))
658 return tokens.all()
659
660 def authenticate_by_token(self, auth_token, roles=None, scope_repo_id=None):
661 from rhodecode.lib import auth
662
663 log.debug('Trying to authenticate user: %s via auth-token, '
664 'and roles: %s', self, roles)
665
666 if not auth_token:
667 return False
668
669 crypto_backend = auth.crypto_backend()
670
671 roles = (roles or []) + [UserApiKeys.ROLE_ALL]
672 tokens_q = UserApiKeys.query()\
673 .filter(UserApiKeys.user_id == self.user_id)\
674 .filter(or_(UserApiKeys.expires == -1,
675 UserApiKeys.expires >= time.time()))
676
677 tokens_q = tokens_q.filter(UserApiKeys.role.in_(roles))
678
679 plain_tokens = []
680 hash_tokens = []
681
682 for token in tokens_q.all():
683 # verify scope first
684 if token.repo_id:
685 # token has a scope, we need to verify it
686 if scope_repo_id != token.repo_id:
687 log.debug(
688 'Scope mismatch: token has a set repo scope: %s, '
689 'and calling scope is:%s, skipping further checks',
690 token.repo, scope_repo_id)
691 # token has a scope, and it doesn't match, skip token
692 continue
693
694 if token.api_key.startswith(crypto_backend.ENC_PREF):
695 hash_tokens.append(token.api_key)
696 else:
697 plain_tokens.append(token.api_key)
698
699 is_plain_match = auth_token in plain_tokens
700 if is_plain_match:
701 return True
702
703 for hashed in hash_tokens:
704 # TODO(marcink): this is expensive to calculate, but most secure
705 match = crypto_backend.hash_check(auth_token, hashed)
706 if match:
707 return True
708
709 return False
710
711 @property
712 def ip_addresses(self):
713 ret = UserIpMap.query().filter(UserIpMap.user == self).all()
714 return [x.ip_addr for x in ret]
715
716 @property
717 def username_and_name(self):
718 return '%s (%s %s)' % (self.username, self.first_name, self.last_name)
719
720 @property
721 def username_or_name_or_email(self):
722 full_name = self.full_name if self.full_name is not ' ' else None
723 return self.username or full_name or self.email
724
725 @property
726 def full_name(self):
727 return '%s %s' % (self.first_name, self.last_name)
728
729 @property
730 def full_name_or_username(self):
731 return ('%s %s' % (self.first_name, self.last_name)
732 if (self.first_name and self.last_name) else self.username)
733
734 @property
735 def full_contact(self):
736 return '%s %s <%s>' % (self.first_name, self.last_name, self.email)
737
738 @property
739 def short_contact(self):
740 return '%s %s' % (self.first_name, self.last_name)
741
742 @property
743 def is_admin(self):
744 return self.admin
745
746 @property
747 def AuthUser(self):
748 """
749 Returns instance of AuthUser for this user
750 """
751 from rhodecode.lib.auth import AuthUser
752 return AuthUser(user_id=self.user_id, username=self.username)
753
754 @hybrid_property
755 def user_data(self):
756 if not self._user_data:
757 return {}
758
759 try:
760 return json.loads(self._user_data)
761 except TypeError:
762 return {}
763
764 @user_data.setter
765 def user_data(self, val):
766 if not isinstance(val, dict):
767 raise Exception('user_data must be dict, got %s' % type(val))
768 try:
769 self._user_data = json.dumps(val)
770 except Exception:
771 log.error(traceback.format_exc())
772
773 @classmethod
774 def get_by_username(cls, username, case_insensitive=False,
775 cache=False, identity_cache=False):
776 session = Session()
777
778 if case_insensitive:
779 q = cls.query().filter(
780 func.lower(cls.username) == func.lower(username))
781 else:
782 q = cls.query().filter(cls.username == username)
783
784 if cache:
785 if identity_cache:
786 val = cls.identity_cache(session, 'username', username)
787 if val:
788 return val
789 else:
790 cache_key = "get_user_by_name_%s" % _hash_key(username)
791 q = q.options(
792 FromCache("sql_cache_short", cache_key))
793
794 return q.scalar()
795
796 @classmethod
797 def get_by_auth_token(cls, auth_token, cache=False):
798 q = UserApiKeys.query()\
799 .filter(UserApiKeys.api_key == auth_token)\
800 .filter(or_(UserApiKeys.expires == -1,
801 UserApiKeys.expires >= time.time()))
802 if cache:
803 q = q.options(
804 FromCache("sql_cache_short", "get_auth_token_%s" % auth_token))
805
806 match = q.first()
807 if match:
808 return match.user
809
810 @classmethod
811 def get_by_email(cls, email, case_insensitive=False, cache=False):
812
813 if case_insensitive:
814 q = cls.query().filter(func.lower(cls.email) == func.lower(email))
815
816 else:
817 q = cls.query().filter(cls.email == email)
818
819 email_key = _hash_key(email)
820 if cache:
821 q = q.options(
822 FromCache("sql_cache_short", "get_email_key_%s" % email_key))
823
824 ret = q.scalar()
825 if ret is None:
826 q = UserEmailMap.query()
827 # try fetching in alternate email map
828 if case_insensitive:
829 q = q.filter(func.lower(UserEmailMap.email) == func.lower(email))
830 else:
831 q = q.filter(UserEmailMap.email == email)
832 q = q.options(joinedload(UserEmailMap.user))
833 if cache:
834 q = q.options(
835 FromCache("sql_cache_short", "get_email_map_key_%s" % email_key))
836 ret = getattr(q.scalar(), 'user', None)
837
838 return ret
839
840 @classmethod
841 def get_from_cs_author(cls, author):
842 """
843 Tries to get User objects out of commit author string
844
845 :param author:
846 """
847 from rhodecode.lib.helpers import email, author_name
848 # Valid email in the attribute passed, see if they're in the system
849 _email = email(author)
850 if _email:
851 user = cls.get_by_email(_email, case_insensitive=True)
852 if user:
853 return user
854 # Maybe we can match by username?
855 _author = author_name(author)
856 user = cls.get_by_username(_author, case_insensitive=True)
857 if user:
858 return user
859
860 def update_userdata(self, **kwargs):
861 usr = self
862 old = usr.user_data
863 old.update(**kwargs)
864 usr.user_data = old
865 Session().add(usr)
866 log.debug('updated userdata with ', kwargs)
867
868 def update_lastlogin(self):
869 """Update user lastlogin"""
870 self.last_login = datetime.datetime.now()
871 Session().add(self)
872 log.debug('updated user %s lastlogin', self.username)
873
874 def update_lastactivity(self):
875 """Update user lastactivity"""
876 self.last_activity = datetime.datetime.now()
877 Session().add(self)
878 log.debug('updated user %s lastactivity', self.username)
879
880 def update_password(self, new_password):
881 from rhodecode.lib.auth import get_crypt_password
882
883 self.password = get_crypt_password(new_password)
884 Session().add(self)
885
886 @classmethod
887 def get_first_super_admin(cls):
888 user = User.query().filter(User.admin == true()).first()
889 if user is None:
890 raise Exception('FATAL: Missing administrative account!')
891 return user
892
893 @classmethod
894 def get_all_super_admins(cls):
895 """
896 Returns all admin accounts sorted by username
897 """
898 return User.query().filter(User.admin == true())\
899 .order_by(User.username.asc()).all()
900
901 @classmethod
902 def get_default_user(cls, cache=False, refresh=False):
903 user = User.get_by_username(User.DEFAULT_USER, cache=cache)
904 if user is None:
905 raise Exception('FATAL: Missing default account!')
906 if refresh:
907 # The default user might be based on outdated state which
908 # has been loaded from the cache.
909 # A call to refresh() ensures that the
910 # latest state from the database is used.
911 Session().refresh(user)
912 return user
913
914 def _get_default_perms(self, user, suffix=''):
915 from rhodecode.model.permission import PermissionModel
916 return PermissionModel().get_default_perms(user.user_perms, suffix)
917
918 def get_default_perms(self, suffix=''):
919 return self._get_default_perms(self, suffix)
920
921 def get_api_data(self, include_secrets=False, details='full'):
922 """
923 Common function for generating user related data for API
924
925 :param include_secrets: By default secrets in the API data will be replaced
926 by a placeholder value to prevent exposing this data by accident. In case
927 this data shall be exposed, set this flag to ``True``.
928
929 :param details: details can be 'basic|full' basic gives only a subset of
930 the available user information that includes user_id, name and emails.
931 """
932 user = self
933 user_data = self.user_data
934 data = {
935 'user_id': user.user_id,
936 'username': user.username,
937 'firstname': user.name,
938 'lastname': user.lastname,
939 'email': user.email,
940 'emails': user.emails,
941 }
942 if details == 'basic':
943 return data
944
945 auth_token_length = 40
946 auth_token_replacement = '*' * auth_token_length
947
948 extras = {
949 'auth_tokens': [auth_token_replacement],
950 'active': user.active,
951 'admin': user.admin,
952 'extern_type': user.extern_type,
953 'extern_name': user.extern_name,
954 'last_login': user.last_login,
955 'last_activity': user.last_activity,
956 'ip_addresses': user.ip_addresses,
957 'language': user_data.get('language')
958 }
959 data.update(extras)
960
961 if include_secrets:
962 data['auth_tokens'] = user.auth_tokens
963 return data
964
965 def __json__(self):
966 data = {
967 'full_name': self.full_name,
968 'full_name_or_username': self.full_name_or_username,
969 'short_contact': self.short_contact,
970 'full_contact': self.full_contact,
971 }
972 data.update(self.get_api_data())
973 return data
974
975
976 class UserApiKeys(Base, BaseModel):
977 __tablename__ = 'user_api_keys'
978 __table_args__ = (
979 Index('uak_api_key_idx', 'api_key', unique=True),
980 Index('uak_api_key_expires_idx', 'api_key', 'expires'),
981 {'extend_existing': True, 'mysql_engine': 'InnoDB',
982 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
983 )
984 __mapper_args__ = {}
985
986 # ApiKey role
987 ROLE_ALL = 'token_role_all'
988 ROLE_HTTP = 'token_role_http'
989 ROLE_VCS = 'token_role_vcs'
990 ROLE_API = 'token_role_api'
991 ROLE_FEED = 'token_role_feed'
992 ROLE_PASSWORD_RESET = 'token_password_reset'
993
994 ROLES = [ROLE_ALL, ROLE_HTTP, ROLE_VCS, ROLE_API, ROLE_FEED]
995
996 user_api_key_id = Column("user_api_key_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
997 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=True, unique=None, default=None)
998 api_key = Column("api_key", String(255), nullable=False, unique=True)
999 description = Column('description', UnicodeText().with_variant(UnicodeText(1024), 'mysql'))
1000 expires = Column('expires', Float(53), nullable=False)
1001 role = Column('role', String(255), nullable=True)
1002 created_on = Column('created_on', DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
1003
1004 # scope columns
1005 repo_id = Column(
1006 'repo_id', Integer(), ForeignKey('repositories.repo_id'),
1007 nullable=True, unique=None, default=None)
1008 repo = relationship('Repository', lazy='joined')
1009
1010 repo_group_id = Column(
1011 'repo_group_id', Integer(), ForeignKey('groups.group_id'),
1012 nullable=True, unique=None, default=None)
1013 repo_group = relationship('RepoGroup', lazy='joined')
1014
1015 user = relationship('User', lazy='joined')
1016
1017 def __unicode__(self):
1018 return u"<%s('%s')>" % (self.__class__.__name__, self.role)
1019
1020 def __json__(self):
1021 data = {
1022 'auth_token': self.api_key,
1023 'role': self.role,
1024 'scope': self.scope_humanized,
1025 'expired': self.expired
1026 }
1027 return data
1028
1029 def get_api_data(self, include_secrets=False):
1030 data = self.__json__()
1031 if include_secrets:
1032 return data
1033 else:
1034 data['auth_token'] = self.token_obfuscated
1035 return data
1036
1037 @hybrid_property
1038 def description_safe(self):
1039 from rhodecode.lib import helpers as h
1040 return h.escape(self.description)
1041
1042 @property
1043 def expired(self):
1044 if self.expires == -1:
1045 return False
1046 return time.time() > self.expires
1047
1048 @classmethod
1049 def _get_role_name(cls, role):
1050 return {
1051 cls.ROLE_ALL: _('all'),
1052 cls.ROLE_HTTP: _('http/web interface'),
1053 cls.ROLE_VCS: _('vcs (git/hg/svn protocol)'),
1054 cls.ROLE_API: _('api calls'),
1055 cls.ROLE_FEED: _('feed access'),
1056 }.get(role, role)
1057
1058 @property
1059 def role_humanized(self):
1060 return self._get_role_name(self.role)
1061
1062 def _get_scope(self):
1063 if self.repo:
1064 return repr(self.repo)
1065 if self.repo_group:
1066 return repr(self.repo_group) + ' (recursive)'
1067 return 'global'
1068
1069 @property
1070 def scope_humanized(self):
1071 return self._get_scope()
1072
1073 @property
1074 def token_obfuscated(self):
1075 if self.api_key:
1076 return self.api_key[:4] + "****"
1077
1078
1079 class UserEmailMap(Base, BaseModel):
1080 __tablename__ = 'user_email_map'
1081 __table_args__ = (
1082 Index('uem_email_idx', 'email'),
1083 UniqueConstraint('email'),
1084 {'extend_existing': True, 'mysql_engine': 'InnoDB',
1085 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
1086 )
1087 __mapper_args__ = {}
1088
1089 email_id = Column("email_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
1090 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=True, unique=None, default=None)
1091 _email = Column("email", String(255), nullable=True, unique=False, default=None)
1092 user = relationship('User', lazy='joined')
1093
1094 @validates('_email')
1095 def validate_email(self, key, email):
1096 # check if this email is not main one
1097 main_email = Session().query(User).filter(User.email == email).scalar()
1098 if main_email is not None:
1099 raise AttributeError('email %s is present is user table' % email)
1100 return email
1101
1102 @hybrid_property
1103 def email(self):
1104 return self._email
1105
1106 @email.setter
1107 def email(self, val):
1108 self._email = val.lower() if val else None
1109
1110
1111 class UserIpMap(Base, BaseModel):
1112 __tablename__ = 'user_ip_map'
1113 __table_args__ = (
1114 UniqueConstraint('user_id', 'ip_addr'),
1115 {'extend_existing': True, 'mysql_engine': 'InnoDB',
1116 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
1117 )
1118 __mapper_args__ = {}
1119
1120 ip_id = Column("ip_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
1121 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=True, unique=None, default=None)
1122 ip_addr = Column("ip_addr", String(255), nullable=True, unique=False, default=None)
1123 active = Column("active", Boolean(), nullable=True, unique=None, default=True)
1124 description = Column("description", String(10000), nullable=True, unique=None, default=None)
1125 user = relationship('User', lazy='joined')
1126
1127 @hybrid_property
1128 def description_safe(self):
1129 from rhodecode.lib import helpers as h
1130 return h.escape(self.description)
1131
1132 @classmethod
1133 def _get_ip_range(cls, ip_addr):
1134 net = ipaddress.ip_network(safe_unicode(ip_addr), strict=False)
1135 return [str(net.network_address), str(net.broadcast_address)]
1136
1137 def __json__(self):
1138 return {
1139 'ip_addr': self.ip_addr,
1140 'ip_range': self._get_ip_range(self.ip_addr),
1141 }
1142
1143 def __unicode__(self):
1144 return u"<%s('user_id:%s=>%s')>" % (self.__class__.__name__,
1145 self.user_id, self.ip_addr)
1146
1147
1148 class UserSshKeys(Base, BaseModel):
1149 __tablename__ = 'user_ssh_keys'
1150 __table_args__ = (
1151 Index('usk_ssh_key_fingerprint_idx', 'ssh_key_fingerprint'),
1152 UniqueConstraint('ssh_key_fingerprint'),
1153
1154 {'extend_existing': True, 'mysql_engine': 'InnoDB',
1155 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
1156 )
1157 __mapper_args__ = {}
1158
1159 ssh_key_id = Column('ssh_key_id', Integer(), nullable=False, unique=True, default=None, primary_key=True)
1160 ssh_key_data = Column('ssh_key_data', String(10240), nullable=False, unique=None, default=None)
1161 ssh_key_fingerprint = Column('ssh_key_fingerprint', String(1024), nullable=False, unique=None, default=None)
1162
1163 description = Column('description', UnicodeText().with_variant(UnicodeText(1024), 'mysql'))
1164
1165 created_on = Column('created_on', DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
1166 accessed_on = Column('accessed_on', DateTime(timezone=False), nullable=True, default=None)
1167 user_id = Column('user_id', Integer(), ForeignKey('users.user_id'), nullable=True, unique=None, default=None)
1168
1169 user = relationship('User', lazy='joined')
1170
1171 def __json__(self):
1172 data = {
1173 'ssh_fingerprint': self.ssh_key_fingerprint,
1174 'description': self.description,
1175 'created_on': self.created_on
1176 }
1177 return data
1178
1179 def get_api_data(self):
1180 data = self.__json__()
1181 return data
1182
1183
1184 class UserLog(Base, BaseModel):
1185 __tablename__ = 'user_logs'
1186 __table_args__ = (
1187 {'extend_existing': True, 'mysql_engine': 'InnoDB',
1188 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
1189 )
1190 VERSION_1 = 'v1'
1191 VERSION_2 = 'v2'
1192 VERSIONS = [VERSION_1, VERSION_2]
1193
1194 user_log_id = Column("user_log_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
1195 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=True, unique=None, default=None)
1196 username = Column("username", String(255), nullable=True, unique=None, default=None)
1197 repository_id = Column("repository_id", Integer(), ForeignKey('repositories.repo_id'), nullable=True)
1198 repository_name = Column("repository_name", String(255), nullable=True, unique=None, default=None)
1199 user_ip = Column("user_ip", String(255), nullable=True, unique=None, default=None)
1200 action = Column("action", Text().with_variant(Text(1200000), 'mysql'), nullable=True, unique=None, default=None)
1201 action_date = Column("action_date", DateTime(timezone=False), nullable=True, unique=None, default=None)
1202
1203 version = Column("version", String(255), nullable=True, default=VERSION_1)
1204 user_data = Column('user_data_json', MutationObj.as_mutable(JsonType(dialect_map=dict(mysql=UnicodeText(16384)))))
1205 action_data = Column('action_data_json', MutationObj.as_mutable(JsonType(dialect_map=dict(mysql=UnicodeText(16384)))))
1206
1207 def __unicode__(self):
1208 return u"<%s('id:%s:%s')>" % (
1209 self.__class__.__name__, self.repository_name, self.action)
1210
1211 def __json__(self):
1212 return {
1213 'user_id': self.user_id,
1214 'username': self.username,
1215 'repository_id': self.repository_id,
1216 'repository_name': self.repository_name,
1217 'user_ip': self.user_ip,
1218 'action_date': self.action_date,
1219 'action': self.action,
1220 }
1221
1222 @property
1223 def action_as_day(self):
1224 return datetime.date(*self.action_date.timetuple()[:3])
1225
1226 user = relationship('User')
1227 repository = relationship('Repository', cascade='')
1228
1229
1230 class UserGroup(Base, BaseModel):
1231 __tablename__ = 'users_groups'
1232 __table_args__ = (
1233 {'extend_existing': True, 'mysql_engine': 'InnoDB',
1234 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
1235 )
1236
1237 users_group_id = Column("users_group_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
1238 users_group_name = Column("users_group_name", String(255), nullable=False, unique=True, default=None)
1239 user_group_description = Column("user_group_description", String(10000), nullable=True, unique=None, default=None)
1240 users_group_active = Column("users_group_active", Boolean(), nullable=True, unique=None, default=None)
1241 inherit_default_permissions = Column("users_group_inherit_default_permissions", Boolean(), nullable=False, unique=None, default=True)
1242 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=False, default=None)
1243 created_on = Column('created_on', DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
1244 _group_data = Column("group_data", LargeBinary(), nullable=True) # JSON data
1245
1246 members = relationship('UserGroupMember', cascade="all, delete, delete-orphan", lazy="joined")
1247 users_group_to_perm = relationship('UserGroupToPerm', cascade='all')
1248 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1249 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
1250 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
1251 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm ', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
1252
1253 user = relationship('User', primaryjoin="User.user_id==UserGroup.user_id")
1254
1255 @classmethod
1256 def _load_group_data(cls, column):
1257 if not column:
1258 return {}
1259
1260 try:
1261 return json.loads(column) or {}
1262 except TypeError:
1263 return {}
1264
1265 @hybrid_property
1266 def description_safe(self):
1267 from rhodecode.lib import helpers as h
1268 return h.escape(self.description)
1269
1270 @hybrid_property
1271 def group_data(self):
1272 return self._load_group_data(self._group_data)
1273
1274 @group_data.expression
1275 def group_data(self, **kwargs):
1276 return self._group_data
1277
1278 @group_data.setter
1279 def group_data(self, val):
1280 try:
1281 self._group_data = json.dumps(val)
1282 except Exception:
1283 log.error(traceback.format_exc())
1284
1285 def __unicode__(self):
1286 return u"<%s('id:%s:%s')>" % (self.__class__.__name__,
1287 self.users_group_id,
1288 self.users_group_name)
1289
1290 @classmethod
1291 def get_by_group_name(cls, group_name, cache=False,
1292 case_insensitive=False):
1293 if case_insensitive:
1294 q = cls.query().filter(func.lower(cls.users_group_name) ==
1295 func.lower(group_name))
1296
1297 else:
1298 q = cls.query().filter(cls.users_group_name == group_name)
1299 if cache:
1300 q = q.options(
1301 FromCache("sql_cache_short", "get_group_%s" % _hash_key(group_name)))
1302 return q.scalar()
1303
1304 @classmethod
1305 def get(cls, user_group_id, cache=False):
1306 user_group = cls.query()
1307 if cache:
1308 user_group = user_group.options(
1309 FromCache("sql_cache_short", "get_users_group_%s" % user_group_id))
1310 return user_group.get(user_group_id)
1311
1312 def permissions(self, with_admins=True, with_owner=True):
1313 q = UserUserGroupToPerm.query().filter(UserUserGroupToPerm.user_group == self)
1314 q = q.options(joinedload(UserUserGroupToPerm.user_group),
1315 joinedload(UserUserGroupToPerm.user),
1316 joinedload(UserUserGroupToPerm.permission),)
1317
1318 # get owners and admins and permissions. We do a trick of re-writing
1319 # objects from sqlalchemy to named-tuples due to sqlalchemy session
1320 # has a global reference and changing one object propagates to all
1321 # others. This means if admin is also an owner admin_row that change
1322 # would propagate to both objects
1323 perm_rows = []
1324 for _usr in q.all():
1325 usr = AttributeDict(_usr.user.get_dict())
1326 usr.permission = _usr.permission.permission_name
1327 perm_rows.append(usr)
1328
1329 # filter the perm rows by 'default' first and then sort them by
1330 # admin,write,read,none permissions sorted again alphabetically in
1331 # each group
1332 perm_rows = sorted(perm_rows, key=display_sort)
1333
1334 _admin_perm = 'usergroup.admin'
1335 owner_row = []
1336 if with_owner:
1337 usr = AttributeDict(self.user.get_dict())
1338 usr.owner_row = True
1339 usr.permission = _admin_perm
1340 owner_row.append(usr)
1341
1342 super_admin_rows = []
1343 if with_admins:
1344 for usr in User.get_all_super_admins():
1345 # if this admin is also owner, don't double the record
1346 if usr.user_id == owner_row[0].user_id:
1347 owner_row[0].admin_row = True
1348 else:
1349 usr = AttributeDict(usr.get_dict())
1350 usr.admin_row = True
1351 usr.permission = _admin_perm
1352 super_admin_rows.append(usr)
1353
1354 return super_admin_rows + owner_row + perm_rows
1355
1356 def permission_user_groups(self):
1357 q = UserGroupUserGroupToPerm.query().filter(UserGroupUserGroupToPerm.target_user_group == self)
1358 q = q.options(joinedload(UserGroupUserGroupToPerm.user_group),
1359 joinedload(UserGroupUserGroupToPerm.target_user_group),
1360 joinedload(UserGroupUserGroupToPerm.permission),)
1361
1362 perm_rows = []
1363 for _user_group in q.all():
1364 usr = AttributeDict(_user_group.user_group.get_dict())
1365 usr.permission = _user_group.permission.permission_name
1366 perm_rows.append(usr)
1367
1368 return perm_rows
1369
1370 def _get_default_perms(self, user_group, suffix=''):
1371 from rhodecode.model.permission import PermissionModel
1372 return PermissionModel().get_default_perms(user_group.users_group_to_perm, suffix)
1373
1374 def get_default_perms(self, suffix=''):
1375 return self._get_default_perms(self, suffix)
1376
1377 def get_api_data(self, with_group_members=True, include_secrets=False):
1378 """
1379 :param include_secrets: See :meth:`User.get_api_data`, this parameter is
1380 basically forwarded.
1381
1382 """
1383 user_group = self
1384 data = {
1385 'users_group_id': user_group.users_group_id,
1386 'group_name': user_group.users_group_name,
1387 'group_description': user_group.user_group_description,
1388 'active': user_group.users_group_active,
1389 'owner': user_group.user.username,
1390 'owner_email': user_group.user.email,
1391 }
1392
1393 if with_group_members:
1394 users = []
1395 for user in user_group.members:
1396 user = user.user
1397 users.append(user.get_api_data(include_secrets=include_secrets))
1398 data['users'] = users
1399
1400 return data
1401
1402
1403 class UserGroupMember(Base, BaseModel):
1404 __tablename__ = 'users_groups_members'
1405 __table_args__ = (
1406 {'extend_existing': True, 'mysql_engine': 'InnoDB',
1407 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
1408 )
1409
1410 users_group_member_id = Column("users_group_member_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
1411 users_group_id = Column("users_group_id", Integer(), ForeignKey('users_groups.users_group_id'), nullable=False, unique=None, default=None)
1412 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=None, default=None)
1413
1414 user = relationship('User', lazy='joined')
1415 users_group = relationship('UserGroup')
1416
1417 def __init__(self, gr_id='', u_id=''):
1418 self.users_group_id = gr_id
1419 self.user_id = u_id
1420
1421
1422 class RepositoryField(Base, BaseModel):
1423 __tablename__ = 'repositories_fields'
1424 __table_args__ = (
1425 UniqueConstraint('repository_id', 'field_key'), # no-multi field
1426 {'extend_existing': True, 'mysql_engine': 'InnoDB',
1427 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
1428 )
1429 PREFIX = 'ex_' # prefix used in form to not conflict with already existing fields
1430
1431 repo_field_id = Column("repo_field_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
1432 repository_id = Column("repository_id", Integer(), ForeignKey('repositories.repo_id'), nullable=False, unique=None, default=None)
1433 field_key = Column("field_key", String(250))
1434 field_label = Column("field_label", String(1024), nullable=False)
1435 field_value = Column("field_value", String(10000), nullable=False)
1436 field_desc = Column("field_desc", String(1024), nullable=False)
1437 field_type = Column("field_type", String(255), nullable=False, unique=None)
1438 created_on = Column('created_on', DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
1439
1440 repository = relationship('Repository')
1441
1442 @property
1443 def field_key_prefixed(self):
1444 return 'ex_%s' % self.field_key
1445
1446 @classmethod
1447 def un_prefix_key(cls, key):
1448 if key.startswith(cls.PREFIX):
1449 return key[len(cls.PREFIX):]
1450 return key
1451
1452 @classmethod
1453 def get_by_key_name(cls, key, repo):
1454 row = cls.query()\
1455 .filter(cls.repository == repo)\
1456 .filter(cls.field_key == key).scalar()
1457 return row
1458
1459
1460 class Repository(Base, BaseModel):
1461 __tablename__ = 'repositories'
1462 __table_args__ = (
1463 Index('r_repo_name_idx', 'repo_name', mysql_length=255),
1464 {'extend_existing': True, 'mysql_engine': 'InnoDB',
1465 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
1466 )
1467 DEFAULT_CLONE_URI = '{scheme}://{user}@{netloc}/{repo}'
1468 DEFAULT_CLONE_URI_ID = '{scheme}://{user}@{netloc}/_{repoid}'
1469
1470 STATE_CREATED = 'repo_state_created'
1471 STATE_PENDING = 'repo_state_pending'
1472 STATE_ERROR = 'repo_state_error'
1473
1474 LOCK_AUTOMATIC = 'lock_auto'
1475 LOCK_API = 'lock_api'
1476 LOCK_WEB = 'lock_web'
1477 LOCK_PULL = 'lock_pull'
1478
1479 NAME_SEP = URL_SEP
1480
1481 repo_id = Column(
1482 "repo_id", Integer(), nullable=False, unique=True, default=None,
1483 primary_key=True)
1484 _repo_name = Column(
1485 "repo_name", Text(), nullable=False, default=None)
1486 _repo_name_hash = Column(
1487 "repo_name_hash", String(255), nullable=False, unique=True)
1488 repo_state = Column("repo_state", String(255), nullable=True)
1489
1490 clone_uri = Column(
1491 "clone_uri", EncryptedTextValue(), nullable=True, unique=False,
1492 default=None)
1493 repo_type = Column(
1494 "repo_type", String(255), nullable=False, unique=False, default=None)
1495 user_id = Column(
1496 "user_id", Integer(), ForeignKey('users.user_id'), nullable=False,
1497 unique=False, default=None)
1498 private = Column(
1499 "private", Boolean(), nullable=True, unique=None, default=None)
1500 enable_statistics = Column(
1501 "statistics", Boolean(), nullable=True, unique=None, default=True)
1502 enable_downloads = Column(
1503 "downloads", Boolean(), nullable=True, unique=None, default=True)
1504 description = Column(
1505 "description", String(10000), nullable=True, unique=None, default=None)
1506 created_on = Column(
1507 'created_on', DateTime(timezone=False), nullable=True, unique=None,
1508 default=datetime.datetime.now)
1509 updated_on = Column(
1510 'updated_on', DateTime(timezone=False), nullable=True, unique=None,
1511 default=datetime.datetime.now)
1512 _landing_revision = Column(
1513 "landing_revision", String(255), nullable=False, unique=False,
1514 default=None)
1515 enable_locking = Column(
1516 "enable_locking", Boolean(), nullable=False, unique=None,
1517 default=False)
1518 _locked = Column(
1519 "locked", String(255), nullable=True, unique=False, default=None)
1520 _changeset_cache = Column(
1521 "changeset_cache", LargeBinary(), nullable=True) # JSON data
1522
1523 fork_id = Column(
1524 "fork_id", Integer(), ForeignKey('repositories.repo_id'),
1525 nullable=True, unique=False, default=None)
1526 group_id = Column(
1527 "group_id", Integer(), ForeignKey('groups.group_id'), nullable=True,
1528 unique=False, default=None)
1529
1530 user = relationship('User', lazy='joined')
1531 fork = relationship('Repository', remote_side=repo_id, lazy='joined')
1532 group = relationship('RepoGroup', lazy='joined')
1533 repo_to_perm = relationship(
1534 'UserRepoToPerm', cascade='all',
1535 order_by='UserRepoToPerm.repo_to_perm_id')
1536 users_group_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1537 stats = relationship('Statistics', cascade='all', uselist=False)
1538
1539 followers = relationship(
1540 'UserFollowing',
1541 primaryjoin='UserFollowing.follows_repo_id==Repository.repo_id',
1542 cascade='all')
1543 extra_fields = relationship(
1544 'RepositoryField', cascade="all, delete, delete-orphan")
1545 logs = relationship('UserLog')
1546 comments = relationship(
1547 'ChangesetComment', cascade="all, delete, delete-orphan")
1548 pull_requests_source = relationship(
1549 'PullRequest',
1550 primaryjoin='PullRequest.source_repo_id==Repository.repo_id',
1551 cascade="all, delete, delete-orphan")
1552 pull_requests_target = relationship(
1553 'PullRequest',
1554 primaryjoin='PullRequest.target_repo_id==Repository.repo_id',
1555 cascade="all, delete, delete-orphan")
1556 ui = relationship('RepoRhodeCodeUi', cascade="all")
1557 settings = relationship('RepoRhodeCodeSetting', cascade="all")
1558 integrations = relationship('Integration',
1559 cascade="all, delete, delete-orphan")
1560
1561 def __unicode__(self):
1562 return u"<%s('%s:%s')>" % (self.__class__.__name__, self.repo_id,
1563 safe_unicode(self.repo_name))
1564
1565 @hybrid_property
1566 def description_safe(self):
1567 from rhodecode.lib import helpers as h
1568 return h.escape(self.description)
1569
1570 @hybrid_property
1571 def landing_rev(self):
1572 # always should return [rev_type, rev]
1573 if self._landing_revision:
1574 _rev_info = self._landing_revision.split(':')
1575 if len(_rev_info) < 2:
1576 _rev_info.insert(0, 'rev')
1577 return [_rev_info[0], _rev_info[1]]
1578 return [None, None]
1579
1580 @landing_rev.setter
1581 def landing_rev(self, val):
1582 if ':' not in val:
1583 raise ValueError('value must be delimited with `:` and consist '
1584 'of <rev_type>:<rev>, got %s instead' % val)
1585 self._landing_revision = val
1586
1587 @hybrid_property
1588 def locked(self):
1589 if self._locked:
1590 user_id, timelocked, reason = self._locked.split(':')
1591 lock_values = int(user_id), timelocked, reason
1592 else:
1593 lock_values = [None, None, None]
1594 return lock_values
1595
1596 @locked.setter
1597 def locked(self, val):
1598 if val and isinstance(val, (list, tuple)):
1599 self._locked = ':'.join(map(str, val))
1600 else:
1601 self._locked = None
1602
1603 @hybrid_property
1604 def changeset_cache(self):
1605 from rhodecode.lib.vcs.backends.base import EmptyCommit
1606 dummy = EmptyCommit().__json__()
1607 if not self._changeset_cache:
1608 return dummy
1609 try:
1610 return json.loads(self._changeset_cache)
1611 except TypeError:
1612 return dummy
1613 except Exception:
1614 log.error(traceback.format_exc())
1615 return dummy
1616
1617 @changeset_cache.setter
1618 def changeset_cache(self, val):
1619 try:
1620 self._changeset_cache = json.dumps(val)
1621 except Exception:
1622 log.error(traceback.format_exc())
1623
1624 @hybrid_property
1625 def repo_name(self):
1626 return self._repo_name
1627
1628 @repo_name.setter
1629 def repo_name(self, value):
1630 self._repo_name = value
1631 self._repo_name_hash = hashlib.sha1(safe_str(value)).hexdigest()
1632
1633 @classmethod
1634 def normalize_repo_name(cls, repo_name):
1635 """
1636 Normalizes os specific repo_name to the format internally stored inside
1637 database using URL_SEP
1638
1639 :param cls:
1640 :param repo_name:
1641 """
1642 return cls.NAME_SEP.join(repo_name.split(os.sep))
1643
1644 @classmethod
1645 def get_by_repo_name(cls, repo_name, cache=False, identity_cache=False):
1646 session = Session()
1647 q = session.query(cls).filter(cls.repo_name == repo_name)
1648
1649 if cache:
1650 if identity_cache:
1651 val = cls.identity_cache(session, 'repo_name', repo_name)
1652 if val:
1653 return val
1654 else:
1655 cache_key = "get_repo_by_name_%s" % _hash_key(repo_name)
1656 q = q.options(
1657 FromCache("sql_cache_short", cache_key))
1658
1659 return q.scalar()
1660
1661 @classmethod
1662 def get_by_full_path(cls, repo_full_path):
1663 repo_name = repo_full_path.split(cls.base_path(), 1)[-1]
1664 repo_name = cls.normalize_repo_name(repo_name)
1665 return cls.get_by_repo_name(repo_name.strip(URL_SEP))
1666
1667 @classmethod
1668 def get_repo_forks(cls, repo_id):
1669 return cls.query().filter(Repository.fork_id == repo_id)
1670
1671 @classmethod
1672 def base_path(cls):
1673 """
1674 Returns base path when all repos are stored
1675
1676 :param cls:
1677 """
1678 q = Session().query(RhodeCodeUi)\
1679 .filter(RhodeCodeUi.ui_key == cls.NAME_SEP)
1680 q = q.options(FromCache("sql_cache_short", "repository_repo_path"))
1681 return q.one().ui_value
1682
1683 @classmethod
1684 def is_valid(cls, repo_name):
1685 """
1686 returns True if given repo name is a valid filesystem repository
1687
1688 :param cls:
1689 :param repo_name:
1690 """
1691 from rhodecode.lib.utils import is_valid_repo
1692
1693 return is_valid_repo(repo_name, cls.base_path())
1694
1695 @classmethod
1696 def get_all_repos(cls, user_id=Optional(None), group_id=Optional(None),
1697 case_insensitive=True):
1698 q = Repository.query()
1699
1700 if not isinstance(user_id, Optional):
1701 q = q.filter(Repository.user_id == user_id)
1702
1703 if not isinstance(group_id, Optional):
1704 q = q.filter(Repository.group_id == group_id)
1705
1706 if case_insensitive:
1707 q = q.order_by(func.lower(Repository.repo_name))
1708 else:
1709 q = q.order_by(Repository.repo_name)
1710 return q.all()
1711
1712 @property
1713 def forks(self):
1714 """
1715 Return forks of this repo
1716 """
1717 return Repository.get_repo_forks(self.repo_id)
1718
1719 @property
1720 def parent(self):
1721 """
1722 Returns fork parent
1723 """
1724 return self.fork
1725
1726 @property
1727 def just_name(self):
1728 return self.repo_name.split(self.NAME_SEP)[-1]
1729
1730 @property
1731 def groups_with_parents(self):
1732 groups = []
1733 if self.group is None:
1734 return groups
1735
1736 cur_gr = self.group
1737 groups.insert(0, cur_gr)
1738 while 1:
1739 gr = getattr(cur_gr, 'parent_group', None)
1740 cur_gr = cur_gr.parent_group
1741 if gr is None:
1742 break
1743 groups.insert(0, gr)
1744
1745 return groups
1746
1747 @property
1748 def groups_and_repo(self):
1749 return self.groups_with_parents, self
1750
1751 @LazyProperty
1752 def repo_path(self):
1753 """
1754 Returns base full path for that repository means where it actually
1755 exists on a filesystem
1756 """
1757 q = Session().query(RhodeCodeUi).filter(
1758 RhodeCodeUi.ui_key == self.NAME_SEP)
1759 q = q.options(FromCache("sql_cache_short", "repository_repo_path"))
1760 return q.one().ui_value
1761
1762 @property
1763 def repo_full_path(self):
1764 p = [self.repo_path]
1765 # we need to split the name by / since this is how we store the
1766 # names in the database, but that eventually needs to be converted
1767 # into a valid system path
1768 p += self.repo_name.split(self.NAME_SEP)
1769 return os.path.join(*map(safe_unicode, p))
1770
1771 @property
1772 def cache_keys(self):
1773 """
1774 Returns associated cache keys for that repo
1775 """
1776 return CacheKey.query()\
1777 .filter(CacheKey.cache_args == self.repo_name)\
1778 .order_by(CacheKey.cache_key)\
1779 .all()
1780
1781 def get_new_name(self, repo_name):
1782 """
1783 returns new full repository name based on assigned group and new new
1784
1785 :param group_name:
1786 """
1787 path_prefix = self.group.full_path_splitted if self.group else []
1788 return self.NAME_SEP.join(path_prefix + [repo_name])
1789
1790 @property
1791 def _config(self):
1792 """
1793 Returns db based config object.
1794 """
1795 from rhodecode.lib.utils import make_db_config
1796 return make_db_config(clear_session=False, repo=self)
1797
1798 def permissions(self, with_admins=True, with_owner=True):
1799 q = UserRepoToPerm.query().filter(UserRepoToPerm.repository == self)
1800 q = q.options(joinedload(UserRepoToPerm.repository),
1801 joinedload(UserRepoToPerm.user),
1802 joinedload(UserRepoToPerm.permission),)
1803
1804 # get owners and admins and permissions. We do a trick of re-writing
1805 # objects from sqlalchemy to named-tuples due to sqlalchemy session
1806 # has a global reference and changing one object propagates to all
1807 # others. This means if admin is also an owner admin_row that change
1808 # would propagate to both objects
1809 perm_rows = []
1810 for _usr in q.all():
1811 usr = AttributeDict(_usr.user.get_dict())
1812 usr.permission = _usr.permission.permission_name
1813 perm_rows.append(usr)
1814
1815 # filter the perm rows by 'default' first and then sort them by
1816 # admin,write,read,none permissions sorted again alphabetically in
1817 # each group
1818 perm_rows = sorted(perm_rows, key=display_sort)
1819
1820 _admin_perm = 'repository.admin'
1821 owner_row = []
1822 if with_owner:
1823 usr = AttributeDict(self.user.get_dict())
1824 usr.owner_row = True
1825 usr.permission = _admin_perm
1826 owner_row.append(usr)
1827
1828 super_admin_rows = []
1829 if with_admins:
1830 for usr in User.get_all_super_admins():
1831 # if this admin is also owner, don't double the record
1832 if usr.user_id == owner_row[0].user_id:
1833 owner_row[0].admin_row = True
1834 else:
1835 usr = AttributeDict(usr.get_dict())
1836 usr.admin_row = True
1837 usr.permission = _admin_perm
1838 super_admin_rows.append(usr)
1839
1840 return super_admin_rows + owner_row + perm_rows
1841
1842 def permission_user_groups(self):
1843 q = UserGroupRepoToPerm.query().filter(
1844 UserGroupRepoToPerm.repository == self)
1845 q = q.options(joinedload(UserGroupRepoToPerm.repository),
1846 joinedload(UserGroupRepoToPerm.users_group),
1847 joinedload(UserGroupRepoToPerm.permission),)
1848
1849 perm_rows = []
1850 for _user_group in q.all():
1851 usr = AttributeDict(_user_group.users_group.get_dict())
1852 usr.permission = _user_group.permission.permission_name
1853 perm_rows.append(usr)
1854
1855 return perm_rows
1856
1857 def get_api_data(self, include_secrets=False):
1858 """
1859 Common function for generating repo api data
1860
1861 :param include_secrets: See :meth:`User.get_api_data`.
1862
1863 """
1864 # TODO: mikhail: Here there is an anti-pattern, we probably need to
1865 # move this methods on models level.
1866 from rhodecode.model.settings import SettingsModel
1867 from rhodecode.model.repo import RepoModel
1868
1869 repo = self
1870 _user_id, _time, _reason = self.locked
1871
1872 data = {
1873 'repo_id': repo.repo_id,
1874 'repo_name': repo.repo_name,
1875 'repo_type': repo.repo_type,
1876 'clone_uri': repo.clone_uri or '',
1877 'url': RepoModel().get_url(self),
1878 'private': repo.private,
1879 'created_on': repo.created_on,
1880 'description': repo.description_safe,
1881 'landing_rev': repo.landing_rev,
1882 'owner': repo.user.username,
1883 'fork_of': repo.fork.repo_name if repo.fork else None,
1884 'fork_of_id': repo.fork.repo_id if repo.fork else None,
1885 'enable_statistics': repo.enable_statistics,
1886 'enable_locking': repo.enable_locking,
1887 'enable_downloads': repo.enable_downloads,
1888 'last_changeset': repo.changeset_cache,
1889 'locked_by': User.get(_user_id).get_api_data(
1890 include_secrets=include_secrets) if _user_id else None,
1891 'locked_date': time_to_datetime(_time) if _time else None,
1892 'lock_reason': _reason if _reason else None,
1893 }
1894
1895 # TODO: mikhail: should be per-repo settings here
1896 rc_config = SettingsModel().get_all_settings()
1897 repository_fields = str2bool(
1898 rc_config.get('rhodecode_repository_fields'))
1899 if repository_fields:
1900 for f in self.extra_fields:
1901 data[f.field_key_prefixed] = f.field_value
1902
1903 return data
1904
1905 @classmethod
1906 def lock(cls, repo, user_id, lock_time=None, lock_reason=None):
1907 if not lock_time:
1908 lock_time = time.time()
1909 if not lock_reason:
1910 lock_reason = cls.LOCK_AUTOMATIC
1911 repo.locked = [user_id, lock_time, lock_reason]
1912 Session().add(repo)
1913 Session().commit()
1914
1915 @classmethod
1916 def unlock(cls, repo):
1917 repo.locked = None
1918 Session().add(repo)
1919 Session().commit()
1920
1921 @classmethod
1922 def getlock(cls, repo):
1923 return repo.locked
1924
1925 def is_user_lock(self, user_id):
1926 if self.lock[0]:
1927 lock_user_id = safe_int(self.lock[0])
1928 user_id = safe_int(user_id)
1929 # both are ints, and they are equal
1930 return all([lock_user_id, user_id]) and lock_user_id == user_id
1931
1932 return False
1933
1934 def get_locking_state(self, action, user_id, only_when_enabled=True):
1935 """
1936 Checks locking on this repository, if locking is enabled and lock is
1937 present returns a tuple of make_lock, locked, locked_by.
1938 make_lock can have 3 states None (do nothing) True, make lock
1939 False release lock, This value is later propagated to hooks, which
1940 do the locking. Think about this as signals passed to hooks what to do.
1941
1942 """
1943 # TODO: johbo: This is part of the business logic and should be moved
1944 # into the RepositoryModel.
1945
1946 if action not in ('push', 'pull'):
1947 raise ValueError("Invalid action value: %s" % repr(action))
1948
1949 # defines if locked error should be thrown to user
1950 currently_locked = False
1951 # defines if new lock should be made, tri-state
1952 make_lock = None
1953 repo = self
1954 user = User.get(user_id)
1955
1956 lock_info = repo.locked
1957
1958 if repo and (repo.enable_locking or not only_when_enabled):
1959 if action == 'push':
1960 # check if it's already locked !, if it is compare users
1961 locked_by_user_id = lock_info[0]
1962 if user.user_id == locked_by_user_id:
1963 log.debug(
1964 'Got `push` action from user %s, now unlocking', user)
1965 # unlock if we have push from user who locked
1966 make_lock = False
1967 else:
1968 # we're not the same user who locked, ban with
1969 # code defined in settings (default is 423 HTTP Locked) !
1970 log.debug('Repo %s is currently locked by %s', repo, user)
1971 currently_locked = True
1972 elif action == 'pull':
1973 # [0] user [1] date
1974 if lock_info[0] and lock_info[1]:
1975 log.debug('Repo %s is currently locked by %s', repo, user)
1976 currently_locked = True
1977 else:
1978 log.debug('Setting lock on repo %s by %s', repo, user)
1979 make_lock = True
1980
1981 else:
1982 log.debug('Repository %s do not have locking enabled', repo)
1983
1984 log.debug('FINAL locking values make_lock:%s,locked:%s,locked_by:%s',
1985 make_lock, currently_locked, lock_info)
1986
1987 from rhodecode.lib.auth import HasRepoPermissionAny
1988 perm_check = HasRepoPermissionAny('repository.write', 'repository.admin')
1989 if make_lock and not perm_check(repo_name=repo.repo_name, user=user):
1990 # if we don't have at least write permission we cannot make a lock
1991 log.debug('lock state reset back to FALSE due to lack '
1992 'of at least read permission')
1993 make_lock = False
1994
1995 return make_lock, currently_locked, lock_info
1996
1997 @property
1998 def last_db_change(self):
1999 return self.updated_on
2000
2001 @property
2002 def clone_uri_hidden(self):
2003 clone_uri = self.clone_uri
2004 if clone_uri:
2005 import urlobject
2006 url_obj = urlobject.URLObject(cleaned_uri(clone_uri))
2007 if url_obj.password:
2008 clone_uri = url_obj.with_password('*****')
2009 return clone_uri
2010
2011 def clone_url(self, **override):
2012 from rhodecode.model.settings import SettingsModel
2013
2014 uri_tmpl = None
2015 if 'with_id' in override:
2016 uri_tmpl = self.DEFAULT_CLONE_URI_ID
2017 del override['with_id']
2018
2019 if 'uri_tmpl' in override:
2020 uri_tmpl = override['uri_tmpl']
2021 del override['uri_tmpl']
2022
2023 # we didn't override our tmpl from **overrides
2024 if not uri_tmpl:
2025 rc_config = SettingsModel().get_all_settings(cache=True)
2026 uri_tmpl = rc_config.get(
2027 'rhodecode_clone_uri_tmpl') or self.DEFAULT_CLONE_URI
2028
2029 request = get_current_request()
2030 return get_clone_url(request=request,
2031 uri_tmpl=uri_tmpl,
2032 repo_name=self.repo_name,
2033 repo_id=self.repo_id, **override)
2034
2035 def set_state(self, state):
2036 self.repo_state = state
2037 Session().add(self)
2038 #==========================================================================
2039 # SCM PROPERTIES
2040 #==========================================================================
2041
2042 def get_commit(self, commit_id=None, commit_idx=None, pre_load=None):
2043 return get_commit_safe(
2044 self.scm_instance(), commit_id, commit_idx, pre_load=pre_load)
2045
2046 def get_changeset(self, rev=None, pre_load=None):
2047 warnings.warn("Use get_commit", DeprecationWarning)
2048 commit_id = None
2049 commit_idx = None
2050 if isinstance(rev, basestring):
2051 commit_id = rev
2052 else:
2053 commit_idx = rev
2054 return self.get_commit(commit_id=commit_id, commit_idx=commit_idx,
2055 pre_load=pre_load)
2056
2057 def get_landing_commit(self):
2058 """
2059 Returns landing commit, or if that doesn't exist returns the tip
2060 """
2061 _rev_type, _rev = self.landing_rev
2062 commit = self.get_commit(_rev)
2063 if isinstance(commit, EmptyCommit):
2064 return self.get_commit()
2065 return commit
2066
2067 def update_commit_cache(self, cs_cache=None, config=None):
2068 """
2069 Update cache of last changeset for repository, keys should be::
2070
2071 short_id
2072 raw_id
2073 revision
2074 parents
2075 message
2076 date
2077 author
2078
2079 :param cs_cache:
2080 """
2081 from rhodecode.lib.vcs.backends.base import BaseChangeset
2082 if cs_cache is None:
2083 # use no-cache version here
2084 scm_repo = self.scm_instance(cache=False, config=config)
2085 if scm_repo:
2086 cs_cache = scm_repo.get_commit(
2087 pre_load=["author", "date", "message", "parents"])
2088 else:
2089 cs_cache = EmptyCommit()
2090
2091 if isinstance(cs_cache, BaseChangeset):
2092 cs_cache = cs_cache.__json__()
2093
2094 def is_outdated(new_cs_cache):
2095 if (new_cs_cache['raw_id'] != self.changeset_cache['raw_id'] or
2096 new_cs_cache['revision'] != self.changeset_cache['revision']):
2097 return True
2098 return False
2099
2100 # check if we have maybe already latest cached revision
2101 if is_outdated(cs_cache) or not self.changeset_cache:
2102 _default = datetime.datetime.fromtimestamp(0)
2103 last_change = cs_cache.get('date') or _default
2104 log.debug('updated repo %s with new cs cache %s',
2105 self.repo_name, cs_cache)
2106 self.updated_on = last_change
2107 self.changeset_cache = cs_cache
2108 Session().add(self)
2109 Session().commit()
2110 else:
2111 log.debug('Skipping update_commit_cache for repo:`%s` '
2112 'commit already with latest changes', self.repo_name)
2113
2114 @property
2115 def tip(self):
2116 return self.get_commit('tip')
2117
2118 @property
2119 def author(self):
2120 return self.tip.author
2121
2122 @property
2123 def last_change(self):
2124 return self.scm_instance().last_change
2125
2126 def get_comments(self, revisions=None):
2127 """
2128 Returns comments for this repository grouped by revisions
2129
2130 :param revisions: filter query by revisions only
2131 """
2132 cmts = ChangesetComment.query()\
2133 .filter(ChangesetComment.repo == self)
2134 if revisions:
2135 cmts = cmts.filter(ChangesetComment.revision.in_(revisions))
2136 grouped = collections.defaultdict(list)
2137 for cmt in cmts.all():
2138 grouped[cmt.revision].append(cmt)
2139 return grouped
2140
2141 def statuses(self, revisions=None):
2142 """
2143 Returns statuses for this repository
2144
2145 :param revisions: list of revisions to get statuses for
2146 """
2147 statuses = ChangesetStatus.query()\
2148 .filter(ChangesetStatus.repo == self)\
2149 .filter(ChangesetStatus.version == 0)
2150
2151 if revisions:
2152 # Try doing the filtering in chunks to avoid hitting limits
2153 size = 500
2154 status_results = []
2155 for chunk in xrange(0, len(revisions), size):
2156 status_results += statuses.filter(
2157 ChangesetStatus.revision.in_(
2158 revisions[chunk: chunk+size])
2159 ).all()
2160 else:
2161 status_results = statuses.all()
2162
2163 grouped = {}
2164
2165 # maybe we have open new pullrequest without a status?
2166 stat = ChangesetStatus.STATUS_UNDER_REVIEW
2167 status_lbl = ChangesetStatus.get_status_lbl(stat)
2168 for pr in PullRequest.query().filter(PullRequest.source_repo == self).all():
2169 for rev in pr.revisions:
2170 pr_id = pr.pull_request_id
2171 pr_repo = pr.target_repo.repo_name
2172 grouped[rev] = [stat, status_lbl, pr_id, pr_repo]
2173
2174 for stat in status_results:
2175 pr_id = pr_repo = None
2176 if stat.pull_request:
2177 pr_id = stat.pull_request.pull_request_id
2178 pr_repo = stat.pull_request.target_repo.repo_name
2179 grouped[stat.revision] = [str(stat.status), stat.status_lbl,
2180 pr_id, pr_repo]
2181 return grouped
2182
2183 # ==========================================================================
2184 # SCM CACHE INSTANCE
2185 # ==========================================================================
2186
2187 def scm_instance(self, **kwargs):
2188 import rhodecode
2189
2190 # Passing a config will not hit the cache currently only used
2191 # for repo2dbmapper
2192 config = kwargs.pop('config', None)
2193 cache = kwargs.pop('cache', None)
2194 full_cache = str2bool(rhodecode.CONFIG.get('vcs_full_cache'))
2195 # if cache is NOT defined use default global, else we have a full
2196 # control over cache behaviour
2197 if cache is None and full_cache and not config:
2198 return self._get_instance_cached()
2199 return self._get_instance(cache=bool(cache), config=config)
2200
2201 def _get_instance_cached(self):
2202 @cache_region('long_term')
2203 def _get_repo(cache_key):
2204 return self._get_instance()
2205
2206 invalidator_context = CacheKey.repo_context_cache(
2207 _get_repo, self.repo_name, None, thread_scoped=True)
2208
2209 with invalidator_context as context:
2210 context.invalidate()
2211 repo = context.compute()
2212
2213 return repo
2214
2215 def _get_instance(self, cache=True, config=None):
2216 config = config or self._config
2217 custom_wire = {
2218 'cache': cache # controls the vcs.remote cache
2219 }
2220 repo = get_vcs_instance(
2221 repo_path=safe_str(self.repo_full_path),
2222 config=config,
2223 with_wire=custom_wire,
2224 create=False,
2225 _vcs_alias=self.repo_type)
2226
2227 return repo
2228
2229 def __json__(self):
2230 return {'landing_rev': self.landing_rev}
2231
2232 def get_dict(self):
2233
2234 # Since we transformed `repo_name` to a hybrid property, we need to
2235 # keep compatibility with the code which uses `repo_name` field.
2236
2237 result = super(Repository, self).get_dict()
2238 result['repo_name'] = result.pop('_repo_name', None)
2239 return result
2240
2241
2242 class RepoGroup(Base, BaseModel):
2243 __tablename__ = 'groups'
2244 __table_args__ = (
2245 UniqueConstraint('group_name', 'group_parent_id'),
2246 CheckConstraint('group_id != group_parent_id'),
2247 {'extend_existing': True, 'mysql_engine': 'InnoDB',
2248 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
2249 )
2250 __mapper_args__ = {'order_by': 'group_name'}
2251
2252 CHOICES_SEPARATOR = '/' # used to generate select2 choices for nested groups
2253
2254 group_id = Column("group_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
2255 group_name = Column("group_name", String(255), nullable=False, unique=True, default=None)
2256 group_parent_id = Column("group_parent_id", Integer(), ForeignKey('groups.group_id'), nullable=True, unique=None, default=None)
2257 group_description = Column("group_description", String(10000), nullable=True, unique=None, default=None)
2258 enable_locking = Column("enable_locking", Boolean(), nullable=False, unique=None, default=False)
2259 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=False, default=None)
2260 created_on = Column('created_on', DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
2261 updated_on = Column('updated_on', DateTime(timezone=False), nullable=True, unique=None, default=datetime.datetime.now)
2262 personal = Column('personal', Boolean(), nullable=True, unique=None, default=None)
2263
2264 repo_group_to_perm = relationship('UserRepoGroupToPerm', cascade='all', order_by='UserRepoGroupToPerm.group_to_perm_id')
2265 users_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
2266 parent_group = relationship('RepoGroup', remote_side=group_id)
2267 user = relationship('User')
2268 integrations = relationship('Integration',
2269 cascade="all, delete, delete-orphan")
2270
2271 def __init__(self, group_name='', parent_group=None):
2272 self.group_name = group_name
2273 self.parent_group = parent_group
2274
2275 def __unicode__(self):
2276 return u"<%s('id:%s:%s')>" % (
2277 self.__class__.__name__, self.group_id, self.group_name)
2278
2279 @hybrid_property
2280 def description_safe(self):
2281 from rhodecode.lib import helpers as h
2282 return h.escape(self.group_description)
2283
2284 @classmethod
2285 def _generate_choice(cls, repo_group):
2286 from webhelpers.html import literal as _literal
2287 _name = lambda k: _literal(cls.CHOICES_SEPARATOR.join(k))
2288 return repo_group.group_id, _name(repo_group.full_path_splitted)
2289
2290 @classmethod
2291 def groups_choices(cls, groups=None, show_empty_group=True):
2292 if not groups:
2293 groups = cls.query().all()
2294
2295 repo_groups = []
2296 if show_empty_group:
2297 repo_groups = [(-1, u'-- %s --' % _('No parent'))]
2298
2299 repo_groups.extend([cls._generate_choice(x) for x in groups])
2300
2301 repo_groups = sorted(
2302 repo_groups, key=lambda t: t[1].split(cls.CHOICES_SEPARATOR)[0])
2303 return repo_groups
2304
2305 @classmethod
2306 def url_sep(cls):
2307 return URL_SEP
2308
2309 @classmethod
2310 def get_by_group_name(cls, group_name, cache=False, case_insensitive=False):
2311 if case_insensitive:
2312 gr = cls.query().filter(func.lower(cls.group_name)
2313 == func.lower(group_name))
2314 else:
2315 gr = cls.query().filter(cls.group_name == group_name)
2316 if cache:
2317 name_key = _hash_key(group_name)
2318 gr = gr.options(
2319 FromCache("sql_cache_short", "get_group_%s" % name_key))
2320 return gr.scalar()
2321
2322 @classmethod
2323 def get_user_personal_repo_group(cls, user_id):
2324 user = User.get(user_id)
2325 if user.username == User.DEFAULT_USER:
2326 return None
2327
2328 return cls.query()\
2329 .filter(cls.personal == true()) \
2330 .filter(cls.user == user).scalar()
2331
2332 @classmethod
2333 def get_all_repo_groups(cls, user_id=Optional(None), group_id=Optional(None),
2334 case_insensitive=True):
2335 q = RepoGroup.query()
2336
2337 if not isinstance(user_id, Optional):
2338 q = q.filter(RepoGroup.user_id == user_id)
2339
2340 if not isinstance(group_id, Optional):
2341 q = q.filter(RepoGroup.group_parent_id == group_id)
2342
2343 if case_insensitive:
2344 q = q.order_by(func.lower(RepoGroup.group_name))
2345 else:
2346 q = q.order_by(RepoGroup.group_name)
2347 return q.all()
2348
2349 @property
2350 def parents(self):
2351 parents_recursion_limit = 10
2352 groups = []
2353 if self.parent_group is None:
2354 return groups
2355 cur_gr = self.parent_group
2356 groups.insert(0, cur_gr)
2357 cnt = 0
2358 while 1:
2359 cnt += 1
2360 gr = getattr(cur_gr, 'parent_group', None)
2361 cur_gr = cur_gr.parent_group
2362 if gr is None:
2363 break
2364 if cnt == parents_recursion_limit:
2365 # this will prevent accidental infinit loops
2366 log.error(('more than %s parents found for group %s, stopping '
2367 'recursive parent fetching' % (parents_recursion_limit, self)))
2368 break
2369
2370 groups.insert(0, gr)
2371 return groups
2372
2373 @property
2374 def last_db_change(self):
2375 return self.updated_on
2376
2377 @property
2378 def children(self):
2379 return RepoGroup.query().filter(RepoGroup.parent_group == self)
2380
2381 @property
2382 def name(self):
2383 return self.group_name.split(RepoGroup.url_sep())[-1]
2384
2385 @property
2386 def full_path(self):
2387 return self.group_name
2388
2389 @property
2390 def full_path_splitted(self):
2391 return self.group_name.split(RepoGroup.url_sep())
2392
2393 @property
2394 def repositories(self):
2395 return Repository.query()\
2396 .filter(Repository.group == self)\
2397 .order_by(Repository.repo_name)
2398
2399 @property
2400 def repositories_recursive_count(self):
2401 cnt = self.repositories.count()
2402
2403 def children_count(group):
2404 cnt = 0
2405 for child in group.children:
2406 cnt += child.repositories.count()
2407 cnt += children_count(child)
2408 return cnt
2409
2410 return cnt + children_count(self)
2411
2412 def _recursive_objects(self, include_repos=True):
2413 all_ = []
2414
2415 def _get_members(root_gr):
2416 if include_repos:
2417 for r in root_gr.repositories:
2418 all_.append(r)
2419 childs = root_gr.children.all()
2420 if childs:
2421 for gr in childs:
2422 all_.append(gr)
2423 _get_members(gr)
2424
2425 _get_members(self)
2426 return [self] + all_
2427
2428 def recursive_groups_and_repos(self):
2429 """
2430 Recursive return all groups, with repositories in those groups
2431 """
2432 return self._recursive_objects()
2433
2434 def recursive_groups(self):
2435 """
2436 Returns all children groups for this group including children of children
2437 """
2438 return self._recursive_objects(include_repos=False)
2439
2440 def get_new_name(self, group_name):
2441 """
2442 returns new full group name based on parent and new name
2443
2444 :param group_name:
2445 """
2446 path_prefix = (self.parent_group.full_path_splitted if
2447 self.parent_group else [])
2448 return RepoGroup.url_sep().join(path_prefix + [group_name])
2449
2450 def permissions(self, with_admins=True, with_owner=True):
2451 q = UserRepoGroupToPerm.query().filter(UserRepoGroupToPerm.group == self)
2452 q = q.options(joinedload(UserRepoGroupToPerm.group),
2453 joinedload(UserRepoGroupToPerm.user),
2454 joinedload(UserRepoGroupToPerm.permission),)
2455
2456 # get owners and admins and permissions. We do a trick of re-writing
2457 # objects from sqlalchemy to named-tuples due to sqlalchemy session
2458 # has a global reference and changing one object propagates to all
2459 # others. This means if admin is also an owner admin_row that change
2460 # would propagate to both objects
2461 perm_rows = []
2462 for _usr in q.all():
2463 usr = AttributeDict(_usr.user.get_dict())
2464 usr.permission = _usr.permission.permission_name
2465 perm_rows.append(usr)
2466
2467 # filter the perm rows by 'default' first and then sort them by
2468 # admin,write,read,none permissions sorted again alphabetically in
2469 # each group
2470 perm_rows = sorted(perm_rows, key=display_sort)
2471
2472 _admin_perm = 'group.admin'
2473 owner_row = []
2474 if with_owner:
2475 usr = AttributeDict(self.user.get_dict())
2476 usr.owner_row = True
2477 usr.permission = _admin_perm
2478 owner_row.append(usr)
2479
2480 super_admin_rows = []
2481 if with_admins:
2482 for usr in User.get_all_super_admins():
2483 # if this admin is also owner, don't double the record
2484 if usr.user_id == owner_row[0].user_id:
2485 owner_row[0].admin_row = True
2486 else:
2487 usr = AttributeDict(usr.get_dict())
2488 usr.admin_row = True
2489 usr.permission = _admin_perm
2490 super_admin_rows.append(usr)
2491
2492 return super_admin_rows + owner_row + perm_rows
2493
2494 def permission_user_groups(self):
2495 q = UserGroupRepoGroupToPerm.query().filter(UserGroupRepoGroupToPerm.group == self)
2496 q = q.options(joinedload(UserGroupRepoGroupToPerm.group),
2497 joinedload(UserGroupRepoGroupToPerm.users_group),
2498 joinedload(UserGroupRepoGroupToPerm.permission),)
2499
2500 perm_rows = []
2501 for _user_group in q.all():
2502 usr = AttributeDict(_user_group.users_group.get_dict())
2503 usr.permission = _user_group.permission.permission_name
2504 perm_rows.append(usr)
2505
2506 return perm_rows
2507
2508 def get_api_data(self):
2509 """
2510 Common function for generating api data
2511
2512 """
2513 group = self
2514 data = {
2515 'group_id': group.group_id,
2516 'group_name': group.group_name,
2517 'group_description': group.description_safe,
2518 'parent_group': group.parent_group.group_name if group.parent_group else None,
2519 'repositories': [x.repo_name for x in group.repositories],
2520 'owner': group.user.username,
2521 }
2522 return data
2523
2524
2525 class Permission(Base, BaseModel):
2526 __tablename__ = 'permissions'
2527 __table_args__ = (
2528 Index('p_perm_name_idx', 'permission_name'),
2529 {'extend_existing': True, 'mysql_engine': 'InnoDB',
2530 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
2531 )
2532 PERMS = [
2533 ('hg.admin', _('RhodeCode Super Administrator')),
2534
2535 ('repository.none', _('Repository no access')),
2536 ('repository.read', _('Repository read access')),
2537 ('repository.write', _('Repository write access')),
2538 ('repository.admin', _('Repository admin access')),
2539
2540 ('group.none', _('Repository group no access')),
2541 ('group.read', _('Repository group read access')),
2542 ('group.write', _('Repository group write access')),
2543 ('group.admin', _('Repository group admin access')),
2544
2545 ('usergroup.none', _('User group no access')),
2546 ('usergroup.read', _('User group read access')),
2547 ('usergroup.write', _('User group write access')),
2548 ('usergroup.admin', _('User group admin access')),
2549
2550 ('hg.repogroup.create.false', _('Repository Group creation disabled')),
2551 ('hg.repogroup.create.true', _('Repository Group creation enabled')),
2552
2553 ('hg.usergroup.create.false', _('User Group creation disabled')),
2554 ('hg.usergroup.create.true', _('User Group creation enabled')),
2555
2556 ('hg.create.none', _('Repository creation disabled')),
2557 ('hg.create.repository', _('Repository creation enabled')),
2558 ('hg.create.write_on_repogroup.true', _('Repository creation enabled with write permission to a repository group')),
2559 ('hg.create.write_on_repogroup.false', _('Repository creation disabled with write permission to a repository group')),
2560
2561 ('hg.fork.none', _('Repository forking disabled')),
2562 ('hg.fork.repository', _('Repository forking enabled')),
2563
2564 ('hg.register.none', _('Registration disabled')),
2565 ('hg.register.manual_activate', _('User Registration with manual account activation')),
2566 ('hg.register.auto_activate', _('User Registration with automatic account activation')),
2567
2568 ('hg.password_reset.enabled', _('Password reset enabled')),
2569 ('hg.password_reset.hidden', _('Password reset hidden')),
2570 ('hg.password_reset.disabled', _('Password reset disabled')),
2571
2572 ('hg.extern_activate.manual', _('Manual activation of external account')),
2573 ('hg.extern_activate.auto', _('Automatic activation of external account')),
2574
2575 ('hg.inherit_default_perms.false', _('Inherit object permissions from default user disabled')),
2576 ('hg.inherit_default_perms.true', _('Inherit object permissions from default user enabled')),
2577 ]
2578
2579 # definition of system default permissions for DEFAULT user
2580 DEFAULT_USER_PERMISSIONS = [
2581 'repository.read',
2582 'group.read',
2583 'usergroup.read',
2584 'hg.create.repository',
2585 'hg.repogroup.create.false',
2586 'hg.usergroup.create.false',
2587 'hg.create.write_on_repogroup.true',
2588 'hg.fork.repository',
2589 'hg.register.manual_activate',
2590 'hg.password_reset.enabled',
2591 'hg.extern_activate.auto',
2592 'hg.inherit_default_perms.true',
2593 ]
2594
2595 # defines which permissions are more important higher the more important
2596 # Weight defines which permissions are more important.
2597 # The higher number the more important.
2598 PERM_WEIGHTS = {
2599 'repository.none': 0,
2600 'repository.read': 1,
2601 'repository.write': 3,
2602 'repository.admin': 4,
2603
2604 'group.none': 0,
2605 'group.read': 1,
2606 'group.write': 3,
2607 'group.admin': 4,
2608
2609 'usergroup.none': 0,
2610 'usergroup.read': 1,
2611 'usergroup.write': 3,
2612 'usergroup.admin': 4,
2613
2614 'hg.repogroup.create.false': 0,
2615 'hg.repogroup.create.true': 1,
2616
2617 'hg.usergroup.create.false': 0,
2618 'hg.usergroup.create.true': 1,
2619
2620 'hg.fork.none': 0,
2621 'hg.fork.repository': 1,
2622 'hg.create.none': 0,
2623 'hg.create.repository': 1
2624 }
2625
2626 permission_id = Column("permission_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
2627 permission_name = Column("permission_name", String(255), nullable=True, unique=None, default=None)
2628 permission_longname = Column("permission_longname", String(255), nullable=True, unique=None, default=None)
2629
2630 def __unicode__(self):
2631 return u"<%s('%s:%s')>" % (
2632 self.__class__.__name__, self.permission_id, self.permission_name
2633 )
2634
2635 @classmethod
2636 def get_by_key(cls, key):
2637 return cls.query().filter(cls.permission_name == key).scalar()
2638
2639 @classmethod
2640 def get_default_repo_perms(cls, user_id, repo_id=None):
2641 q = Session().query(UserRepoToPerm, Repository, Permission)\
2642 .join((Permission, UserRepoToPerm.permission_id == Permission.permission_id))\
2643 .join((Repository, UserRepoToPerm.repository_id == Repository.repo_id))\
2644 .filter(UserRepoToPerm.user_id == user_id)
2645 if repo_id:
2646 q = q.filter(UserRepoToPerm.repository_id == repo_id)
2647 return q.all()
2648
2649 @classmethod
2650 def get_default_repo_perms_from_user_group(cls, user_id, repo_id=None):
2651 q = Session().query(UserGroupRepoToPerm, Repository, Permission)\
2652 .join(
2653 Permission,
2654 UserGroupRepoToPerm.permission_id == Permission.permission_id)\
2655 .join(
2656 Repository,
2657 UserGroupRepoToPerm.repository_id == Repository.repo_id)\
2658 .join(
2659 UserGroup,
2660 UserGroupRepoToPerm.users_group_id ==
2661 UserGroup.users_group_id)\
2662 .join(
2663 UserGroupMember,
2664 UserGroupRepoToPerm.users_group_id ==
2665 UserGroupMember.users_group_id)\
2666 .filter(
2667 UserGroupMember.user_id == user_id,
2668 UserGroup.users_group_active == true())
2669 if repo_id:
2670 q = q.filter(UserGroupRepoToPerm.repository_id == repo_id)
2671 return q.all()
2672
2673 @classmethod
2674 def get_default_group_perms(cls, user_id, repo_group_id=None):
2675 q = Session().query(UserRepoGroupToPerm, RepoGroup, Permission)\
2676 .join((Permission, UserRepoGroupToPerm.permission_id == Permission.permission_id))\
2677 .join((RepoGroup, UserRepoGroupToPerm.group_id == RepoGroup.group_id))\
2678 .filter(UserRepoGroupToPerm.user_id == user_id)
2679 if repo_group_id:
2680 q = q.filter(UserRepoGroupToPerm.group_id == repo_group_id)
2681 return q.all()
2682
2683 @classmethod
2684 def get_default_group_perms_from_user_group(
2685 cls, user_id, repo_group_id=None):
2686 q = Session().query(UserGroupRepoGroupToPerm, RepoGroup, Permission)\
2687 .join(
2688 Permission,
2689 UserGroupRepoGroupToPerm.permission_id ==
2690 Permission.permission_id)\
2691 .join(
2692 RepoGroup,
2693 UserGroupRepoGroupToPerm.group_id == RepoGroup.group_id)\
2694 .join(
2695 UserGroup,
2696 UserGroupRepoGroupToPerm.users_group_id ==
2697 UserGroup.users_group_id)\
2698 .join(
2699 UserGroupMember,
2700 UserGroupRepoGroupToPerm.users_group_id ==
2701 UserGroupMember.users_group_id)\
2702 .filter(
2703 UserGroupMember.user_id == user_id,
2704 UserGroup.users_group_active == true())
2705 if repo_group_id:
2706 q = q.filter(UserGroupRepoGroupToPerm.group_id == repo_group_id)
2707 return q.all()
2708
2709 @classmethod
2710 def get_default_user_group_perms(cls, user_id, user_group_id=None):
2711 q = Session().query(UserUserGroupToPerm, UserGroup, Permission)\
2712 .join((Permission, UserUserGroupToPerm.permission_id == Permission.permission_id))\
2713 .join((UserGroup, UserUserGroupToPerm.user_group_id == UserGroup.users_group_id))\
2714 .filter(UserUserGroupToPerm.user_id == user_id)
2715 if user_group_id:
2716 q = q.filter(UserUserGroupToPerm.user_group_id == user_group_id)
2717 return q.all()
2718
2719 @classmethod
2720 def get_default_user_group_perms_from_user_group(
2721 cls, user_id, user_group_id=None):
2722 TargetUserGroup = aliased(UserGroup, name='target_user_group')
2723 q = Session().query(UserGroupUserGroupToPerm, UserGroup, Permission)\
2724 .join(
2725 Permission,
2726 UserGroupUserGroupToPerm.permission_id ==
2727 Permission.permission_id)\
2728 .join(
2729 TargetUserGroup,
2730 UserGroupUserGroupToPerm.target_user_group_id ==
2731 TargetUserGroup.users_group_id)\
2732 .join(
2733 UserGroup,
2734 UserGroupUserGroupToPerm.user_group_id ==
2735 UserGroup.users_group_id)\
2736 .join(
2737 UserGroupMember,
2738 UserGroupUserGroupToPerm.user_group_id ==
2739 UserGroupMember.users_group_id)\
2740 .filter(
2741 UserGroupMember.user_id == user_id,
2742 UserGroup.users_group_active == true())
2743 if user_group_id:
2744 q = q.filter(
2745 UserGroupUserGroupToPerm.user_group_id == user_group_id)
2746
2747 return q.all()
2748
2749
2750 class UserRepoToPerm(Base, BaseModel):
2751 __tablename__ = 'repo_to_perm'
2752 __table_args__ = (
2753 UniqueConstraint('user_id', 'repository_id', 'permission_id'),
2754 {'extend_existing': True, 'mysql_engine': 'InnoDB',
2755 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
2756 )
2757 repo_to_perm_id = Column("repo_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
2758 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=None, default=None)
2759 permission_id = Column("permission_id", Integer(), ForeignKey('permissions.permission_id'), nullable=False, unique=None, default=None)
2760 repository_id = Column("repository_id", Integer(), ForeignKey('repositories.repo_id'), nullable=False, unique=None, default=None)
2761
2762 user = relationship('User')
2763 repository = relationship('Repository')
2764 permission = relationship('Permission')
2765
2766 @classmethod
2767 def create(cls, user, repository, permission):
2768 n = cls()
2769 n.user = user
2770 n.repository = repository
2771 n.permission = permission
2772 Session().add(n)
2773 return n
2774
2775 def __unicode__(self):
2776 return u'<%s => %s >' % (self.user, self.repository)
2777
2778
2779 class UserUserGroupToPerm(Base, BaseModel):
2780 __tablename__ = 'user_user_group_to_perm'
2781 __table_args__ = (
2782 UniqueConstraint('user_id', 'user_group_id', 'permission_id'),
2783 {'extend_existing': True, 'mysql_engine': 'InnoDB',
2784 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
2785 )
2786 user_user_group_to_perm_id = Column("user_user_group_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
2787 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=None, default=None)
2788 permission_id = Column("permission_id", Integer(), ForeignKey('permissions.permission_id'), nullable=False, unique=None, default=None)
2789 user_group_id = Column("user_group_id", Integer(), ForeignKey('users_groups.users_group_id'), nullable=False, unique=None, default=None)
2790
2791 user = relationship('User')
2792 user_group = relationship('UserGroup')
2793 permission = relationship('Permission')
2794
2795 @classmethod
2796 def create(cls, user, user_group, permission):
2797 n = cls()
2798 n.user = user
2799 n.user_group = user_group
2800 n.permission = permission
2801 Session().add(n)
2802 return n
2803
2804 def __unicode__(self):
2805 return u'<%s => %s >' % (self.user, self.user_group)
2806
2807
2808 class UserToPerm(Base, BaseModel):
2809 __tablename__ = 'user_to_perm'
2810 __table_args__ = (
2811 UniqueConstraint('user_id', 'permission_id'),
2812 {'extend_existing': True, 'mysql_engine': 'InnoDB',
2813 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
2814 )
2815 user_to_perm_id = Column("user_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
2816 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=None, default=None)
2817 permission_id = Column("permission_id", Integer(), ForeignKey('permissions.permission_id'), nullable=False, unique=None, default=None)
2818
2819 user = relationship('User')
2820 permission = relationship('Permission', lazy='joined')
2821
2822 def __unicode__(self):
2823 return u'<%s => %s >' % (self.user, self.permission)
2824
2825
2826 class UserGroupRepoToPerm(Base, BaseModel):
2827 __tablename__ = 'users_group_repo_to_perm'
2828 __table_args__ = (
2829 UniqueConstraint('repository_id', 'users_group_id', 'permission_id'),
2830 {'extend_existing': True, 'mysql_engine': 'InnoDB',
2831 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
2832 )
2833 users_group_to_perm_id = Column("users_group_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
2834 users_group_id = Column("users_group_id", Integer(), ForeignKey('users_groups.users_group_id'), nullable=False, unique=None, default=None)
2835 permission_id = Column("permission_id", Integer(), ForeignKey('permissions.permission_id'), nullable=False, unique=None, default=None)
2836 repository_id = Column("repository_id", Integer(), ForeignKey('repositories.repo_id'), nullable=False, unique=None, default=None)
2837
2838 users_group = relationship('UserGroup')
2839 permission = relationship('Permission')
2840 repository = relationship('Repository')
2841
2842 @classmethod
2843 def create(cls, users_group, repository, permission):
2844 n = cls()
2845 n.users_group = users_group
2846 n.repository = repository
2847 n.permission = permission
2848 Session().add(n)
2849 return n
2850
2851 def __unicode__(self):
2852 return u'<UserGroupRepoToPerm:%s => %s >' % (self.users_group, self.repository)
2853
2854
2855 class UserGroupUserGroupToPerm(Base, BaseModel):
2856 __tablename__ = 'user_group_user_group_to_perm'
2857 __table_args__ = (
2858 UniqueConstraint('target_user_group_id', 'user_group_id', 'permission_id'),
2859 CheckConstraint('target_user_group_id != user_group_id'),
2860 {'extend_existing': True, 'mysql_engine': 'InnoDB',
2861 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
2862 )
2863 user_group_user_group_to_perm_id = Column("user_group_user_group_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
2864 target_user_group_id = Column("target_user_group_id", Integer(), ForeignKey('users_groups.users_group_id'), nullable=False, unique=None, default=None)
2865 permission_id = Column("permission_id", Integer(), ForeignKey('permissions.permission_id'), nullable=False, unique=None, default=None)
2866 user_group_id = Column("user_group_id", Integer(), ForeignKey('users_groups.users_group_id'), nullable=False, unique=None, default=None)
2867
2868 target_user_group = relationship('UserGroup', primaryjoin='UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id')
2869 user_group = relationship('UserGroup', primaryjoin='UserGroupUserGroupToPerm.user_group_id==UserGroup.users_group_id')
2870 permission = relationship('Permission')
2871
2872 @classmethod
2873 def create(cls, target_user_group, user_group, permission):
2874 n = cls()
2875 n.target_user_group = target_user_group
2876 n.user_group = user_group
2877 n.permission = permission
2878 Session().add(n)
2879 return n
2880
2881 def __unicode__(self):
2882 return u'<UserGroupUserGroup:%s => %s >' % (self.target_user_group, self.user_group)
2883
2884
2885 class UserGroupToPerm(Base, BaseModel):
2886 __tablename__ = 'users_group_to_perm'
2887 __table_args__ = (
2888 UniqueConstraint('users_group_id', 'permission_id',),
2889 {'extend_existing': True, 'mysql_engine': 'InnoDB',
2890 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
2891 )
2892 users_group_to_perm_id = Column("users_group_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
2893 users_group_id = Column("users_group_id", Integer(), ForeignKey('users_groups.users_group_id'), nullable=False, unique=None, default=None)
2894 permission_id = Column("permission_id", Integer(), ForeignKey('permissions.permission_id'), nullable=False, unique=None, default=None)
2895
2896 users_group = relationship('UserGroup')
2897 permission = relationship('Permission')
2898
2899
2900 class UserRepoGroupToPerm(Base, BaseModel):
2901 __tablename__ = 'user_repo_group_to_perm'
2902 __table_args__ = (
2903 UniqueConstraint('user_id', 'group_id', 'permission_id'),
2904 {'extend_existing': True, 'mysql_engine': 'InnoDB',
2905 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
2906 )
2907
2908 group_to_perm_id = Column("group_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
2909 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=None, default=None)
2910 group_id = Column("group_id", Integer(), ForeignKey('groups.group_id'), nullable=False, unique=None, default=None)
2911 permission_id = Column("permission_id", Integer(), ForeignKey('permissions.permission_id'), nullable=False, unique=None, default=None)
2912
2913 user = relationship('User')
2914 group = relationship('RepoGroup')
2915 permission = relationship('Permission')
2916
2917 @classmethod
2918 def create(cls, user, repository_group, permission):
2919 n = cls()
2920 n.user = user
2921 n.group = repository_group
2922 n.permission = permission
2923 Session().add(n)
2924 return n
2925
2926
2927 class UserGroupRepoGroupToPerm(Base, BaseModel):
2928 __tablename__ = 'users_group_repo_group_to_perm'
2929 __table_args__ = (
2930 UniqueConstraint('users_group_id', 'group_id'),
2931 {'extend_existing': True, 'mysql_engine': 'InnoDB',
2932 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
2933 )
2934
2935 users_group_repo_group_to_perm_id = Column("users_group_repo_group_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
2936 users_group_id = Column("users_group_id", Integer(), ForeignKey('users_groups.users_group_id'), nullable=False, unique=None, default=None)
2937 group_id = Column("group_id", Integer(), ForeignKey('groups.group_id'), nullable=False, unique=None, default=None)
2938 permission_id = Column("permission_id", Integer(), ForeignKey('permissions.permission_id'), nullable=False, unique=None, default=None)
2939
2940 users_group = relationship('UserGroup')
2941 permission = relationship('Permission')
2942 group = relationship('RepoGroup')
2943
2944 @classmethod
2945 def create(cls, user_group, repository_group, permission):
2946 n = cls()
2947 n.users_group = user_group
2948 n.group = repository_group
2949 n.permission = permission
2950 Session().add(n)
2951 return n
2952
2953 def __unicode__(self):
2954 return u'<UserGroupRepoGroupToPerm:%s => %s >' % (self.users_group, self.group)
2955
2956
2957 class Statistics(Base, BaseModel):
2958 __tablename__ = 'statistics'
2959 __table_args__ = (
2960 {'extend_existing': True, 'mysql_engine': 'InnoDB',
2961 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
2962 )
2963 stat_id = Column("stat_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
2964 repository_id = Column("repository_id", Integer(), ForeignKey('repositories.repo_id'), nullable=False, unique=True, default=None)
2965 stat_on_revision = Column("stat_on_revision", Integer(), nullable=False)
2966 commit_activity = Column("commit_activity", LargeBinary(1000000), nullable=False)#JSON data
2967 commit_activity_combined = Column("commit_activity_combined", LargeBinary(), nullable=False)#JSON data
2968 languages = Column("languages", LargeBinary(1000000), nullable=False)#JSON data
2969
2970 repository = relationship('Repository', single_parent=True)
2971
2972
2973 class UserFollowing(Base, BaseModel):
2974 __tablename__ = 'user_followings'
2975 __table_args__ = (
2976 UniqueConstraint('user_id', 'follows_repository_id'),
2977 UniqueConstraint('user_id', 'follows_user_id'),
2978 {'extend_existing': True, 'mysql_engine': 'InnoDB',
2979 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
2980 )
2981
2982 user_following_id = Column("user_following_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
2983 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=None, default=None)
2984 follows_repo_id = Column("follows_repository_id", Integer(), ForeignKey('repositories.repo_id'), nullable=True, unique=None, default=None)
2985 follows_user_id = Column("follows_user_id", Integer(), ForeignKey('users.user_id'), nullable=True, unique=None, default=None)
2986 follows_from = Column('follows_from', DateTime(timezone=False), nullable=True, unique=None, default=datetime.datetime.now)
2987
2988 user = relationship('User', primaryjoin='User.user_id==UserFollowing.user_id')
2989
2990 follows_user = relationship('User', primaryjoin='User.user_id==UserFollowing.follows_user_id')
2991 follows_repository = relationship('Repository', order_by='Repository.repo_name')
2992
2993 @classmethod
2994 def get_repo_followers(cls, repo_id):
2995 return cls.query().filter(cls.follows_repo_id == repo_id)
2996
2997
2998 class CacheKey(Base, BaseModel):
2999 __tablename__ = 'cache_invalidation'
3000 __table_args__ = (
3001 UniqueConstraint('cache_key'),
3002 Index('key_idx', 'cache_key'),
3003 {'extend_existing': True, 'mysql_engine': 'InnoDB',
3004 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
3005 )
3006 CACHE_TYPE_ATOM = 'ATOM'
3007 CACHE_TYPE_RSS = 'RSS'
3008 CACHE_TYPE_README = 'README'
3009
3010 cache_id = Column("cache_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
3011 cache_key = Column("cache_key", String(255), nullable=True, unique=None, default=None)
3012 cache_args = Column("cache_args", String(255), nullable=True, unique=None, default=None)
3013 cache_active = Column("cache_active", Boolean(), nullable=True, unique=None, default=False)
3014
3015 def __init__(self, cache_key, cache_args=''):
3016 self.cache_key = cache_key
3017 self.cache_args = cache_args
3018 self.cache_active = False
3019
3020 def __unicode__(self):
3021 return u"<%s('%s:%s[%s]')>" % (
3022 self.__class__.__name__,
3023 self.cache_id, self.cache_key, self.cache_active)
3024
3025 def _cache_key_partition(self):
3026 prefix, repo_name, suffix = self.cache_key.partition(self.cache_args)
3027 return prefix, repo_name, suffix
3028
3029 def get_prefix(self):
3030 """
3031 Try to extract prefix from existing cache key. The key could consist
3032 of prefix, repo_name, suffix
3033 """
3034 # this returns prefix, repo_name, suffix
3035 return self._cache_key_partition()[0]
3036
3037 def get_suffix(self):
3038 """
3039 get suffix that might have been used in _get_cache_key to
3040 generate self.cache_key. Only used for informational purposes
3041 in repo_edit.mako.
3042 """
3043 # prefix, repo_name, suffix
3044 return self._cache_key_partition()[2]
3045
3046 @classmethod
3047 def delete_all_cache(cls):
3048 """
3049 Delete all cache keys from database.
3050 Should only be run when all instances are down and all entries
3051 thus stale.
3052 """
3053 cls.query().delete()
3054 Session().commit()
3055
3056 @classmethod
3057 def get_cache_key(cls, repo_name, cache_type):
3058 """
3059
3060 Generate a cache key for this process of RhodeCode instance.
3061 Prefix most likely will be process id or maybe explicitly set
3062 instance_id from .ini file.
3063 """
3064 import rhodecode
3065 prefix = safe_unicode(rhodecode.CONFIG.get('instance_id') or '')
3066
3067 repo_as_unicode = safe_unicode(repo_name)
3068 key = u'{}_{}'.format(repo_as_unicode, cache_type) \
3069 if cache_type else repo_as_unicode
3070
3071 return u'{}{}'.format(prefix, key)
3072
3073 @classmethod
3074 def set_invalidate(cls, repo_name, delete=False):
3075 """
3076 Mark all caches of a repo as invalid in the database.
3077 """
3078
3079 try:
3080 qry = Session().query(cls).filter(cls.cache_args == repo_name)
3081 if delete:
3082 log.debug('cache objects deleted for repo %s',
3083 safe_str(repo_name))
3084 qry.delete()
3085 else:
3086 log.debug('cache objects marked as invalid for repo %s',
3087 safe_str(repo_name))
3088 qry.update({"cache_active": False})
3089
3090 Session().commit()
3091 except Exception:
3092 log.exception(
3093 'Cache key invalidation failed for repository %s',
3094 safe_str(repo_name))
3095 Session().rollback()
3096
3097 @classmethod
3098 def get_active_cache(cls, cache_key):
3099 inv_obj = cls.query().filter(cls.cache_key == cache_key).scalar()
3100 if inv_obj:
3101 return inv_obj
3102 return None
3103
3104 @classmethod
3105 def repo_context_cache(cls, compute_func, repo_name, cache_type,
3106 thread_scoped=False):
3107 """
3108 @cache_region('long_term')
3109 def _heavy_calculation(cache_key):
3110 return 'result'
3111
3112 cache_context = CacheKey.repo_context_cache(
3113 _heavy_calculation, repo_name, cache_type)
3114
3115 with cache_context as context:
3116 context.invalidate()
3117 computed = context.compute()
3118
3119 assert computed == 'result'
3120 """
3121 from rhodecode.lib import caches
3122 return caches.InvalidationContext(
3123 compute_func, repo_name, cache_type, thread_scoped=thread_scoped)
3124
3125
3126 class ChangesetComment(Base, BaseModel):
3127 __tablename__ = 'changeset_comments'
3128 __table_args__ = (
3129 Index('cc_revision_idx', 'revision'),
3130 {'extend_existing': True, 'mysql_engine': 'InnoDB',
3131 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
3132 )
3133
3134 COMMENT_OUTDATED = u'comment_outdated'
3135 COMMENT_TYPE_NOTE = u'note'
3136 COMMENT_TYPE_TODO = u'todo'
3137 COMMENT_TYPES = [COMMENT_TYPE_NOTE, COMMENT_TYPE_TODO]
3138
3139 comment_id = Column('comment_id', Integer(), nullable=False, primary_key=True)
3140 repo_id = Column('repo_id', Integer(), ForeignKey('repositories.repo_id'), nullable=False)
3141 revision = Column('revision', String(40), nullable=True)
3142 pull_request_id = Column("pull_request_id", Integer(), ForeignKey('pull_requests.pull_request_id'), nullable=True)
3143 pull_request_version_id = Column("pull_request_version_id", Integer(), ForeignKey('pull_request_versions.pull_request_version_id'), nullable=True)
3144 line_no = Column('line_no', Unicode(10), nullable=True)
3145 hl_lines = Column('hl_lines', Unicode(512), nullable=True)
3146 f_path = Column('f_path', Unicode(1000), nullable=True)
3147 user_id = Column('user_id', Integer(), ForeignKey('users.user_id'), nullable=False)
3148 text = Column('text', UnicodeText().with_variant(UnicodeText(25000), 'mysql'), nullable=False)
3149 created_on = Column('created_on', DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
3150 modified_at = Column('modified_at', DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
3151 renderer = Column('renderer', Unicode(64), nullable=True)
3152 display_state = Column('display_state', Unicode(128), nullable=True)
3153
3154 comment_type = Column('comment_type', Unicode(128), nullable=True, default=COMMENT_TYPE_NOTE)
3155 resolved_comment_id = Column('resolved_comment_id', Integer(), ForeignKey('changeset_comments.comment_id'), nullable=True)
3156 resolved_comment = relationship('ChangesetComment', remote_side=comment_id, backref='resolved_by')
3157 author = relationship('User', lazy='joined')
3158 repo = relationship('Repository')
3159 status_change = relationship('ChangesetStatus', cascade="all, delete, delete-orphan", lazy='joined')
3160 pull_request = relationship('PullRequest', lazy='joined')
3161 pull_request_version = relationship('PullRequestVersion')
3162
3163 @classmethod
3164 def get_users(cls, revision=None, pull_request_id=None):
3165 """
3166 Returns user associated with this ChangesetComment. ie those
3167 who actually commented
3168
3169 :param cls:
3170 :param revision:
3171 """
3172 q = Session().query(User)\
3173 .join(ChangesetComment.author)
3174 if revision:
3175 q = q.filter(cls.revision == revision)
3176 elif pull_request_id:
3177 q = q.filter(cls.pull_request_id == pull_request_id)
3178 return q.all()
3179
3180 @classmethod
3181 def get_index_from_version(cls, pr_version, versions):
3182 num_versions = [x.pull_request_version_id for x in versions]
3183 try:
3184 return num_versions.index(pr_version) +1
3185 except (IndexError, ValueError):
3186 return
3187
3188 @property
3189 def outdated(self):
3190 return self.display_state == self.COMMENT_OUTDATED
3191
3192 def outdated_at_version(self, version):
3193 """
3194 Checks if comment is outdated for given pull request version
3195 """
3196 return self.outdated and self.pull_request_version_id != version
3197
3198 def older_than_version(self, version):
3199 """
3200 Checks if comment is made from previous version than given
3201 """
3202 if version is None:
3203 return self.pull_request_version_id is not None
3204
3205 return self.pull_request_version_id < version
3206
3207 @property
3208 def resolved(self):
3209 return self.resolved_by[0] if self.resolved_by else None
3210
3211 @property
3212 def is_todo(self):
3213 return self.comment_type == self.COMMENT_TYPE_TODO
3214
3215 @property
3216 def is_inline(self):
3217 return self.line_no and self.f_path
3218
3219 def get_index_version(self, versions):
3220 return self.get_index_from_version(
3221 self.pull_request_version_id, versions)
3222
3223 def __repr__(self):
3224 if self.comment_id:
3225 return '<DB:Comment #%s>' % self.comment_id
3226 else:
3227 return '<DB:Comment at %#x>' % id(self)
3228
3229 def get_api_data(self):
3230 comment = self
3231 data = {
3232 'comment_id': comment.comment_id,
3233 'comment_type': comment.comment_type,
3234 'comment_text': comment.text,
3235 'comment_status': comment.status_change,
3236 'comment_f_path': comment.f_path,
3237 'comment_lineno': comment.line_no,
3238 'comment_author': comment.author,
3239 'comment_created_on': comment.created_on
3240 }
3241 return data
3242
3243 def __json__(self):
3244 data = dict()
3245 data.update(self.get_api_data())
3246 return data
3247
3248
3249 class ChangesetStatus(Base, BaseModel):
3250 __tablename__ = 'changeset_statuses'
3251 __table_args__ = (
3252 Index('cs_revision_idx', 'revision'),
3253 Index('cs_version_idx', 'version'),
3254 UniqueConstraint('repo_id', 'revision', 'version'),
3255 {'extend_existing': True, 'mysql_engine': 'InnoDB',
3256 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
3257 )
3258 STATUS_NOT_REVIEWED = DEFAULT = 'not_reviewed'
3259 STATUS_APPROVED = 'approved'
3260 STATUS_REJECTED = 'rejected'
3261 STATUS_UNDER_REVIEW = 'under_review'
3262
3263 STATUSES = [
3264 (STATUS_NOT_REVIEWED, _("Not Reviewed")), # (no icon) and default
3265 (STATUS_APPROVED, _("Approved")),
3266 (STATUS_REJECTED, _("Rejected")),
3267 (STATUS_UNDER_REVIEW, _("Under Review")),
3268 ]
3269
3270 changeset_status_id = Column('changeset_status_id', Integer(), nullable=False, primary_key=True)
3271 repo_id = Column('repo_id', Integer(), ForeignKey('repositories.repo_id'), nullable=False)
3272 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=None)
3273 revision = Column('revision', String(40), nullable=False)
3274 status = Column('status', String(128), nullable=False, default=DEFAULT)
3275 changeset_comment_id = Column('changeset_comment_id', Integer(), ForeignKey('changeset_comments.comment_id'))
3276 modified_at = Column('modified_at', DateTime(), nullable=False, default=datetime.datetime.now)
3277 version = Column('version', Integer(), nullable=False, default=0)
3278 pull_request_id = Column("pull_request_id", Integer(), ForeignKey('pull_requests.pull_request_id'), nullable=True)
3279
3280 author = relationship('User', lazy='joined')
3281 repo = relationship('Repository')
3282 comment = relationship('ChangesetComment', lazy='joined')
3283 pull_request = relationship('PullRequest', lazy='joined')
3284
3285 def __unicode__(self):
3286 return u"<%s('%s[v%s]:%s')>" % (
3287 self.__class__.__name__,
3288 self.status, self.version, self.author
3289 )
3290
3291 @classmethod
3292 def get_status_lbl(cls, value):
3293 return dict(cls.STATUSES).get(value)
3294
3295 @property
3296 def status_lbl(self):
3297 return ChangesetStatus.get_status_lbl(self.status)
3298
3299 def get_api_data(self):
3300 status = self
3301 data = {
3302 'status_id': status.changeset_status_id,
3303 'status': status.status,
3304 }
3305 return data
3306
3307 def __json__(self):
3308 data = dict()
3309 data.update(self.get_api_data())
3310 return data
3311
3312
3313 class _PullRequestBase(BaseModel):
3314 """
3315 Common attributes of pull request and version entries.
3316 """
3317
3318 # .status values
3319 STATUS_NEW = u'new'
3320 STATUS_OPEN = u'open'
3321 STATUS_CLOSED = u'closed'
3322
3323 title = Column('title', Unicode(255), nullable=True)
3324 description = Column(
3325 'description', UnicodeText().with_variant(UnicodeText(10240), 'mysql'),
3326 nullable=True)
3327 # new/open/closed status of pull request (not approve/reject/etc)
3328 status = Column('status', Unicode(255), nullable=False, default=STATUS_NEW)
3329 created_on = Column(
3330 'created_on', DateTime(timezone=False), nullable=False,
3331 default=datetime.datetime.now)
3332 updated_on = Column(
3333 'updated_on', DateTime(timezone=False), nullable=False,
3334 default=datetime.datetime.now)
3335
3336 @declared_attr
3337 def user_id(cls):
3338 return Column(
3339 "user_id", Integer(), ForeignKey('users.user_id'), nullable=False,
3340 unique=None)
3341
3342 # 500 revisions max
3343 _revisions = Column(
3344 'revisions', UnicodeText().with_variant(UnicodeText(20500), 'mysql'))
3345
3346 @declared_attr
3347 def source_repo_id(cls):
3348 # TODO: dan: rename column to source_repo_id
3349 return Column(
3350 'org_repo_id', Integer(), ForeignKey('repositories.repo_id'),
3351 nullable=False)
3352
3353 source_ref = Column('org_ref', Unicode(255), nullable=False)
3354
3355 @declared_attr
3356 def target_repo_id(cls):
3357 # TODO: dan: rename column to target_repo_id
3358 return Column(
3359 'other_repo_id', Integer(), ForeignKey('repositories.repo_id'),
3360 nullable=False)
3361
3362 target_ref = Column('other_ref', Unicode(255), nullable=False)
3363 _shadow_merge_ref = Column('shadow_merge_ref', Unicode(255), nullable=True)
3364
3365 # TODO: dan: rename column to last_merge_source_rev
3366 _last_merge_source_rev = Column(
3367 'last_merge_org_rev', String(40), nullable=True)
3368 # TODO: dan: rename column to last_merge_target_rev
3369 _last_merge_target_rev = Column(
3370 'last_merge_other_rev', String(40), nullable=True)
3371 _last_merge_status = Column('merge_status', Integer(), nullable=True)
3372 merge_rev = Column('merge_rev', String(40), nullable=True)
3373
3374 reviewer_data = Column(
3375 'reviewer_data_json', MutationObj.as_mutable(
3376 JsonType(dialect_map=dict(mysql=UnicodeText(16384)))))
3377
3378 @property
3379 def reviewer_data_json(self):
3380 return json.dumps(self.reviewer_data)
3381
3382 @hybrid_property
3383 def description_safe(self):
3384 from rhodecode.lib import helpers as h
3385 return h.escape(self.description)
3386
3387 @hybrid_property
3388 def revisions(self):
3389 return self._revisions.split(':') if self._revisions else []
3390
3391 @revisions.setter
3392 def revisions(self, val):
3393 self._revisions = ':'.join(val)
3394
3395 @hybrid_property
3396 def last_merge_status(self):
3397 return safe_int(self._last_merge_status)
3398
3399 @last_merge_status.setter
3400 def last_merge_status(self, val):
3401 self._last_merge_status = val
3402
3403 @declared_attr
3404 def author(cls):
3405 return relationship('User', lazy='joined')
3406
3407 @declared_attr
3408 def source_repo(cls):
3409 return relationship(
3410 'Repository',
3411 primaryjoin='%s.source_repo_id==Repository.repo_id' % cls.__name__)
3412
3413 @property
3414 def source_ref_parts(self):
3415 return self.unicode_to_reference(self.source_ref)
3416
3417 @declared_attr
3418 def target_repo(cls):
3419 return relationship(
3420 'Repository',
3421 primaryjoin='%s.target_repo_id==Repository.repo_id' % cls.__name__)
3422
3423 @property
3424 def target_ref_parts(self):
3425 return self.unicode_to_reference(self.target_ref)
3426
3427 @property
3428 def shadow_merge_ref(self):
3429 return self.unicode_to_reference(self._shadow_merge_ref)
3430
3431 @shadow_merge_ref.setter
3432 def shadow_merge_ref(self, ref):
3433 self._shadow_merge_ref = self.reference_to_unicode(ref)
3434
3435 def unicode_to_reference(self, raw):
3436 """
3437 Convert a unicode (or string) to a reference object.
3438 If unicode evaluates to False it returns None.
3439 """
3440 if raw:
3441 refs = raw.split(':')
3442 return Reference(*refs)
3443 else:
3444 return None
3445
3446 def reference_to_unicode(self, ref):
3447 """
3448 Convert a reference object to unicode.
3449 If reference is None it returns None.
3450 """
3451 if ref:
3452 return u':'.join(ref)
3453 else:
3454 return None
3455
3456 def get_api_data(self, with_merge_state=True):
3457 from rhodecode.model.pull_request import PullRequestModel
3458
3459 pull_request = self
3460 if with_merge_state:
3461 merge_status = PullRequestModel().merge_status(pull_request)
3462 merge_state = {
3463 'status': merge_status[0],
3464 'message': safe_unicode(merge_status[1]),
3465 }
3466 else:
3467 merge_state = {'status': 'not_available',
3468 'message': 'not_available'}
3469
3470 merge_data = {
3471 'clone_url': PullRequestModel().get_shadow_clone_url(pull_request),
3472 'reference': (
3473 pull_request.shadow_merge_ref._asdict()
3474 if pull_request.shadow_merge_ref else None),
3475 }
3476
3477 data = {
3478 'pull_request_id': pull_request.pull_request_id,
3479 'url': PullRequestModel().get_url(pull_request),
3480 'title': pull_request.title,
3481 'description': pull_request.description,
3482 'status': pull_request.status,
3483 'created_on': pull_request.created_on,
3484 'updated_on': pull_request.updated_on,
3485 'commit_ids': pull_request.revisions,
3486 'review_status': pull_request.calculated_review_status(),
3487 'mergeable': merge_state,
3488 'source': {
3489 'clone_url': pull_request.source_repo.clone_url(),
3490 'repository': pull_request.source_repo.repo_name,
3491 'reference': {
3492 'name': pull_request.source_ref_parts.name,
3493 'type': pull_request.source_ref_parts.type,
3494 'commit_id': pull_request.source_ref_parts.commit_id,
3495 },
3496 },
3497 'target': {
3498 'clone_url': pull_request.target_repo.clone_url(),
3499 'repository': pull_request.target_repo.repo_name,
3500 'reference': {
3501 'name': pull_request.target_ref_parts.name,
3502 'type': pull_request.target_ref_parts.type,
3503 'commit_id': pull_request.target_ref_parts.commit_id,
3504 },
3505 },
3506 'merge': merge_data,
3507 'author': pull_request.author.get_api_data(include_secrets=False,
3508 details='basic'),
3509 'reviewers': [
3510 {
3511 'user': reviewer.get_api_data(include_secrets=False,
3512 details='basic'),
3513 'reasons': reasons,
3514 'review_status': st[0][1].status if st else 'not_reviewed',
3515 }
3516 for reviewer, reasons, mandatory, st in
3517 pull_request.reviewers_statuses()
3518 ]
3519 }
3520
3521 return data
3522
3523
3524 class PullRequest(Base, _PullRequestBase):
3525 __tablename__ = 'pull_requests'
3526 __table_args__ = (
3527 {'extend_existing': True, 'mysql_engine': 'InnoDB',
3528 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
3529 )
3530
3531 pull_request_id = Column(
3532 'pull_request_id', Integer(), nullable=False, primary_key=True)
3533
3534 def __repr__(self):
3535 if self.pull_request_id:
3536 return '<DB:PullRequest #%s>' % self.pull_request_id
3537 else:
3538 return '<DB:PullRequest at %#x>' % id(self)
3539
3540 reviewers = relationship('PullRequestReviewers',
3541 cascade="all, delete, delete-orphan")
3542 statuses = relationship('ChangesetStatus',
3543 cascade="all, delete, delete-orphan")
3544 comments = relationship('ChangesetComment',
3545 cascade="all, delete, delete-orphan")
3546 versions = relationship('PullRequestVersion',
3547 cascade="all, delete, delete-orphan",
3548 lazy='dynamic')
3549
3550 @classmethod
3551 def get_pr_display_object(cls, pull_request_obj, org_pull_request_obj,
3552 internal_methods=None):
3553
3554 class PullRequestDisplay(object):
3555 """
3556 Special object wrapper for showing PullRequest data via Versions
3557 It mimics PR object as close as possible. This is read only object
3558 just for display
3559 """
3560
3561 def __init__(self, attrs, internal=None):
3562 self.attrs = attrs
3563 # internal have priority over the given ones via attrs
3564 self.internal = internal or ['versions']
3565
3566 def __getattr__(self, item):
3567 if item in self.internal:
3568 return getattr(self, item)
3569 try:
3570 return self.attrs[item]
3571 except KeyError:
3572 raise AttributeError(
3573 '%s object has no attribute %s' % (self, item))
3574
3575 def __repr__(self):
3576 return '<DB:PullRequestDisplay #%s>' % self.attrs.get('pull_request_id')
3577
3578 def versions(self):
3579 return pull_request_obj.versions.order_by(
3580 PullRequestVersion.pull_request_version_id).all()
3581
3582 def is_closed(self):
3583 return pull_request_obj.is_closed()
3584
3585 @property
3586 def pull_request_version_id(self):
3587 return getattr(pull_request_obj, 'pull_request_version_id', None)
3588
3589 attrs = StrictAttributeDict(pull_request_obj.get_api_data())
3590
3591 attrs.author = StrictAttributeDict(
3592 pull_request_obj.author.get_api_data())
3593 if pull_request_obj.target_repo:
3594 attrs.target_repo = StrictAttributeDict(
3595 pull_request_obj.target_repo.get_api_data())
3596 attrs.target_repo.clone_url = pull_request_obj.target_repo.clone_url
3597
3598 if pull_request_obj.source_repo:
3599 attrs.source_repo = StrictAttributeDict(
3600 pull_request_obj.source_repo.get_api_data())
3601 attrs.source_repo.clone_url = pull_request_obj.source_repo.clone_url
3602
3603 attrs.source_ref_parts = pull_request_obj.source_ref_parts
3604 attrs.target_ref_parts = pull_request_obj.target_ref_parts
3605 attrs.revisions = pull_request_obj.revisions
3606
3607 attrs.shadow_merge_ref = org_pull_request_obj.shadow_merge_ref
3608 attrs.reviewer_data = org_pull_request_obj.reviewer_data
3609 attrs.reviewer_data_json = org_pull_request_obj.reviewer_data_json
3610
3611 return PullRequestDisplay(attrs, internal=internal_methods)
3612
3613 def is_closed(self):
3614 return self.status == self.STATUS_CLOSED
3615
3616 def __json__(self):
3617 return {
3618 'revisions': self.revisions,
3619 }
3620
3621 def calculated_review_status(self):
3622 from rhodecode.model.changeset_status import ChangesetStatusModel
3623 return ChangesetStatusModel().calculated_review_status(self)
3624
3625 def reviewers_statuses(self):
3626 from rhodecode.model.changeset_status import ChangesetStatusModel
3627 return ChangesetStatusModel().reviewers_statuses(self)
3628
3629 @property
3630 def workspace_id(self):
3631 from rhodecode.model.pull_request import PullRequestModel
3632 return PullRequestModel()._workspace_id(self)
3633
3634 def get_shadow_repo(self):
3635 workspace_id = self.workspace_id
3636 vcs_obj = self.target_repo.scm_instance()
3637 shadow_repository_path = vcs_obj._get_shadow_repository_path(
3638 workspace_id)
3639 return vcs_obj._get_shadow_instance(shadow_repository_path)
3640
3641
3642 class PullRequestVersion(Base, _PullRequestBase):
3643 __tablename__ = 'pull_request_versions'
3644 __table_args__ = (
3645 {'extend_existing': True, 'mysql_engine': 'InnoDB',
3646 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
3647 )
3648
3649 pull_request_version_id = Column(
3650 'pull_request_version_id', Integer(), nullable=False, primary_key=True)
3651 pull_request_id = Column(
3652 'pull_request_id', Integer(),
3653 ForeignKey('pull_requests.pull_request_id'), nullable=False)
3654 pull_request = relationship('PullRequest')
3655
3656 def __repr__(self):
3657 if self.pull_request_version_id:
3658 return '<DB:PullRequestVersion #%s>' % self.pull_request_version_id
3659 else:
3660 return '<DB:PullRequestVersion at %#x>' % id(self)
3661
3662 @property
3663 def reviewers(self):
3664 return self.pull_request.reviewers
3665
3666 @property
3667 def versions(self):
3668 return self.pull_request.versions
3669
3670 def is_closed(self):
3671 # calculate from original
3672 return self.pull_request.status == self.STATUS_CLOSED
3673
3674 def calculated_review_status(self):
3675 return self.pull_request.calculated_review_status()
3676
3677 def reviewers_statuses(self):
3678 return self.pull_request.reviewers_statuses()
3679
3680
3681 class PullRequestReviewers(Base, BaseModel):
3682 __tablename__ = 'pull_request_reviewers'
3683 __table_args__ = (
3684 {'extend_existing': True, 'mysql_engine': 'InnoDB',
3685 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
3686 )
3687
3688 @hybrid_property
3689 def reasons(self):
3690 if not self._reasons:
3691 return []
3692 return self._reasons
3693
3694 @reasons.setter
3695 def reasons(self, val):
3696 val = val or []
3697 if any(not isinstance(x, basestring) for x in val):
3698 raise Exception('invalid reasons type, must be list of strings')
3699 self._reasons = val
3700
3701 pull_requests_reviewers_id = Column(
3702 'pull_requests_reviewers_id', Integer(), nullable=False,
3703 primary_key=True)
3704 pull_request_id = Column(
3705 "pull_request_id", Integer(),
3706 ForeignKey('pull_requests.pull_request_id'), nullable=False)
3707 user_id = Column(
3708 "user_id", Integer(), ForeignKey('users.user_id'), nullable=True)
3709 _reasons = Column(
3710 'reason', MutationList.as_mutable(
3711 JsonType('list', dialect_map=dict(mysql=UnicodeText(16384)))))
3712 mandatory = Column("mandatory", Boolean(), nullable=False, default=False)
3713 user = relationship('User')
3714 pull_request = relationship('PullRequest')
3715
3716
3717 class Notification(Base, BaseModel):
3718 __tablename__ = 'notifications'
3719 __table_args__ = (
3720 Index('notification_type_idx', 'type'),
3721 {'extend_existing': True, 'mysql_engine': 'InnoDB',
3722 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
3723 )
3724
3725 TYPE_CHANGESET_COMMENT = u'cs_comment'
3726 TYPE_MESSAGE = u'message'
3727 TYPE_MENTION = u'mention'
3728 TYPE_REGISTRATION = u'registration'
3729 TYPE_PULL_REQUEST = u'pull_request'
3730 TYPE_PULL_REQUEST_COMMENT = u'pull_request_comment'
3731
3732 notification_id = Column('notification_id', Integer(), nullable=False, primary_key=True)
3733 subject = Column('subject', Unicode(512), nullable=True)
3734 body = Column('body', UnicodeText().with_variant(UnicodeText(50000), 'mysql'), nullable=True)
3735 created_by = Column("created_by", Integer(), ForeignKey('users.user_id'), nullable=True)
3736 created_on = Column('created_on', DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
3737 type_ = Column('type', Unicode(255))
3738
3739 created_by_user = relationship('User')
3740 notifications_to_users = relationship('UserNotification', lazy='joined',
3741 cascade="all, delete, delete-orphan")
3742
3743 @property
3744 def recipients(self):
3745 return [x.user for x in UserNotification.query()\
3746 .filter(UserNotification.notification == self)\
3747 .order_by(UserNotification.user_id.asc()).all()]
3748
3749 @classmethod
3750 def create(cls, created_by, subject, body, recipients, type_=None):
3751 if type_ is None:
3752 type_ = Notification.TYPE_MESSAGE
3753
3754 notification = cls()
3755 notification.created_by_user = created_by
3756 notification.subject = subject
3757 notification.body = body
3758 notification.type_ = type_
3759 notification.created_on = datetime.datetime.now()
3760
3761 for u in recipients:
3762 assoc = UserNotification()
3763 assoc.notification = notification
3764
3765 # if created_by is inside recipients mark his notification
3766 # as read
3767 if u.user_id == created_by.user_id:
3768 assoc.read = True
3769
3770 u.notifications.append(assoc)
3771 Session().add(notification)
3772
3773 return notification
3774
3775
3776 class UserNotification(Base, BaseModel):
3777 __tablename__ = 'user_to_notification'
3778 __table_args__ = (
3779 UniqueConstraint('user_id', 'notification_id'),
3780 {'extend_existing': True, 'mysql_engine': 'InnoDB',
3781 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
3782 )
3783 user_id = Column('user_id', Integer(), ForeignKey('users.user_id'), primary_key=True)
3784 notification_id = Column("notification_id", Integer(), ForeignKey('notifications.notification_id'), primary_key=True)
3785 read = Column('read', Boolean, default=False)
3786 sent_on = Column('sent_on', DateTime(timezone=False), nullable=True, unique=None)
3787
3788 user = relationship('User', lazy="joined")
3789 notification = relationship('Notification', lazy="joined",
3790 order_by=lambda: Notification.created_on.desc(),)
3791
3792 def mark_as_read(self):
3793 self.read = True
3794 Session().add(self)
3795
3796
3797 class Gist(Base, BaseModel):
3798 __tablename__ = 'gists'
3799 __table_args__ = (
3800 Index('g_gist_access_id_idx', 'gist_access_id'),
3801 Index('g_created_on_idx', 'created_on'),
3802 {'extend_existing': True, 'mysql_engine': 'InnoDB',
3803 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
3804 )
3805 GIST_PUBLIC = u'public'
3806 GIST_PRIVATE = u'private'
3807 DEFAULT_FILENAME = u'gistfile1.txt'
3808
3809 ACL_LEVEL_PUBLIC = u'acl_public'
3810 ACL_LEVEL_PRIVATE = u'acl_private'
3811
3812 gist_id = Column('gist_id', Integer(), primary_key=True)
3813 gist_access_id = Column('gist_access_id', Unicode(250))
3814 gist_description = Column('gist_description', UnicodeText().with_variant(UnicodeText(1024), 'mysql'))
3815 gist_owner = Column('user_id', Integer(), ForeignKey('users.user_id'), nullable=True)
3816 gist_expires = Column('gist_expires', Float(53), nullable=False)
3817 gist_type = Column('gist_type', Unicode(128), nullable=False)
3818 created_on = Column('created_on', DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
3819 modified_at = Column('modified_at', DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
3820 acl_level = Column('acl_level', Unicode(128), nullable=True)
3821
3822 owner = relationship('User')
3823
3824 def __repr__(self):
3825 return '<Gist:[%s]%s>' % (self.gist_type, self.gist_access_id)
3826
3827 @hybrid_property
3828 def description_safe(self):
3829 from rhodecode.lib import helpers as h
3830 return h.escape(self.gist_description)
3831
3832 @classmethod
3833 def get_or_404(cls, id_):
3834 from pyramid.httpexceptions import HTTPNotFound
3835
3836 res = cls.query().filter(cls.gist_access_id == id_).scalar()
3837 if not res:
3838 raise HTTPNotFound()
3839 return res
3840
3841 @classmethod
3842 def get_by_access_id(cls, gist_access_id):
3843 return cls.query().filter(cls.gist_access_id == gist_access_id).scalar()
3844
3845 def gist_url(self):
3846 from rhodecode.model.gist import GistModel
3847 return GistModel().get_url(self)
3848
3849 @classmethod
3850 def base_path(cls):
3851 """
3852 Returns base path when all gists are stored
3853
3854 :param cls:
3855 """
3856 from rhodecode.model.gist import GIST_STORE_LOC
3857 q = Session().query(RhodeCodeUi)\
3858 .filter(RhodeCodeUi.ui_key == URL_SEP)
3859 q = q.options(FromCache("sql_cache_short", "repository_repo_path"))
3860 return os.path.join(q.one().ui_value, GIST_STORE_LOC)
3861
3862 def get_api_data(self):
3863 """
3864 Common function for generating gist related data for API
3865 """
3866 gist = self
3867 data = {
3868 'gist_id': gist.gist_id,
3869 'type': gist.gist_type,
3870 'access_id': gist.gist_access_id,
3871 'description': gist.gist_description,
3872 'url': gist.gist_url(),
3873 'expires': gist.gist_expires,
3874 'created_on': gist.created_on,
3875 'modified_at': gist.modified_at,
3876 'content': None,
3877 'acl_level': gist.acl_level,
3878 }
3879 return data
3880
3881 def __json__(self):
3882 data = dict(
3883 )
3884 data.update(self.get_api_data())
3885 return data
3886 # SCM functions
3887
3888 def scm_instance(self, **kwargs):
3889 full_repo_path = os.path.join(self.base_path(), self.gist_access_id)
3890 return get_vcs_instance(
3891 repo_path=safe_str(full_repo_path), create=False)
3892
3893
3894 class ExternalIdentity(Base, BaseModel):
3895 __tablename__ = 'external_identities'
3896 __table_args__ = (
3897 Index('local_user_id_idx', 'local_user_id'),
3898 Index('external_id_idx', 'external_id'),
3899 {'extend_existing': True, 'mysql_engine': 'InnoDB',
3900 'mysql_charset': 'utf8'})
3901
3902 external_id = Column('external_id', Unicode(255), default=u'',
3903 primary_key=True)
3904 external_username = Column('external_username', Unicode(1024), default=u'')
3905 local_user_id = Column('local_user_id', Integer(),
3906 ForeignKey('users.user_id'), primary_key=True)
3907 provider_name = Column('provider_name', Unicode(255), default=u'',
3908 primary_key=True)
3909 access_token = Column('access_token', String(1024), default=u'')
3910 alt_token = Column('alt_token', String(1024), default=u'')
3911 token_secret = Column('token_secret', String(1024), default=u'')
3912
3913 @classmethod
3914 def by_external_id_and_provider(cls, external_id, provider_name,
3915 local_user_id=None):
3916 """
3917 Returns ExternalIdentity instance based on search params
3918
3919 :param external_id:
3920 :param provider_name:
3921 :return: ExternalIdentity
3922 """
3923 query = cls.query()
3924 query = query.filter(cls.external_id == external_id)
3925 query = query.filter(cls.provider_name == provider_name)
3926 if local_user_id:
3927 query = query.filter(cls.local_user_id == local_user_id)
3928 return query.first()
3929
3930 @classmethod
3931 def user_by_external_id_and_provider(cls, external_id, provider_name):
3932 """
3933 Returns User instance based on search params
3934
3935 :param external_id:
3936 :param provider_name:
3937 :return: User
3938 """
3939 query = User.query()
3940 query = query.filter(cls.external_id == external_id)
3941 query = query.filter(cls.provider_name == provider_name)
3942 query = query.filter(User.user_id == cls.local_user_id)
3943 return query.first()
3944
3945 @classmethod
3946 def by_local_user_id(cls, local_user_id):
3947 """
3948 Returns all tokens for user
3949
3950 :param local_user_id:
3951 :return: ExternalIdentity
3952 """
3953 query = cls.query()
3954 query = query.filter(cls.local_user_id == local_user_id)
3955 return query
3956
3957
3958 class Integration(Base, BaseModel):
3959 __tablename__ = 'integrations'
3960 __table_args__ = (
3961 {'extend_existing': True, 'mysql_engine': 'InnoDB',
3962 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
3963 )
3964
3965 integration_id = Column('integration_id', Integer(), primary_key=True)
3966 integration_type = Column('integration_type', String(255))
3967 enabled = Column('enabled', Boolean(), nullable=False)
3968 name = Column('name', String(255), nullable=False)
3969 child_repos_only = Column('child_repos_only', Boolean(), nullable=False,
3970 default=False)
3971
3972 settings = Column(
3973 'settings_json', MutationObj.as_mutable(
3974 JsonType(dialect_map=dict(mysql=UnicodeText(16384)))))
3975 repo_id = Column(
3976 'repo_id', Integer(), ForeignKey('repositories.repo_id'),
3977 nullable=True, unique=None, default=None)
3978 repo = relationship('Repository', lazy='joined')
3979
3980 repo_group_id = Column(
3981 'repo_group_id', Integer(), ForeignKey('groups.group_id'),
3982 nullable=True, unique=None, default=None)
3983 repo_group = relationship('RepoGroup', lazy='joined')
3984
3985 @property
3986 def scope(self):
3987 if self.repo:
3988 return repr(self.repo)
3989 if self.repo_group:
3990 if self.child_repos_only:
3991 return repr(self.repo_group) + ' (child repos only)'
3992 else:
3993 return repr(self.repo_group) + ' (recursive)'
3994 if self.child_repos_only:
3995 return 'root_repos'
3996 return 'global'
3997
3998 def __repr__(self):
3999 return '<Integration(%r, %r)>' % (self.integration_type, self.scope)
4000
4001
4002 class RepoReviewRuleUser(Base, BaseModel):
4003 __tablename__ = 'repo_review_rules_users'
4004 __table_args__ = (
4005 {'extend_existing': True, 'mysql_engine': 'InnoDB',
4006 'mysql_charset': 'utf8', 'sqlite_autoincrement': True,}
4007 )
4008 repo_review_rule_user_id = Column('repo_review_rule_user_id', Integer(), primary_key=True)
4009 repo_review_rule_id = Column("repo_review_rule_id", Integer(), ForeignKey('repo_review_rules.repo_review_rule_id'))
4010 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False)
4011 mandatory = Column("mandatory", Boolean(), nullable=False, default=False)
4012 user = relationship('User')
4013
4014 def rule_data(self):
4015 return {
4016 'mandatory': self.mandatory
4017 }
4018
4019
4020 class RepoReviewRuleUserGroup(Base, BaseModel):
4021 __tablename__ = 'repo_review_rules_users_groups'
4022 __table_args__ = (
4023 {'extend_existing': True, 'mysql_engine': 'InnoDB',
4024 'mysql_charset': 'utf8', 'sqlite_autoincrement': True,}
4025 )
4026 repo_review_rule_users_group_id = Column('repo_review_rule_users_group_id', Integer(), primary_key=True)
4027 repo_review_rule_id = Column("repo_review_rule_id", Integer(), ForeignKey('repo_review_rules.repo_review_rule_id'))
4028 users_group_id = Column("users_group_id", Integer(),ForeignKey('users_groups.users_group_id'), nullable=False)
4029 mandatory = Column("mandatory", Boolean(), nullable=False, default=False)
4030 users_group = relationship('UserGroup')
4031
4032 def rule_data(self):
4033 return {
4034 'mandatory': self.mandatory
4035 }
4036
4037
4038 class RepoReviewRule(Base, BaseModel):
4039 __tablename__ = 'repo_review_rules'
4040 __table_args__ = (
4041 {'extend_existing': True, 'mysql_engine': 'InnoDB',
4042 'mysql_charset': 'utf8', 'sqlite_autoincrement': True,}
4043 )
4044
4045 repo_review_rule_id = Column(
4046 'repo_review_rule_id', Integer(), primary_key=True)
4047 repo_id = Column(
4048 "repo_id", Integer(), ForeignKey('repositories.repo_id'))
4049 repo = relationship('Repository', backref='review_rules')
4050
4051 _branch_pattern = Column("branch_pattern", UnicodeText().with_variant(UnicodeText(255), 'mysql'), default=u'*') # glob
4052 _file_pattern = Column("file_pattern", UnicodeText().with_variant(UnicodeText(255), 'mysql'), default=u'*') # glob
4053
4054 use_authors_for_review = Column("use_authors_for_review", Boolean(), nullable=False, default=False)
4055 forbid_author_to_review = Column("forbid_author_to_review", Boolean(), nullable=False, default=False)
4056 forbid_commit_author_to_review = Column("forbid_commit_author_to_review", Boolean(), nullable=False, default=False)
4057 forbid_adding_reviewers = Column("forbid_adding_reviewers", Boolean(), nullable=False, default=False)
4058
4059 rule_users = relationship('RepoReviewRuleUser')
4060 rule_user_groups = relationship('RepoReviewRuleUserGroup')
4061
4062 @hybrid_property
4063 def branch_pattern(self):
4064 return self._branch_pattern or '*'
4065
4066 def _validate_glob(self, value):
4067 re.compile('^' + glob2re(value) + '$')
4068
4069 @branch_pattern.setter
4070 def branch_pattern(self, value):
4071 self._validate_glob(value)
4072 self._branch_pattern = value or '*'
4073
4074 @hybrid_property
4075 def file_pattern(self):
4076 return self._file_pattern or '*'
4077
4078 @file_pattern.setter
4079 def file_pattern(self, value):
4080 self._validate_glob(value)
4081 self._file_pattern = value or '*'
4082
4083 def matches(self, branch, files_changed):
4084 """
4085 Check if this review rule matches a branch/files in a pull request
4086
4087 :param branch: branch name for the commit
4088 :param files_changed: list of file paths changed in the pull request
4089 """
4090
4091 branch = branch or ''
4092 files_changed = files_changed or []
4093
4094 branch_matches = True
4095 if branch:
4096 branch_regex = re.compile('^' + glob2re(self.branch_pattern) + '$')
4097 branch_matches = bool(branch_regex.search(branch))
4098
4099 files_matches = True
4100 if self.file_pattern != '*':
4101 files_matches = False
4102 file_regex = re.compile(glob2re(self.file_pattern))
4103 for filename in files_changed:
4104 if file_regex.search(filename):
4105 files_matches = True
4106 break
4107
4108 return branch_matches and files_matches
4109
4110 @property
4111 def review_users(self):
4112 """ Returns the users which this rule applies to """
4113
4114 users = collections.OrderedDict()
4115
4116 for rule_user in self.rule_users:
4117 if rule_user.user.active:
4118 if rule_user.user not in users:
4119 users[rule_user.user.username] = {
4120 'user': rule_user.user,
4121 'source': 'user',
4122 'source_data': {},
4123 'data': rule_user.rule_data()
4124 }
4125
4126 for rule_user_group in self.rule_user_groups:
4127 source_data = {
4128 'name': rule_user_group.users_group.users_group_name,
4129 'members': len(rule_user_group.users_group.members)
4130 }
4131 for member in rule_user_group.users_group.members:
4132 if member.user.active:
4133 users[member.user.username] = {
4134 'user': member.user,
4135 'source': 'user_group',
4136 'source_data': source_data,
4137 'data': rule_user_group.rule_data()
4138 }
4139
4140 return users
4141
4142 def __repr__(self):
4143 return '<RepoReviewerRule(id=%r, repo=%r)>' % (
4144 self.repo_review_rule_id, self.repo)
4145
4146
4147 class DbMigrateVersion(Base, BaseModel):
4148 __tablename__ = 'db_migrate_version'
4149 __table_args__ = (
4150 {'extend_existing': True, 'mysql_engine': 'InnoDB',
4151 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
4152 )
4153 repository_id = Column('repository_id', String(250), primary_key=True)
4154 repository_path = Column('repository_path', Text)
4155 version = Column('version', Integer)
4156
4157
4158 class DbSession(Base, BaseModel):
4159 __tablename__ = 'db_session'
4160 __table_args__ = (
4161 {'extend_existing': True, 'mysql_engine': 'InnoDB',
4162 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
4163 )
4164
4165 def __repr__(self):
4166 return '<DB:DbSession({})>'.format(self.id)
4167
4168 id = Column('id', Integer())
4169 namespace = Column('namespace', String(255), primary_key=True)
4170 accessed = Column('accessed', DateTime, nullable=False)
4171 created = Column('created', DateTime, nullable=False)
4172 data = Column('data', PickleType, nullable=False)
@@ -0,0 +1,29 b''
1 import logging
2
3 from sqlalchemy import *
4 from rhodecode.model import meta
5 from rhodecode.lib.dbmigrate.versions import _reset_base, notify
6
7 log = logging.getLogger(__name__)
8
9
10 def upgrade(migrate_engine):
11 """
12 Upgrade operations go here.
13 Don't create your own engine; bind migrate_engine to your metadata
14 """
15 _reset_base(migrate_engine)
16 from rhodecode.lib.dbmigrate.schema import db_4_9_0_0 as db
17
18 db.UserSshKeys.__table__.create()
19
20 fixups(db, meta.Session)
21
22
23 def downgrade(migrate_engine):
24 meta = MetaData()
25 meta.bind = migrate_engine
26
27
28 def fixups(models, _SESSION):
29 pass
@@ -0,0 +1,123 b''
1 # -*- coding: utf-8 -*-
2
3 # Copyright (C) 2013-2017 RhodeCode GmbH
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License, version 3
7 # (only), as published by the Free Software Foundation.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 #
17 # This program is dual-licensed. If you wish to learn more about the
18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
21 import logging
22 import traceback
23
24 import sshpubkeys
25 import sshpubkeys.exceptions
26
27 from rhodecode.model import BaseModel
28 from rhodecode.model.db import UserSshKeys
29 from rhodecode.model.meta import Session
30
31 log = logging.getLogger(__name__)
32
33
34 class SshKeyModel(BaseModel):
35 cls = UserSshKeys
36
37 def parse_key(self, key_data):
38 """
39 print(ssh.bits) # 768
40 print(ssh.hash_md5()) # 56:84:1e:90:08:3b:60:c7:29:70:5f:5e:25:a6:3b:86
41 print(ssh.hash_sha256()) # SHA256:xk3IEJIdIoR9MmSRXTP98rjDdZocmXJje/28ohMQEwM
42 print(ssh.hash_sha512()) # SHA512:1C3lNBhjpDVQe39hnyy+xvlZYU3IPwzqK1rVneGavy6O3/ebjEQSFvmeWoyMTplIanmUK1hmr9nA8Skmj516HA
43 print(ssh.comment) # ojar@ojar-laptop
44 print(ssh.options_raw) # None (string of optional options at the beginning of public key)
45 print(ssh.options) # None (options as a dictionary, parsed and validated)
46
47 :param key_data:
48 :return:
49 """
50 ssh = sshpubkeys.SSHKey(strict_mode=True)
51 try:
52 ssh.parse(key_data)
53 return ssh
54 except sshpubkeys.exceptions.InvalidKeyException as err:
55 log.error("Invalid key: %s", err)
56 raise
57 except NotImplementedError as err:
58 log.error("Invalid key type: %s", err)
59 raise
60 except Exception as err:
61 log.error("Key Parse error: %s", err)
62 raise
63
64 def generate_keypair(self, comment=None):
65 from Crypto.PublicKey import RSA
66
67 key = RSA.generate(2048)
68 private = key.exportKey('PEM')
69
70 pubkey = key.publickey()
71 public = pubkey.exportKey('OpenSSH')
72 if comment:
73 public = public + " " + comment
74 return private, public
75
76 def create(self, user, fingerprint, key_data, description):
77 """
78 """
79 user = self._get_user(user)
80
81 new_ssh_key = UserSshKeys()
82 new_ssh_key.ssh_key_fingerprint = fingerprint
83 new_ssh_key.ssh_key_data = key_data
84 new_ssh_key.user_id = user.user_id
85 new_ssh_key.description = description
86
87 Session().add(new_ssh_key)
88
89 return new_ssh_key
90
91 def delete(self, ssh_key_id, user=None):
92 """
93 Deletes given api_key, if user is set it also filters the object for
94 deletion by given user.
95 """
96 ssh_key = UserSshKeys.query().filter(
97 UserSshKeys.ssh_key_id == ssh_key_id)
98
99 if user:
100 user = self._get_user(user)
101 ssh_key = ssh_key.filter(UserSshKeys.user_id == user.user_id)
102 ssh_key = ssh_key.scalar()
103
104 if ssh_key:
105 try:
106 Session().delete(ssh_key)
107 except Exception:
108 log.error(traceback.format_exc())
109 raise
110
111 def get_ssh_keys(self, user):
112 user = self._get_user(user)
113 user_ssh_keys = UserSshKeys.query()\
114 .filter(UserSshKeys.user_id == user.user_id)
115 user_ssh_keys = user_ssh_keys.order_by(UserSshKeys.ssh_key_id)
116 return user_ssh_keys
117
118 def get_ssh_key_by_fingerprint(self, ssh_key_fingerprint):
119 user_ssh_key = UserSshKeys.query()\
120 .filter(UserSshKeys.ssh_key_fingerprint == ssh_key_fingerprint)\
121 .first()
122
123 return user_ssh_key
@@ -0,0 +1,78 b''
1 <div class="panel panel-default">
2 <div class="panel-heading">
3 <h3 class="panel-title">${_('SSH Keys')}</h3>
4 </div>
5 <div class="panel-body">
6 <div class="sshkeys_wrap">
7 <table class="rctable ssh_keys">
8 <tr>
9 <th>${_('Fingerprint')}</th>
10 <th>${_('Description')}</th>
11 <th>${_('Created')}</th>
12 <th>${_('Action')}</th>
13 </tr>
14 %if c.user_ssh_keys:
15 %for ssh_key in c.user_ssh_keys:
16 <tr class="">
17 <td class="">
18 <code>${ssh_key.ssh_key_fingerprint}</code>
19 </td>
20 <td class="td-wrap">${ssh_key.description}</td>
21 <td class="td-tags">${h.format_date(ssh_key.created_on)}</td>
22
23 <td class="td-action">
24 ${h.secure_form(h.route_path('edit_user_ssh_keys_delete', user_id=c.user.user_id), method='POST', request=request)}
25 ${h.hidden('del_ssh_key', ssh_key.ssh_key_id)}
26 <button class="btn btn-link btn-danger" type="submit"
27 onclick="return confirm('${_('Confirm to remove ssh key %s') % ssh_key.ssh_key_fingerprint}');">
28 ${_('Delete')}
29 </button>
30 ${h.end_form()}
31 </td>
32 </tr>
33 %endfor
34 %else:
35 <tr><td><div class="ip">${_('No additional ssh keys specified')}</div></td></tr>
36 %endif
37 </table>
38 </div>
39
40 <div class="user_ssh_keys">
41 ${h.secure_form(h.route_path('edit_user_ssh_keys_add', user_id=c.user.user_id), method='POST', request=request)}
42 <div class="form form-vertical">
43 <!-- fields -->
44 <div class="fields">
45 <div class="field">
46 <div class="label">
47 <label for="new_email">${_('New ssh key')}:</label>
48 </div>
49 <div class="input">
50 ${h.text('description', class_='medium', placeholder=_('Description'))}
51 <a href="${h.route_path('edit_user_ssh_keys_generate_keypair', user_id=c.user.user_id)}">${_('Generate random RSA key')}</a>
52 </div>
53 </div>
54
55 <div class="field">
56 <div class="textarea text-area editor">
57 ${h.textarea('key_data',c.default_key, size=30, placeholder=_("Public key, begins with 'ssh-rsa', 'ssh-dss', 'ssh-ed25519', 'ecdsa-sha2-nistp256', 'ecdsa-sha2-nistp384', or 'ecdsa-sha2-nistp521'"))}
58 </div>
59 </div>
60
61 <div class="buttons">
62 ${h.submit('save',_('Add'),class_="btn")}
63 ${h.reset('reset',_('Reset'),class_="btn")}
64 </div>
65 </div>
66 </div>
67 ${h.end_form()}
68 </div>
69 </div>
70 </div>
71
72 <script>
73
74 $(document).ready(function(){
75
76
77 });
78 </script>
@@ -0,0 +1,45 b''
1 <div class="panel panel-default">
2 <div class="panel-heading">
3 <h3 class="panel-title">${_('New SSH Key generated')}</h3>
4 </div>
5 <div class="panel-body">
6 <p>
7 ${_('Below is a 2048 bit generated SSH RSA key. You can use it to access RhodeCode via the SSH wrapper.')}
8 </p>
9 <h4>${_('Private key')}</h4>
10 <pre>
11 # Save the content as
12 ~/.ssh/id_rsa_rhodecode_access_priv.key
13 # Change permissions
14 chmod 0600 ~/.ssh/id_rsa_rhodecode_access_priv.key
15 </pre>
16
17 <div>
18 <textarea style="height: 300px">${c.private}</textarea>
19 </div>
20 <br/>
21
22
23 <h4>${_('Public key')}</h4>
24 <pre>
25 # Save the content as
26 ~/.ssh/id_rsa_rhodecode_access_pub.key
27 # Change permissions
28 chmod 0600 ~/.ssh/id_rsa_rhodecode_access_pub.key
29 </pre>
30
31 <input type="text" value="${c.public}" class="large text" size="100"/>
32 <p>
33 <a href="${h.route_path('edit_user_ssh_keys', user_id=c.user.user_id, _query=dict(default_key=c.public))}">${_('Add this generated key')}</a>
34 </p>
35
36 </div>
37 </div>
38
39 <script>
40
41 $(document).ready(function(){
42
43
44 });
45 </script>
@@ -1,2086 +1,2086 b''
1 # Generated by pip2nix 0.4.0
1 # Generated by pip2nix 0.4.0
2 # See https://github.com/johbo/pip2nix
2 # See https://github.com/johbo/pip2nix
3
3
4 {
4 {
5 Babel = super.buildPythonPackage {
5 Babel = super.buildPythonPackage {
6 name = "Babel-1.3";
6 name = "Babel-1.3";
7 buildInputs = with self; [];
7 buildInputs = with self; [];
8 doCheck = false;
8 doCheck = false;
9 propagatedBuildInputs = with self; [pytz];
9 propagatedBuildInputs = with self; [pytz];
10 src = fetchurl {
10 src = fetchurl {
11 url = "https://pypi.python.org/packages/33/27/e3978243a03a76398c384c83f7ca879bc6e8f1511233a621fcada135606e/Babel-1.3.tar.gz";
11 url = "https://pypi.python.org/packages/33/27/e3978243a03a76398c384c83f7ca879bc6e8f1511233a621fcada135606e/Babel-1.3.tar.gz";
12 md5 = "5264ceb02717843cbc9ffce8e6e06bdb";
12 md5 = "5264ceb02717843cbc9ffce8e6e06bdb";
13 };
13 };
14 meta = {
14 meta = {
15 license = [ pkgs.lib.licenses.bsdOriginal ];
15 license = [ pkgs.lib.licenses.bsdOriginal ];
16 };
16 };
17 };
17 };
18 Beaker = super.buildPythonPackage {
18 Beaker = super.buildPythonPackage {
19 name = "Beaker-1.9.0";
19 name = "Beaker-1.9.0";
20 buildInputs = with self; [];
20 buildInputs = with self; [];
21 doCheck = false;
21 doCheck = false;
22 propagatedBuildInputs = with self; [funcsigs];
22 propagatedBuildInputs = with self; [funcsigs];
23 src = fetchurl {
23 src = fetchurl {
24 url = "https://pypi.python.org/packages/93/b2/12de6937b06e9615dbb3cb3a1c9af17f133f435bdef59f4ad42032b6eb49/Beaker-1.9.0.tar.gz";
24 url = "https://pypi.python.org/packages/93/b2/12de6937b06e9615dbb3cb3a1c9af17f133f435bdef59f4ad42032b6eb49/Beaker-1.9.0.tar.gz";
25 md5 = "38b3fcdfa24faf97c6cf66991eb54e9c";
25 md5 = "38b3fcdfa24faf97c6cf66991eb54e9c";
26 };
26 };
27 meta = {
27 meta = {
28 license = [ pkgs.lib.licenses.bsdOriginal ];
28 license = [ pkgs.lib.licenses.bsdOriginal ];
29 };
29 };
30 };
30 };
31 CProfileV = super.buildPythonPackage {
31 CProfileV = super.buildPythonPackage {
32 name = "CProfileV-1.0.7";
32 name = "CProfileV-1.0.7";
33 buildInputs = with self; [];
33 buildInputs = with self; [];
34 doCheck = false;
34 doCheck = false;
35 propagatedBuildInputs = with self; [bottle];
35 propagatedBuildInputs = with self; [bottle];
36 src = fetchurl {
36 src = fetchurl {
37 url = "https://pypi.python.org/packages/df/50/d8c1ada7d537c64b0f76453fa31dedb6af6e27b82fcf0331e5f71a4cf98b/CProfileV-1.0.7.tar.gz";
37 url = "https://pypi.python.org/packages/df/50/d8c1ada7d537c64b0f76453fa31dedb6af6e27b82fcf0331e5f71a4cf98b/CProfileV-1.0.7.tar.gz";
38 md5 = "db4c7640438aa3d8887e194c81c7a019";
38 md5 = "db4c7640438aa3d8887e194c81c7a019";
39 };
39 };
40 meta = {
40 meta = {
41 license = [ pkgs.lib.licenses.mit ];
41 license = [ pkgs.lib.licenses.mit ];
42 };
42 };
43 };
43 };
44 Chameleon = super.buildPythonPackage {
44 Chameleon = super.buildPythonPackage {
45 name = "Chameleon-2.24";
45 name = "Chameleon-2.24";
46 buildInputs = with self; [];
46 buildInputs = with self; [];
47 doCheck = false;
47 doCheck = false;
48 propagatedBuildInputs = with self; [];
48 propagatedBuildInputs = with self; [];
49 src = fetchurl {
49 src = fetchurl {
50 url = "https://pypi.python.org/packages/5a/9e/637379ffa13c5172b5c0e704833ffea6bf51cec7567f93fd6e903d53ed74/Chameleon-2.24.tar.gz";
50 url = "https://pypi.python.org/packages/5a/9e/637379ffa13c5172b5c0e704833ffea6bf51cec7567f93fd6e903d53ed74/Chameleon-2.24.tar.gz";
51 md5 = "1b01f1f6533a8a11d0d2f2366dec5342";
51 md5 = "1b01f1f6533a8a11d0d2f2366dec5342";
52 };
52 };
53 meta = {
53 meta = {
54 license = [ { fullName = "BSD-like (http://repoze.org/license.html)"; } ];
54 license = [ { fullName = "BSD-like (http://repoze.org/license.html)"; } ];
55 };
55 };
56 };
56 };
57 FormEncode = super.buildPythonPackage {
57 FormEncode = super.buildPythonPackage {
58 name = "FormEncode-1.2.4";
58 name = "FormEncode-1.2.4";
59 buildInputs = with self; [];
59 buildInputs = with self; [];
60 doCheck = false;
60 doCheck = false;
61 propagatedBuildInputs = with self; [];
61 propagatedBuildInputs = with self; [];
62 src = fetchurl {
62 src = fetchurl {
63 url = "https://pypi.python.org/packages/8e/59/0174271a6f004512e0201188593e6d319db139d14cb7490e488bbb078015/FormEncode-1.2.4.tar.gz";
63 url = "https://pypi.python.org/packages/8e/59/0174271a6f004512e0201188593e6d319db139d14cb7490e488bbb078015/FormEncode-1.2.4.tar.gz";
64 md5 = "6bc17fb9aed8aea198975e888e2077f4";
64 md5 = "6bc17fb9aed8aea198975e888e2077f4";
65 };
65 };
66 meta = {
66 meta = {
67 license = [ pkgs.lib.licenses.psfl ];
67 license = [ pkgs.lib.licenses.psfl ];
68 };
68 };
69 };
69 };
70 Jinja2 = super.buildPythonPackage {
70 Jinja2 = super.buildPythonPackage {
71 name = "Jinja2-2.7.3";
71 name = "Jinja2-2.7.3";
72 buildInputs = with self; [];
72 buildInputs = with self; [];
73 doCheck = false;
73 doCheck = false;
74 propagatedBuildInputs = with self; [MarkupSafe];
74 propagatedBuildInputs = with self; [MarkupSafe];
75 src = fetchurl {
75 src = fetchurl {
76 url = "https://pypi.python.org/packages/b0/73/eab0bca302d6d6a0b5c402f47ad1760dc9cb2dd14bbc1873ad48db258e4d/Jinja2-2.7.3.tar.gz";
76 url = "https://pypi.python.org/packages/b0/73/eab0bca302d6d6a0b5c402f47ad1760dc9cb2dd14bbc1873ad48db258e4d/Jinja2-2.7.3.tar.gz";
77 md5 = "b9dffd2f3b43d673802fe857c8445b1a";
77 md5 = "b9dffd2f3b43d673802fe857c8445b1a";
78 };
78 };
79 meta = {
79 meta = {
80 license = [ pkgs.lib.licenses.bsdOriginal ];
80 license = [ pkgs.lib.licenses.bsdOriginal ];
81 };
81 };
82 };
82 };
83 Mako = super.buildPythonPackage {
83 Mako = super.buildPythonPackage {
84 name = "Mako-1.0.6";
84 name = "Mako-1.0.6";
85 buildInputs = with self; [];
85 buildInputs = with self; [];
86 doCheck = false;
86 doCheck = false;
87 propagatedBuildInputs = with self; [MarkupSafe];
87 propagatedBuildInputs = with self; [MarkupSafe];
88 src = fetchurl {
88 src = fetchurl {
89 url = "https://pypi.python.org/packages/56/4b/cb75836863a6382199aefb3d3809937e21fa4cb0db15a4f4ba0ecc2e7e8e/Mako-1.0.6.tar.gz";
89 url = "https://pypi.python.org/packages/56/4b/cb75836863a6382199aefb3d3809937e21fa4cb0db15a4f4ba0ecc2e7e8e/Mako-1.0.6.tar.gz";
90 md5 = "a28e22a339080316b2acc352b9ee631c";
90 md5 = "a28e22a339080316b2acc352b9ee631c";
91 };
91 };
92 meta = {
92 meta = {
93 license = [ pkgs.lib.licenses.mit ];
93 license = [ pkgs.lib.licenses.mit ];
94 };
94 };
95 };
95 };
96 Markdown = super.buildPythonPackage {
96 Markdown = super.buildPythonPackage {
97 name = "Markdown-2.6.8";
97 name = "Markdown-2.6.8";
98 buildInputs = with self; [];
98 buildInputs = with self; [];
99 doCheck = false;
99 doCheck = false;
100 propagatedBuildInputs = with self; [];
100 propagatedBuildInputs = with self; [];
101 src = fetchurl {
101 src = fetchurl {
102 url = "https://pypi.python.org/packages/1d/25/3f6d2cb31ec42ca5bd3bfbea99b63892b735d76e26f20dd2dcc34ffe4f0d/Markdown-2.6.8.tar.gz";
102 url = "https://pypi.python.org/packages/1d/25/3f6d2cb31ec42ca5bd3bfbea99b63892b735d76e26f20dd2dcc34ffe4f0d/Markdown-2.6.8.tar.gz";
103 md5 = "d9ef057a5bd185f6f536400a31fc5d45";
103 md5 = "d9ef057a5bd185f6f536400a31fc5d45";
104 };
104 };
105 meta = {
105 meta = {
106 license = [ pkgs.lib.licenses.bsdOriginal ];
106 license = [ pkgs.lib.licenses.bsdOriginal ];
107 };
107 };
108 };
108 };
109 MarkupSafe = super.buildPythonPackage {
109 MarkupSafe = super.buildPythonPackage {
110 name = "MarkupSafe-0.23";
110 name = "MarkupSafe-0.23";
111 buildInputs = with self; [];
111 buildInputs = with self; [];
112 doCheck = false;
112 doCheck = false;
113 propagatedBuildInputs = with self; [];
113 propagatedBuildInputs = with self; [];
114 src = fetchurl {
114 src = fetchurl {
115 url = "https://pypi.python.org/packages/c0/41/bae1254e0396c0cc8cf1751cb7d9afc90a602353695af5952530482c963f/MarkupSafe-0.23.tar.gz";
115 url = "https://pypi.python.org/packages/c0/41/bae1254e0396c0cc8cf1751cb7d9afc90a602353695af5952530482c963f/MarkupSafe-0.23.tar.gz";
116 md5 = "f5ab3deee4c37cd6a922fb81e730da6e";
116 md5 = "f5ab3deee4c37cd6a922fb81e730da6e";
117 };
117 };
118 meta = {
118 meta = {
119 license = [ pkgs.lib.licenses.bsdOriginal ];
119 license = [ pkgs.lib.licenses.bsdOriginal ];
120 };
120 };
121 };
121 };
122 MySQL-python = super.buildPythonPackage {
122 MySQL-python = super.buildPythonPackage {
123 name = "MySQL-python-1.2.5";
123 name = "MySQL-python-1.2.5";
124 buildInputs = with self; [];
124 buildInputs = with self; [];
125 doCheck = false;
125 doCheck = false;
126 propagatedBuildInputs = with self; [];
126 propagatedBuildInputs = with self; [];
127 src = fetchurl {
127 src = fetchurl {
128 url = "https://pypi.python.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip";
128 url = "https://pypi.python.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip";
129 md5 = "654f75b302db6ed8dc5a898c625e030c";
129 md5 = "654f75b302db6ed8dc5a898c625e030c";
130 };
130 };
131 meta = {
131 meta = {
132 license = [ pkgs.lib.licenses.gpl1 ];
132 license = [ pkgs.lib.licenses.gpl1 ];
133 };
133 };
134 };
134 };
135 Paste = super.buildPythonPackage {
135 Paste = super.buildPythonPackage {
136 name = "Paste-2.0.3";
136 name = "Paste-2.0.3";
137 buildInputs = with self; [];
137 buildInputs = with self; [];
138 doCheck = false;
138 doCheck = false;
139 propagatedBuildInputs = with self; [six];
139 propagatedBuildInputs = with self; [six];
140 src = fetchurl {
140 src = fetchurl {
141 url = "https://pypi.python.org/packages/30/c3/5c2f7c7a02e4f58d4454353fa1c32c94f79fa4e36d07a67c0ac295ea369e/Paste-2.0.3.tar.gz";
141 url = "https://pypi.python.org/packages/30/c3/5c2f7c7a02e4f58d4454353fa1c32c94f79fa4e36d07a67c0ac295ea369e/Paste-2.0.3.tar.gz";
142 md5 = "1231e14eae62fa7ed76e9130b04bc61e";
142 md5 = "1231e14eae62fa7ed76e9130b04bc61e";
143 };
143 };
144 meta = {
144 meta = {
145 license = [ pkgs.lib.licenses.mit ];
145 license = [ pkgs.lib.licenses.mit ];
146 };
146 };
147 };
147 };
148 PasteDeploy = super.buildPythonPackage {
148 PasteDeploy = super.buildPythonPackage {
149 name = "PasteDeploy-1.5.2";
149 name = "PasteDeploy-1.5.2";
150 buildInputs = with self; [];
150 buildInputs = with self; [];
151 doCheck = false;
151 doCheck = false;
152 propagatedBuildInputs = with self; [];
152 propagatedBuildInputs = with self; [];
153 src = fetchurl {
153 src = fetchurl {
154 url = "https://pypi.python.org/packages/0f/90/8e20cdae206c543ea10793cbf4136eb9a8b3f417e04e40a29d72d9922cbd/PasteDeploy-1.5.2.tar.gz";
154 url = "https://pypi.python.org/packages/0f/90/8e20cdae206c543ea10793cbf4136eb9a8b3f417e04e40a29d72d9922cbd/PasteDeploy-1.5.2.tar.gz";
155 md5 = "352b7205c78c8de4987578d19431af3b";
155 md5 = "352b7205c78c8de4987578d19431af3b";
156 };
156 };
157 meta = {
157 meta = {
158 license = [ pkgs.lib.licenses.mit ];
158 license = [ pkgs.lib.licenses.mit ];
159 };
159 };
160 };
160 };
161 PasteScript = super.buildPythonPackage {
161 PasteScript = super.buildPythonPackage {
162 name = "PasteScript-1.7.5";
162 name = "PasteScript-1.7.5";
163 buildInputs = with self; [];
163 buildInputs = with self; [];
164 doCheck = false;
164 doCheck = false;
165 propagatedBuildInputs = with self; [Paste PasteDeploy];
165 propagatedBuildInputs = with self; [Paste PasteDeploy];
166 src = fetchurl {
166 src = fetchurl {
167 url = "https://pypi.python.org/packages/a5/05/fc60efa7c2f17a1dbaeccb2a903a1e90902d92b9d00eebabe3095829d806/PasteScript-1.7.5.tar.gz";
167 url = "https://pypi.python.org/packages/a5/05/fc60efa7c2f17a1dbaeccb2a903a1e90902d92b9d00eebabe3095829d806/PasteScript-1.7.5.tar.gz";
168 md5 = "4c72d78dcb6bb993f30536842c16af4d";
168 md5 = "4c72d78dcb6bb993f30536842c16af4d";
169 };
169 };
170 meta = {
170 meta = {
171 license = [ pkgs.lib.licenses.mit ];
171 license = [ pkgs.lib.licenses.mit ];
172 };
172 };
173 };
173 };
174 Pygments = super.buildPythonPackage {
174 Pygments = super.buildPythonPackage {
175 name = "Pygments-2.2.0";
175 name = "Pygments-2.2.0";
176 buildInputs = with self; [];
176 buildInputs = with self; [];
177 doCheck = false;
177 doCheck = false;
178 propagatedBuildInputs = with self; [];
178 propagatedBuildInputs = with self; [];
179 src = fetchurl {
179 src = fetchurl {
180 url = "https://pypi.python.org/packages/71/2a/2e4e77803a8bd6408a2903340ac498cb0a2181811af7c9ec92cb70b0308a/Pygments-2.2.0.tar.gz";
180 url = "https://pypi.python.org/packages/71/2a/2e4e77803a8bd6408a2903340ac498cb0a2181811af7c9ec92cb70b0308a/Pygments-2.2.0.tar.gz";
181 md5 = "13037baca42f16917cbd5ad2fab50844";
181 md5 = "13037baca42f16917cbd5ad2fab50844";
182 };
182 };
183 meta = {
183 meta = {
184 license = [ pkgs.lib.licenses.bsdOriginal ];
184 license = [ pkgs.lib.licenses.bsdOriginal ];
185 };
185 };
186 };
186 };
187 Pylons = super.buildPythonPackage {
187 Pylons = super.buildPythonPackage {
188 name = "Pylons-1.0.2.dev20170630";
188 name = "Pylons-1.0.2.dev20170630";
189 buildInputs = with self; [];
189 buildInputs = with self; [];
190 doCheck = false;
190 doCheck = false;
191 propagatedBuildInputs = with self; [Routes WebHelpers Beaker Paste PasteDeploy PasteScript FormEncode simplejson decorator nose Mako WebError WebTest Tempita MarkupSafe WebOb];
191 propagatedBuildInputs = with self; [Routes WebHelpers Beaker Paste PasteDeploy PasteScript FormEncode simplejson decorator nose Mako WebError WebTest Tempita MarkupSafe WebOb];
192 src = fetchurl {
192 src = fetchurl {
193 url = "https://code.rhodecode.com/upstream/pylons/archive/707354ee4261b9c10450404fc9852ccea4fd667d.tar.gz?md5=f26633726fa2cd3a340316ee6a5d218f";
193 url = "https://code.rhodecode.com/upstream/pylons/archive/707354ee4261b9c10450404fc9852ccea4fd667d.tar.gz?md5=f26633726fa2cd3a340316ee6a5d218f";
194 md5 = "f26633726fa2cd3a340316ee6a5d218f";
194 md5 = "f26633726fa2cd3a340316ee6a5d218f";
195 };
195 };
196 meta = {
196 meta = {
197 license = [ pkgs.lib.licenses.bsdOriginal ];
197 license = [ pkgs.lib.licenses.bsdOriginal ];
198 };
198 };
199 };
199 };
200 Routes = super.buildPythonPackage {
200 Routes = super.buildPythonPackage {
201 name = "Routes-1.13";
201 name = "Routes-1.13";
202 buildInputs = with self; [];
202 buildInputs = with self; [];
203 doCheck = false;
203 doCheck = false;
204 propagatedBuildInputs = with self; [repoze.lru];
204 propagatedBuildInputs = with self; [repoze.lru];
205 src = fetchurl {
205 src = fetchurl {
206 url = "https://pypi.python.org/packages/88/d3/259c3b3cde8837eb9441ab5f574a660e8a4acea8f54a078441d4d2acac1c/Routes-1.13.tar.gz";
206 url = "https://pypi.python.org/packages/88/d3/259c3b3cde8837eb9441ab5f574a660e8a4acea8f54a078441d4d2acac1c/Routes-1.13.tar.gz";
207 md5 = "d527b0ab7dd9172b1275a41f97448783";
207 md5 = "d527b0ab7dd9172b1275a41f97448783";
208 };
208 };
209 meta = {
209 meta = {
210 license = [ pkgs.lib.licenses.bsdOriginal ];
210 license = [ pkgs.lib.licenses.bsdOriginal ];
211 };
211 };
212 };
212 };
213 SQLAlchemy = super.buildPythonPackage {
213 SQLAlchemy = super.buildPythonPackage {
214 name = "SQLAlchemy-1.1.11";
214 name = "SQLAlchemy-1.1.11";
215 buildInputs = with self; [];
215 buildInputs = with self; [];
216 doCheck = false;
216 doCheck = false;
217 propagatedBuildInputs = with self; [];
217 propagatedBuildInputs = with self; [];
218 src = fetchurl {
218 src = fetchurl {
219 url = "https://pypi.python.org/packages/59/f1/28f2205c3175e6bf32300c0f30f9d91dbc9eb910debbff3ffecb88d18528/SQLAlchemy-1.1.11.tar.gz";
219 url = "https://pypi.python.org/packages/59/f1/28f2205c3175e6bf32300c0f30f9d91dbc9eb910debbff3ffecb88d18528/SQLAlchemy-1.1.11.tar.gz";
220 md5 = "3de387eddb4012083a4562928c511e43";
220 md5 = "3de387eddb4012083a4562928c511e43";
221 };
221 };
222 meta = {
222 meta = {
223 license = [ pkgs.lib.licenses.mit ];
223 license = [ pkgs.lib.licenses.mit ];
224 };
224 };
225 };
225 };
226 Sphinx = super.buildPythonPackage {
226 Sphinx = super.buildPythonPackage {
227 name = "Sphinx-1.2.2";
227 name = "Sphinx-1.2.2";
228 buildInputs = with self; [];
228 buildInputs = with self; [];
229 doCheck = false;
229 doCheck = false;
230 propagatedBuildInputs = with self; [Pygments docutils Jinja2];
230 propagatedBuildInputs = with self; [Pygments docutils Jinja2];
231 src = fetchurl {
231 src = fetchurl {
232 url = "https://pypi.python.org/packages/0a/50/34017e6efcd372893a416aba14b84a1a149fc7074537b0e9cb6ca7b7abe9/Sphinx-1.2.2.tar.gz";
232 url = "https://pypi.python.org/packages/0a/50/34017e6efcd372893a416aba14b84a1a149fc7074537b0e9cb6ca7b7abe9/Sphinx-1.2.2.tar.gz";
233 md5 = "3dc73ccaa8d0bfb2d62fb671b1f7e8a4";
233 md5 = "3dc73ccaa8d0bfb2d62fb671b1f7e8a4";
234 };
234 };
235 meta = {
235 meta = {
236 license = [ pkgs.lib.licenses.bsdOriginal ];
236 license = [ pkgs.lib.licenses.bsdOriginal ];
237 };
237 };
238 };
238 };
239 Tempita = super.buildPythonPackage {
239 Tempita = super.buildPythonPackage {
240 name = "Tempita-0.5.2";
240 name = "Tempita-0.5.2";
241 buildInputs = with self; [];
241 buildInputs = with self; [];
242 doCheck = false;
242 doCheck = false;
243 propagatedBuildInputs = with self; [];
243 propagatedBuildInputs = with self; [];
244 src = fetchurl {
244 src = fetchurl {
245 url = "https://pypi.python.org/packages/56/c8/8ed6eee83dbddf7b0fc64dd5d4454bc05e6ccaafff47991f73f2894d9ff4/Tempita-0.5.2.tar.gz";
245 url = "https://pypi.python.org/packages/56/c8/8ed6eee83dbddf7b0fc64dd5d4454bc05e6ccaafff47991f73f2894d9ff4/Tempita-0.5.2.tar.gz";
246 md5 = "4c2f17bb9d481821c41b6fbee904cea1";
246 md5 = "4c2f17bb9d481821c41b6fbee904cea1";
247 };
247 };
248 meta = {
248 meta = {
249 license = [ pkgs.lib.licenses.mit ];
249 license = [ pkgs.lib.licenses.mit ];
250 };
250 };
251 };
251 };
252 URLObject = super.buildPythonPackage {
252 URLObject = super.buildPythonPackage {
253 name = "URLObject-2.4.0";
253 name = "URLObject-2.4.0";
254 buildInputs = with self; [];
254 buildInputs = with self; [];
255 doCheck = false;
255 doCheck = false;
256 propagatedBuildInputs = with self; [];
256 propagatedBuildInputs = with self; [];
257 src = fetchurl {
257 src = fetchurl {
258 url = "https://pypi.python.org/packages/cb/b6/e25e58500f9caef85d664bec71ec67c116897bfebf8622c32cb75d1ca199/URLObject-2.4.0.tar.gz";
258 url = "https://pypi.python.org/packages/cb/b6/e25e58500f9caef85d664bec71ec67c116897bfebf8622c32cb75d1ca199/URLObject-2.4.0.tar.gz";
259 md5 = "2ed819738a9f0a3051f31dc9924e3065";
259 md5 = "2ed819738a9f0a3051f31dc9924e3065";
260 };
260 };
261 meta = {
261 meta = {
262 license = [ ];
262 license = [ ];
263 };
263 };
264 };
264 };
265 WebError = super.buildPythonPackage {
265 WebError = super.buildPythonPackage {
266 name = "WebError-0.10.3";
266 name = "WebError-0.10.3";
267 buildInputs = with self; [];
267 buildInputs = with self; [];
268 doCheck = false;
268 doCheck = false;
269 propagatedBuildInputs = with self; [WebOb Tempita Pygments Paste];
269 propagatedBuildInputs = with self; [WebOb Tempita Pygments Paste];
270 src = fetchurl {
270 src = fetchurl {
271 url = "https://pypi.python.org/packages/35/76/e7e5c2ce7e9c7f31b54c1ff295a495886d1279a002557d74dd8957346a79/WebError-0.10.3.tar.gz";
271 url = "https://pypi.python.org/packages/35/76/e7e5c2ce7e9c7f31b54c1ff295a495886d1279a002557d74dd8957346a79/WebError-0.10.3.tar.gz";
272 md5 = "84b9990b0baae6fd440b1e60cdd06f9a";
272 md5 = "84b9990b0baae6fd440b1e60cdd06f9a";
273 };
273 };
274 meta = {
274 meta = {
275 license = [ pkgs.lib.licenses.mit ];
275 license = [ pkgs.lib.licenses.mit ];
276 };
276 };
277 };
277 };
278 WebHelpers = super.buildPythonPackage {
278 WebHelpers = super.buildPythonPackage {
279 name = "WebHelpers-1.3";
279 name = "WebHelpers-1.3";
280 buildInputs = with self; [];
280 buildInputs = with self; [];
281 doCheck = false;
281 doCheck = false;
282 propagatedBuildInputs = with self; [MarkupSafe];
282 propagatedBuildInputs = with self; [MarkupSafe];
283 src = fetchurl {
283 src = fetchurl {
284 url = "https://pypi.python.org/packages/ee/68/4d07672821d514184357f1552f2dad923324f597e722de3b016ca4f7844f/WebHelpers-1.3.tar.gz";
284 url = "https://pypi.python.org/packages/ee/68/4d07672821d514184357f1552f2dad923324f597e722de3b016ca4f7844f/WebHelpers-1.3.tar.gz";
285 md5 = "32749ffadfc40fea51075a7def32588b";
285 md5 = "32749ffadfc40fea51075a7def32588b";
286 };
286 };
287 meta = {
287 meta = {
288 license = [ pkgs.lib.licenses.bsdOriginal ];
288 license = [ pkgs.lib.licenses.bsdOriginal ];
289 };
289 };
290 };
290 };
291 WebHelpers2 = super.buildPythonPackage {
291 WebHelpers2 = super.buildPythonPackage {
292 name = "WebHelpers2-2.0";
292 name = "WebHelpers2-2.0";
293 buildInputs = with self; [];
293 buildInputs = with self; [];
294 doCheck = false;
294 doCheck = false;
295 propagatedBuildInputs = with self; [MarkupSafe six];
295 propagatedBuildInputs = with self; [MarkupSafe six];
296 src = fetchurl {
296 src = fetchurl {
297 url = "https://pypi.python.org/packages/ff/30/56342c6ea522439e3662427c8d7b5e5b390dff4ff2dc92d8afcb8ab68b75/WebHelpers2-2.0.tar.gz";
297 url = "https://pypi.python.org/packages/ff/30/56342c6ea522439e3662427c8d7b5e5b390dff4ff2dc92d8afcb8ab68b75/WebHelpers2-2.0.tar.gz";
298 md5 = "0f6b68d70c12ee0aed48c00b24da13d3";
298 md5 = "0f6b68d70c12ee0aed48c00b24da13d3";
299 };
299 };
300 meta = {
300 meta = {
301 license = [ pkgs.lib.licenses.mit ];
301 license = [ pkgs.lib.licenses.mit ];
302 };
302 };
303 };
303 };
304 WebOb = super.buildPythonPackage {
304 WebOb = super.buildPythonPackage {
305 name = "WebOb-1.7.3";
305 name = "WebOb-1.7.3";
306 buildInputs = with self; [];
306 buildInputs = with self; [];
307 doCheck = false;
307 doCheck = false;
308 propagatedBuildInputs = with self; [];
308 propagatedBuildInputs = with self; [];
309 src = fetchurl {
309 src = fetchurl {
310 url = "https://pypi.python.org/packages/46/87/2f96d8d43b2078fae6e1d33fa86b95c228cebed060f4e3c7576cc44ea83b/WebOb-1.7.3.tar.gz";
310 url = "https://pypi.python.org/packages/46/87/2f96d8d43b2078fae6e1d33fa86b95c228cebed060f4e3c7576cc44ea83b/WebOb-1.7.3.tar.gz";
311 md5 = "350028baffc508e3d23c078118e35316";
311 md5 = "350028baffc508e3d23c078118e35316";
312 };
312 };
313 meta = {
313 meta = {
314 license = [ pkgs.lib.licenses.mit ];
314 license = [ pkgs.lib.licenses.mit ];
315 };
315 };
316 };
316 };
317 WebTest = super.buildPythonPackage {
317 WebTest = super.buildPythonPackage {
318 name = "WebTest-2.0.27";
318 name = "WebTest-2.0.27";
319 buildInputs = with self; [];
319 buildInputs = with self; [];
320 doCheck = false;
320 doCheck = false;
321 propagatedBuildInputs = with self; [six WebOb waitress beautifulsoup4];
321 propagatedBuildInputs = with self; [six WebOb waitress beautifulsoup4];
322 src = fetchurl {
322 src = fetchurl {
323 url = "https://pypi.python.org/packages/80/fa/ca3a759985c72e3a124cbca3e1f8a2e931a07ffd31fd45d8f7bf21cb95cf/WebTest-2.0.27.tar.gz";
323 url = "https://pypi.python.org/packages/80/fa/ca3a759985c72e3a124cbca3e1f8a2e931a07ffd31fd45d8f7bf21cb95cf/WebTest-2.0.27.tar.gz";
324 md5 = "54e6515ac71c51b6fc90179483c749ad";
324 md5 = "54e6515ac71c51b6fc90179483c749ad";
325 };
325 };
326 meta = {
326 meta = {
327 license = [ pkgs.lib.licenses.mit ];
327 license = [ pkgs.lib.licenses.mit ];
328 };
328 };
329 };
329 };
330 Whoosh = super.buildPythonPackage {
330 Whoosh = super.buildPythonPackage {
331 name = "Whoosh-2.7.4";
331 name = "Whoosh-2.7.4";
332 buildInputs = with self; [];
332 buildInputs = with self; [];
333 doCheck = false;
333 doCheck = false;
334 propagatedBuildInputs = with self; [];
334 propagatedBuildInputs = with self; [];
335 src = fetchurl {
335 src = fetchurl {
336 url = "https://pypi.python.org/packages/25/2b/6beed2107b148edc1321da0d489afc4617b9ed317ef7b72d4993cad9b684/Whoosh-2.7.4.tar.gz";
336 url = "https://pypi.python.org/packages/25/2b/6beed2107b148edc1321da0d489afc4617b9ed317ef7b72d4993cad9b684/Whoosh-2.7.4.tar.gz";
337 md5 = "c2710105f20b3e29936bd2357383c325";
337 md5 = "c2710105f20b3e29936bd2357383c325";
338 };
338 };
339 meta = {
339 meta = {
340 license = [ pkgs.lib.licenses.bsdOriginal pkgs.lib.licenses.bsd2 ];
340 license = [ pkgs.lib.licenses.bsdOriginal pkgs.lib.licenses.bsd2 ];
341 };
341 };
342 };
342 };
343 alembic = super.buildPythonPackage {
343 alembic = super.buildPythonPackage {
344 name = "alembic-0.9.2";
344 name = "alembic-0.9.2";
345 buildInputs = with self; [];
345 buildInputs = with self; [];
346 doCheck = false;
346 doCheck = false;
347 propagatedBuildInputs = with self; [SQLAlchemy Mako python-editor python-dateutil];
347 propagatedBuildInputs = with self; [SQLAlchemy Mako python-editor python-dateutil];
348 src = fetchurl {
348 src = fetchurl {
349 url = "https://pypi.python.org/packages/78/48/b5b26e7218b415f40b60b92c53853d242e5456c0f19f6c66101d98ff5f2a/alembic-0.9.2.tar.gz";
349 url = "https://pypi.python.org/packages/78/48/b5b26e7218b415f40b60b92c53853d242e5456c0f19f6c66101d98ff5f2a/alembic-0.9.2.tar.gz";
350 md5 = "40daf8bae50969beea40efaaf0839ff4";
350 md5 = "40daf8bae50969beea40efaaf0839ff4";
351 };
351 };
352 meta = {
352 meta = {
353 license = [ pkgs.lib.licenses.mit ];
353 license = [ pkgs.lib.licenses.mit ];
354 };
354 };
355 };
355 };
356 amqplib = super.buildPythonPackage {
356 amqplib = super.buildPythonPackage {
357 name = "amqplib-1.0.2";
357 name = "amqplib-1.0.2";
358 buildInputs = with self; [];
358 buildInputs = with self; [];
359 doCheck = false;
359 doCheck = false;
360 propagatedBuildInputs = with self; [];
360 propagatedBuildInputs = with self; [];
361 src = fetchurl {
361 src = fetchurl {
362 url = "https://pypi.python.org/packages/75/b7/8c2429bf8d92354a0118614f9a4d15e53bc69ebedce534284111de5a0102/amqplib-1.0.2.tgz";
362 url = "https://pypi.python.org/packages/75/b7/8c2429bf8d92354a0118614f9a4d15e53bc69ebedce534284111de5a0102/amqplib-1.0.2.tgz";
363 md5 = "5c92f17fbedd99b2b4a836d4352d1e2f";
363 md5 = "5c92f17fbedd99b2b4a836d4352d1e2f";
364 };
364 };
365 meta = {
365 meta = {
366 license = [ { fullName = "LGPL"; } { fullName = "GNU Library or Lesser General Public License (LGPL)"; } ];
366 license = [ { fullName = "LGPL"; } { fullName = "GNU Library or Lesser General Public License (LGPL)"; } ];
367 };
367 };
368 };
368 };
369 anyjson = super.buildPythonPackage {
369 anyjson = super.buildPythonPackage {
370 name = "anyjson-0.3.3";
370 name = "anyjson-0.3.3";
371 buildInputs = with self; [];
371 buildInputs = with self; [];
372 doCheck = false;
372 doCheck = false;
373 propagatedBuildInputs = with self; [];
373 propagatedBuildInputs = with self; [];
374 src = fetchurl {
374 src = fetchurl {
375 url = "https://pypi.python.org/packages/c3/4d/d4089e1a3dd25b46bebdb55a992b0797cff657b4477bc32ce28038fdecbc/anyjson-0.3.3.tar.gz";
375 url = "https://pypi.python.org/packages/c3/4d/d4089e1a3dd25b46bebdb55a992b0797cff657b4477bc32ce28038fdecbc/anyjson-0.3.3.tar.gz";
376 md5 = "2ea28d6ec311aeeebaf993cb3008b27c";
376 md5 = "2ea28d6ec311aeeebaf993cb3008b27c";
377 };
377 };
378 meta = {
378 meta = {
379 license = [ pkgs.lib.licenses.bsdOriginal ];
379 license = [ pkgs.lib.licenses.bsdOriginal ];
380 };
380 };
381 };
381 };
382 appenlight-client = super.buildPythonPackage {
382 appenlight-client = super.buildPythonPackage {
383 name = "appenlight-client-0.6.21";
383 name = "appenlight-client-0.6.21";
384 buildInputs = with self; [];
384 buildInputs = with self; [];
385 doCheck = false;
385 doCheck = false;
386 propagatedBuildInputs = with self; [WebOb requests six];
386 propagatedBuildInputs = with self; [WebOb requests six];
387 src = fetchurl {
387 src = fetchurl {
388 url = "https://pypi.python.org/packages/c9/23/91b66cfa0b963662c10b2a06ccaadf3f3a4848a7a2aa16255cb43d5160ec/appenlight_client-0.6.21.tar.gz";
388 url = "https://pypi.python.org/packages/c9/23/91b66cfa0b963662c10b2a06ccaadf3f3a4848a7a2aa16255cb43d5160ec/appenlight_client-0.6.21.tar.gz";
389 md5 = "273999ac854fdaefa8d0fb61965a4ed9";
389 md5 = "273999ac854fdaefa8d0fb61965a4ed9";
390 };
390 };
391 meta = {
391 meta = {
392 license = [ pkgs.lib.licenses.bsdOriginal ];
392 license = [ pkgs.lib.licenses.bsdOriginal ];
393 };
393 };
394 };
394 };
395 authomatic = super.buildPythonPackage {
395 authomatic = super.buildPythonPackage {
396 name = "authomatic-0.1.0.post1";
396 name = "authomatic-0.1.0.post1";
397 buildInputs = with self; [];
397 buildInputs = with self; [];
398 doCheck = false;
398 doCheck = false;
399 propagatedBuildInputs = with self; [];
399 propagatedBuildInputs = with self; [];
400 src = fetchurl {
400 src = fetchurl {
401 url = "https://pypi.python.org/packages/08/1a/8a930461e604c2d5a7a871e1ac59fa82ccf994c32e807230c8d2fb07815a/Authomatic-0.1.0.post1.tar.gz";
401 url = "https://pypi.python.org/packages/08/1a/8a930461e604c2d5a7a871e1ac59fa82ccf994c32e807230c8d2fb07815a/Authomatic-0.1.0.post1.tar.gz";
402 md5 = "be3f3ce08747d776aae6d6cc8dcb49a9";
402 md5 = "be3f3ce08747d776aae6d6cc8dcb49a9";
403 };
403 };
404 meta = {
404 meta = {
405 license = [ pkgs.lib.licenses.mit ];
405 license = [ pkgs.lib.licenses.mit ];
406 };
406 };
407 };
407 };
408 backports.shutil-get-terminal-size = super.buildPythonPackage {
408 backports.shutil-get-terminal-size = super.buildPythonPackage {
409 name = "backports.shutil-get-terminal-size-1.0.0";
409 name = "backports.shutil-get-terminal-size-1.0.0";
410 buildInputs = with self; [];
410 buildInputs = with self; [];
411 doCheck = false;
411 doCheck = false;
412 propagatedBuildInputs = with self; [];
412 propagatedBuildInputs = with self; [];
413 src = fetchurl {
413 src = fetchurl {
414 url = "https://pypi.python.org/packages/ec/9c/368086faa9c016efce5da3e0e13ba392c9db79e3ab740b763fe28620b18b/backports.shutil_get_terminal_size-1.0.0.tar.gz";
414 url = "https://pypi.python.org/packages/ec/9c/368086faa9c016efce5da3e0e13ba392c9db79e3ab740b763fe28620b18b/backports.shutil_get_terminal_size-1.0.0.tar.gz";
415 md5 = "03267762480bd86b50580dc19dff3c66";
415 md5 = "03267762480bd86b50580dc19dff3c66";
416 };
416 };
417 meta = {
417 meta = {
418 license = [ pkgs.lib.licenses.mit ];
418 license = [ pkgs.lib.licenses.mit ];
419 };
419 };
420 };
420 };
421 beautifulsoup4 = super.buildPythonPackage {
421 beautifulsoup4 = super.buildPythonPackage {
422 name = "beautifulsoup4-4.6.0";
422 name = "beautifulsoup4-4.6.0";
423 buildInputs = with self; [];
423 buildInputs = with self; [];
424 doCheck = false;
424 doCheck = false;
425 propagatedBuildInputs = with self; [];
425 propagatedBuildInputs = with self; [];
426 src = fetchurl {
426 src = fetchurl {
427 url = "https://pypi.python.org/packages/fa/8d/1d14391fdaed5abada4e0f63543fef49b8331a34ca60c88bd521bcf7f782/beautifulsoup4-4.6.0.tar.gz";
427 url = "https://pypi.python.org/packages/fa/8d/1d14391fdaed5abada4e0f63543fef49b8331a34ca60c88bd521bcf7f782/beautifulsoup4-4.6.0.tar.gz";
428 md5 = "c17714d0f91a23b708a592cb3c697728";
428 md5 = "c17714d0f91a23b708a592cb3c697728";
429 };
429 };
430 meta = {
430 meta = {
431 license = [ pkgs.lib.licenses.mit ];
431 license = [ pkgs.lib.licenses.mit ];
432 };
432 };
433 };
433 };
434 bleach = super.buildPythonPackage {
434 bleach = super.buildPythonPackage {
435 name = "bleach-1.5.0";
435 name = "bleach-1.5.0";
436 buildInputs = with self; [];
436 buildInputs = with self; [];
437 doCheck = false;
437 doCheck = false;
438 propagatedBuildInputs = with self; [six html5lib];
438 propagatedBuildInputs = with self; [six html5lib];
439 src = fetchurl {
439 src = fetchurl {
440 url = "https://pypi.python.org/packages/99/00/25a8fce4de102bf6e3cc76bc4ea60685b2fee33bde1b34830c70cacc26a7/bleach-1.5.0.tar.gz";
440 url = "https://pypi.python.org/packages/99/00/25a8fce4de102bf6e3cc76bc4ea60685b2fee33bde1b34830c70cacc26a7/bleach-1.5.0.tar.gz";
441 md5 = "b663300efdf421b3b727b19d7be9c7e7";
441 md5 = "b663300efdf421b3b727b19d7be9c7e7";
442 };
442 };
443 meta = {
443 meta = {
444 license = [ pkgs.lib.licenses.asl20 ];
444 license = [ pkgs.lib.licenses.asl20 ];
445 };
445 };
446 };
446 };
447 bottle = super.buildPythonPackage {
447 bottle = super.buildPythonPackage {
448 name = "bottle-0.12.8";
448 name = "bottle-0.12.8";
449 buildInputs = with self; [];
449 buildInputs = with self; [];
450 doCheck = false;
450 doCheck = false;
451 propagatedBuildInputs = with self; [];
451 propagatedBuildInputs = with self; [];
452 src = fetchurl {
452 src = fetchurl {
453 url = "https://pypi.python.org/packages/52/df/e4a408f3a7af396d186d4ecd3b389dd764f0f943b4fa8d257bfe7b49d343/bottle-0.12.8.tar.gz";
453 url = "https://pypi.python.org/packages/52/df/e4a408f3a7af396d186d4ecd3b389dd764f0f943b4fa8d257bfe7b49d343/bottle-0.12.8.tar.gz";
454 md5 = "13132c0a8f607bf860810a6ee9064c5b";
454 md5 = "13132c0a8f607bf860810a6ee9064c5b";
455 };
455 };
456 meta = {
456 meta = {
457 license = [ pkgs.lib.licenses.mit ];
457 license = [ pkgs.lib.licenses.mit ];
458 };
458 };
459 };
459 };
460 bumpversion = super.buildPythonPackage {
460 bumpversion = super.buildPythonPackage {
461 name = "bumpversion-0.5.3";
461 name = "bumpversion-0.5.3";
462 buildInputs = with self; [];
462 buildInputs = with self; [];
463 doCheck = false;
463 doCheck = false;
464 propagatedBuildInputs = with self; [];
464 propagatedBuildInputs = with self; [];
465 src = fetchurl {
465 src = fetchurl {
466 url = "https://pypi.python.org/packages/14/41/8c9da3549f8e00c84f0432c3a8cf8ed6898374714676aab91501d48760db/bumpversion-0.5.3.tar.gz";
466 url = "https://pypi.python.org/packages/14/41/8c9da3549f8e00c84f0432c3a8cf8ed6898374714676aab91501d48760db/bumpversion-0.5.3.tar.gz";
467 md5 = "c66a3492eafcf5ad4b024be9fca29820";
467 md5 = "c66a3492eafcf5ad4b024be9fca29820";
468 };
468 };
469 meta = {
469 meta = {
470 license = [ pkgs.lib.licenses.mit ];
470 license = [ pkgs.lib.licenses.mit ];
471 };
471 };
472 };
472 };
473 celery = super.buildPythonPackage {
473 celery = super.buildPythonPackage {
474 name = "celery-2.2.10";
474 name = "celery-2.2.10";
475 buildInputs = with self; [];
475 buildInputs = with self; [];
476 doCheck = false;
476 doCheck = false;
477 propagatedBuildInputs = with self; [python-dateutil anyjson kombu pyparsing];
477 propagatedBuildInputs = with self; [python-dateutil anyjson kombu pyparsing];
478 src = fetchurl {
478 src = fetchurl {
479 url = "https://pypi.python.org/packages/b1/64/860fd50e45844c83442e7953effcddeff66b2851d90b2d784f7201c111b8/celery-2.2.10.tar.gz";
479 url = "https://pypi.python.org/packages/b1/64/860fd50e45844c83442e7953effcddeff66b2851d90b2d784f7201c111b8/celery-2.2.10.tar.gz";
480 md5 = "898bc87e54f278055b561316ba73e222";
480 md5 = "898bc87e54f278055b561316ba73e222";
481 };
481 };
482 meta = {
482 meta = {
483 license = [ pkgs.lib.licenses.bsdOriginal ];
483 license = [ pkgs.lib.licenses.bsdOriginal ];
484 };
484 };
485 };
485 };
486 channelstream = super.buildPythonPackage {
486 channelstream = super.buildPythonPackage {
487 name = "channelstream-0.5.2";
487 name = "channelstream-0.5.2";
488 buildInputs = with self; [];
488 buildInputs = with self; [];
489 doCheck = false;
489 doCheck = false;
490 propagatedBuildInputs = with self; [gevent ws4py pyramid pyramid-jinja2 itsdangerous requests six];
490 propagatedBuildInputs = with self; [gevent ws4py pyramid pyramid-jinja2 itsdangerous requests six];
491 src = fetchurl {
491 src = fetchurl {
492 url = "https://pypi.python.org/packages/2b/31/29a8e085cf5bf97fa88e7b947adabfc581a18a3463adf77fb6dada34a65f/channelstream-0.5.2.tar.gz";
492 url = "https://pypi.python.org/packages/2b/31/29a8e085cf5bf97fa88e7b947adabfc581a18a3463adf77fb6dada34a65f/channelstream-0.5.2.tar.gz";
493 md5 = "1c5eb2a8a405be6f1073da94da6d81d3";
493 md5 = "1c5eb2a8a405be6f1073da94da6d81d3";
494 };
494 };
495 meta = {
495 meta = {
496 license = [ pkgs.lib.licenses.bsdOriginal ];
496 license = [ pkgs.lib.licenses.bsdOriginal ];
497 };
497 };
498 };
498 };
499 click = super.buildPythonPackage {
499 click = super.buildPythonPackage {
500 name = "click-5.1";
500 name = "click-5.1";
501 buildInputs = with self; [];
501 buildInputs = with self; [];
502 doCheck = false;
502 doCheck = false;
503 propagatedBuildInputs = with self; [];
503 propagatedBuildInputs = with self; [];
504 src = fetchurl {
504 src = fetchurl {
505 url = "https://pypi.python.org/packages/b7/34/a496632c4fb6c1ee76efedf77bb8d28b29363d839953d95095b12defe791/click-5.1.tar.gz";
505 url = "https://pypi.python.org/packages/b7/34/a496632c4fb6c1ee76efedf77bb8d28b29363d839953d95095b12defe791/click-5.1.tar.gz";
506 md5 = "9c5323008cccfe232a8b161fc8196d41";
506 md5 = "9c5323008cccfe232a8b161fc8196d41";
507 };
507 };
508 meta = {
508 meta = {
509 license = [ pkgs.lib.licenses.bsdOriginal ];
509 license = [ pkgs.lib.licenses.bsdOriginal ];
510 };
510 };
511 };
511 };
512 colander = super.buildPythonPackage {
512 colander = super.buildPythonPackage {
513 name = "colander-1.3.3";
513 name = "colander-1.3.3";
514 buildInputs = with self; [];
514 buildInputs = with self; [];
515 doCheck = false;
515 doCheck = false;
516 propagatedBuildInputs = with self; [translationstring iso8601];
516 propagatedBuildInputs = with self; [translationstring iso8601];
517 src = fetchurl {
517 src = fetchurl {
518 url = "https://pypi.python.org/packages/54/a9/9862a561e015b2c7b56404c0b13828a8bdc51e05ab3703bd792cec064487/colander-1.3.3.tar.gz";
518 url = "https://pypi.python.org/packages/54/a9/9862a561e015b2c7b56404c0b13828a8bdc51e05ab3703bd792cec064487/colander-1.3.3.tar.gz";
519 md5 = "f5d783768c51d73695f49bbe95778ab4";
519 md5 = "f5d783768c51d73695f49bbe95778ab4";
520 };
520 };
521 meta = {
521 meta = {
522 license = [ { fullName = "BSD-derived (http://www.repoze.org/LICENSE.txt)"; } ];
522 license = [ { fullName = "BSD-derived (http://www.repoze.org/LICENSE.txt)"; } ];
523 };
523 };
524 };
524 };
525 configobj = super.buildPythonPackage {
525 configobj = super.buildPythonPackage {
526 name = "configobj-5.0.6";
526 name = "configobj-5.0.6";
527 buildInputs = with self; [];
527 buildInputs = with self; [];
528 doCheck = false;
528 doCheck = false;
529 propagatedBuildInputs = with self; [six];
529 propagatedBuildInputs = with self; [six];
530 src = fetchurl {
530 src = fetchurl {
531 url = "https://pypi.python.org/packages/64/61/079eb60459c44929e684fa7d9e2fdca403f67d64dd9dbac27296be2e0fab/configobj-5.0.6.tar.gz";
531 url = "https://pypi.python.org/packages/64/61/079eb60459c44929e684fa7d9e2fdca403f67d64dd9dbac27296be2e0fab/configobj-5.0.6.tar.gz";
532 md5 = "e472a3a1c2a67bb0ec9b5d54c13a47d6";
532 md5 = "e472a3a1c2a67bb0ec9b5d54c13a47d6";
533 };
533 };
534 meta = {
534 meta = {
535 license = [ pkgs.lib.licenses.bsdOriginal ];
535 license = [ pkgs.lib.licenses.bsdOriginal ];
536 };
536 };
537 };
537 };
538 configparser = super.buildPythonPackage {
538 configparser = super.buildPythonPackage {
539 name = "configparser-3.5.0";
539 name = "configparser-3.5.0";
540 buildInputs = with self; [];
540 buildInputs = with self; [];
541 doCheck = false;
541 doCheck = false;
542 propagatedBuildInputs = with self; [];
542 propagatedBuildInputs = with self; [];
543 src = fetchurl {
543 src = fetchurl {
544 url = "https://pypi.python.org/packages/7c/69/c2ce7e91c89dc073eb1aa74c0621c3eefbffe8216b3f9af9d3885265c01c/configparser-3.5.0.tar.gz";
544 url = "https://pypi.python.org/packages/7c/69/c2ce7e91c89dc073eb1aa74c0621c3eefbffe8216b3f9af9d3885265c01c/configparser-3.5.0.tar.gz";
545 md5 = "cfdd915a5b7a6c09917a64a573140538";
545 md5 = "cfdd915a5b7a6c09917a64a573140538";
546 };
546 };
547 meta = {
547 meta = {
548 license = [ pkgs.lib.licenses.mit ];
548 license = [ pkgs.lib.licenses.mit ];
549 };
549 };
550 };
550 };
551 cov-core = super.buildPythonPackage {
551 cov-core = super.buildPythonPackage {
552 name = "cov-core-1.15.0";
552 name = "cov-core-1.15.0";
553 buildInputs = with self; [];
553 buildInputs = with self; [];
554 doCheck = false;
554 doCheck = false;
555 propagatedBuildInputs = with self; [coverage];
555 propagatedBuildInputs = with self; [coverage];
556 src = fetchurl {
556 src = fetchurl {
557 url = "https://pypi.python.org/packages/4b/87/13e75a47b4ba1be06f29f6d807ca99638bedc6b57fa491cd3de891ca2923/cov-core-1.15.0.tar.gz";
557 url = "https://pypi.python.org/packages/4b/87/13e75a47b4ba1be06f29f6d807ca99638bedc6b57fa491cd3de891ca2923/cov-core-1.15.0.tar.gz";
558 md5 = "f519d4cb4c4e52856afb14af52919fe6";
558 md5 = "f519d4cb4c4e52856afb14af52919fe6";
559 };
559 };
560 meta = {
560 meta = {
561 license = [ pkgs.lib.licenses.mit ];
561 license = [ pkgs.lib.licenses.mit ];
562 };
562 };
563 };
563 };
564 coverage = super.buildPythonPackage {
564 coverage = super.buildPythonPackage {
565 name = "coverage-3.7.1";
565 name = "coverage-3.7.1";
566 buildInputs = with self; [];
566 buildInputs = with self; [];
567 doCheck = false;
567 doCheck = false;
568 propagatedBuildInputs = with self; [];
568 propagatedBuildInputs = with self; [];
569 src = fetchurl {
569 src = fetchurl {
570 url = "https://pypi.python.org/packages/09/4f/89b06c7fdc09687bca507dc411c342556ef9c5a3b26756137a4878ff19bf/coverage-3.7.1.tar.gz";
570 url = "https://pypi.python.org/packages/09/4f/89b06c7fdc09687bca507dc411c342556ef9c5a3b26756137a4878ff19bf/coverage-3.7.1.tar.gz";
571 md5 = "c47b36ceb17eaff3ecfab3bcd347d0df";
571 md5 = "c47b36ceb17eaff3ecfab3bcd347d0df";
572 };
572 };
573 meta = {
573 meta = {
574 license = [ pkgs.lib.licenses.bsdOriginal ];
574 license = [ pkgs.lib.licenses.bsdOriginal ];
575 };
575 };
576 };
576 };
577 cssselect = super.buildPythonPackage {
577 cssselect = super.buildPythonPackage {
578 name = "cssselect-1.0.1";
578 name = "cssselect-1.0.1";
579 buildInputs = with self; [];
579 buildInputs = with self; [];
580 doCheck = false;
580 doCheck = false;
581 propagatedBuildInputs = with self; [];
581 propagatedBuildInputs = with self; [];
582 src = fetchurl {
582 src = fetchurl {
583 url = "https://pypi.python.org/packages/77/ff/9c865275cd19290feba56344eba570e719efb7ca5b34d67ed12b22ebbb0d/cssselect-1.0.1.tar.gz";
583 url = "https://pypi.python.org/packages/77/ff/9c865275cd19290feba56344eba570e719efb7ca5b34d67ed12b22ebbb0d/cssselect-1.0.1.tar.gz";
584 md5 = "3fa03bf82a9f0b1223c0f1eb1369e139";
584 md5 = "3fa03bf82a9f0b1223c0f1eb1369e139";
585 };
585 };
586 meta = {
586 meta = {
587 license = [ pkgs.lib.licenses.bsdOriginal ];
587 license = [ pkgs.lib.licenses.bsdOriginal ];
588 };
588 };
589 };
589 };
590 decorator = super.buildPythonPackage {
590 decorator = super.buildPythonPackage {
591 name = "decorator-4.0.11";
591 name = "decorator-4.0.11";
592 buildInputs = with self; [];
592 buildInputs = with self; [];
593 doCheck = false;
593 doCheck = false;
594 propagatedBuildInputs = with self; [];
594 propagatedBuildInputs = with self; [];
595 src = fetchurl {
595 src = fetchurl {
596 url = "https://pypi.python.org/packages/cc/ac/5a16f1fc0506ff72fcc8fd4e858e3a1c231f224ab79bb7c4c9b2094cc570/decorator-4.0.11.tar.gz";
596 url = "https://pypi.python.org/packages/cc/ac/5a16f1fc0506ff72fcc8fd4e858e3a1c231f224ab79bb7c4c9b2094cc570/decorator-4.0.11.tar.gz";
597 md5 = "73644c8f0bd4983d1b6a34b49adec0ae";
597 md5 = "73644c8f0bd4983d1b6a34b49adec0ae";
598 };
598 };
599 meta = {
599 meta = {
600 license = [ pkgs.lib.licenses.bsdOriginal { fullName = "new BSD License"; } ];
600 license = [ pkgs.lib.licenses.bsdOriginal { fullName = "new BSD License"; } ];
601 };
601 };
602 };
602 };
603 deform = super.buildPythonPackage {
603 deform = super.buildPythonPackage {
604 name = "deform-2.0.4";
604 name = "deform-2.0.4";
605 buildInputs = with self; [];
605 buildInputs = with self; [];
606 doCheck = false;
606 doCheck = false;
607 propagatedBuildInputs = with self; [Chameleon colander iso8601 peppercorn translationstring zope.deprecation];
607 propagatedBuildInputs = with self; [Chameleon colander iso8601 peppercorn translationstring zope.deprecation];
608 src = fetchurl {
608 src = fetchurl {
609 url = "https://pypi.python.org/packages/66/3b/eefcb07abcab7a97f6665aa2d0cf1af741d9d6e78a2e4657fd2b89f89880/deform-2.0.4.tar.gz";
609 url = "https://pypi.python.org/packages/66/3b/eefcb07abcab7a97f6665aa2d0cf1af741d9d6e78a2e4657fd2b89f89880/deform-2.0.4.tar.gz";
610 md5 = "34756e42cf50dd4b4430809116c4ec0a";
610 md5 = "34756e42cf50dd4b4430809116c4ec0a";
611 };
611 };
612 meta = {
612 meta = {
613 license = [ { fullName = "BSD-derived (http://www.repoze.org/LICENSE.txt)"; } ];
613 license = [ { fullName = "BSD-derived (http://www.repoze.org/LICENSE.txt)"; } ];
614 };
614 };
615 };
615 };
616 docutils = super.buildPythonPackage {
616 docutils = super.buildPythonPackage {
617 name = "docutils-0.13.1";
617 name = "docutils-0.13.1";
618 buildInputs = with self; [];
618 buildInputs = with self; [];
619 doCheck = false;
619 doCheck = false;
620 propagatedBuildInputs = with self; [];
620 propagatedBuildInputs = with self; [];
621 src = fetchurl {
621 src = fetchurl {
622 url = "https://pypi.python.org/packages/05/25/7b5484aca5d46915493f1fd4ecb63c38c333bd32aa9ad6e19da8d08895ae/docutils-0.13.1.tar.gz";
622 url = "https://pypi.python.org/packages/05/25/7b5484aca5d46915493f1fd4ecb63c38c333bd32aa9ad6e19da8d08895ae/docutils-0.13.1.tar.gz";
623 md5 = "ea4a893c633c788be9b8078b6b305d53";
623 md5 = "ea4a893c633c788be9b8078b6b305d53";
624 };
624 };
625 meta = {
625 meta = {
626 license = [ pkgs.lib.licenses.bsdOriginal pkgs.lib.licenses.publicDomain pkgs.lib.licenses.gpl1 { fullName = "public domain, Python, 2-Clause BSD, GPL 3 (see COPYING.txt)"; } pkgs.lib.licenses.psfl ];
626 license = [ pkgs.lib.licenses.bsdOriginal pkgs.lib.licenses.publicDomain pkgs.lib.licenses.gpl1 { fullName = "public domain, Python, 2-Clause BSD, GPL 3 (see COPYING.txt)"; } pkgs.lib.licenses.psfl ];
627 };
627 };
628 };
628 };
629 dogpile.cache = super.buildPythonPackage {
629 dogpile.cache = super.buildPythonPackage {
630 name = "dogpile.cache-0.6.4";
630 name = "dogpile.cache-0.6.4";
631 buildInputs = with self; [];
631 buildInputs = with self; [];
632 doCheck = false;
632 doCheck = false;
633 propagatedBuildInputs = with self; [];
633 propagatedBuildInputs = with self; [];
634 src = fetchurl {
634 src = fetchurl {
635 url = "https://pypi.python.org/packages/b6/3d/35c05ca01c070bb70d9d422f2c4858ecb021b05b21af438fec5ccd7b945c/dogpile.cache-0.6.4.tar.gz";
635 url = "https://pypi.python.org/packages/b6/3d/35c05ca01c070bb70d9d422f2c4858ecb021b05b21af438fec5ccd7b945c/dogpile.cache-0.6.4.tar.gz";
636 md5 = "66e0a6cae6c08cb1ea25f89d0eadfeb0";
636 md5 = "66e0a6cae6c08cb1ea25f89d0eadfeb0";
637 };
637 };
638 meta = {
638 meta = {
639 license = [ pkgs.lib.licenses.bsdOriginal ];
639 license = [ pkgs.lib.licenses.bsdOriginal ];
640 };
640 };
641 };
641 };
642 dogpile.core = super.buildPythonPackage {
642 dogpile.core = super.buildPythonPackage {
643 name = "dogpile.core-0.4.1";
643 name = "dogpile.core-0.4.1";
644 buildInputs = with self; [];
644 buildInputs = with self; [];
645 doCheck = false;
645 doCheck = false;
646 propagatedBuildInputs = with self; [];
646 propagatedBuildInputs = with self; [];
647 src = fetchurl {
647 src = fetchurl {
648 url = "https://pypi.python.org/packages/0e/77/e72abc04c22aedf874301861e5c1e761231c288b5de369c18be8f4b5c9bb/dogpile.core-0.4.1.tar.gz";
648 url = "https://pypi.python.org/packages/0e/77/e72abc04c22aedf874301861e5c1e761231c288b5de369c18be8f4b5c9bb/dogpile.core-0.4.1.tar.gz";
649 md5 = "01cb19f52bba3e95c9b560f39341f045";
649 md5 = "01cb19f52bba3e95c9b560f39341f045";
650 };
650 };
651 meta = {
651 meta = {
652 license = [ pkgs.lib.licenses.bsdOriginal ];
652 license = [ pkgs.lib.licenses.bsdOriginal ];
653 };
653 };
654 };
654 };
655 ecdsa = super.buildPythonPackage {
655 ecdsa = super.buildPythonPackage {
656 name = "ecdsa-0.11";
656 name = "ecdsa-0.13";
657 buildInputs = with self; [];
657 buildInputs = with self; [];
658 doCheck = false;
658 doCheck = false;
659 propagatedBuildInputs = with self; [];
659 propagatedBuildInputs = with self; [];
660 src = fetchurl {
660 src = fetchurl {
661 url = "https://pypi.python.org/packages/6c/3f/92fe5dcdcaa7bd117be21e5520c9a54375112b66ec000d209e9e9519fad1/ecdsa-0.11.tar.gz";
661 url = "https://pypi.python.org/packages/f9/e5/99ebb176e47f150ac115ffeda5fedb6a3dbb3c00c74a59fd84ddf12f5857/ecdsa-0.13.tar.gz";
662 md5 = "8ef586fe4dbb156697d756900cb41d7c";
662 md5 = "1f60eda9cb5c46722856db41a3ae6670";
663 };
663 };
664 meta = {
664 meta = {
665 license = [ pkgs.lib.licenses.mit ];
665 license = [ pkgs.lib.licenses.mit ];
666 };
666 };
667 };
667 };
668 elasticsearch = super.buildPythonPackage {
668 elasticsearch = super.buildPythonPackage {
669 name = "elasticsearch-2.3.0";
669 name = "elasticsearch-2.3.0";
670 buildInputs = with self; [];
670 buildInputs = with self; [];
671 doCheck = false;
671 doCheck = false;
672 propagatedBuildInputs = with self; [urllib3];
672 propagatedBuildInputs = with self; [urllib3];
673 src = fetchurl {
673 src = fetchurl {
674 url = "https://pypi.python.org/packages/10/35/5fd52c5f0b0ee405ed4b5195e8bce44c5e041787680dc7b94b8071cac600/elasticsearch-2.3.0.tar.gz";
674 url = "https://pypi.python.org/packages/10/35/5fd52c5f0b0ee405ed4b5195e8bce44c5e041787680dc7b94b8071cac600/elasticsearch-2.3.0.tar.gz";
675 md5 = "2550f3b51629cf1ef9636608af92c340";
675 md5 = "2550f3b51629cf1ef9636608af92c340";
676 };
676 };
677 meta = {
677 meta = {
678 license = [ pkgs.lib.licenses.asl20 ];
678 license = [ pkgs.lib.licenses.asl20 ];
679 };
679 };
680 };
680 };
681 elasticsearch-dsl = super.buildPythonPackage {
681 elasticsearch-dsl = super.buildPythonPackage {
682 name = "elasticsearch-dsl-2.2.0";
682 name = "elasticsearch-dsl-2.2.0";
683 buildInputs = with self; [];
683 buildInputs = with self; [];
684 doCheck = false;
684 doCheck = false;
685 propagatedBuildInputs = with self; [six python-dateutil elasticsearch];
685 propagatedBuildInputs = with self; [six python-dateutil elasticsearch];
686 src = fetchurl {
686 src = fetchurl {
687 url = "https://pypi.python.org/packages/66/2f/52a086968788e58461641570f45c3207a52d46ebbe9b77dc22b6a8ffda66/elasticsearch-dsl-2.2.0.tar.gz";
687 url = "https://pypi.python.org/packages/66/2f/52a086968788e58461641570f45c3207a52d46ebbe9b77dc22b6a8ffda66/elasticsearch-dsl-2.2.0.tar.gz";
688 md5 = "fa6bd3c87ea3caa8f0f051bc37c53221";
688 md5 = "fa6bd3c87ea3caa8f0f051bc37c53221";
689 };
689 };
690 meta = {
690 meta = {
691 license = [ pkgs.lib.licenses.asl20 ];
691 license = [ pkgs.lib.licenses.asl20 ];
692 };
692 };
693 };
693 };
694 entrypoints = super.buildPythonPackage {
694 entrypoints = super.buildPythonPackage {
695 name = "entrypoints-0.2.2";
695 name = "entrypoints-0.2.2";
696 buildInputs = with self; [];
696 buildInputs = with self; [];
697 doCheck = false;
697 doCheck = false;
698 propagatedBuildInputs = with self; [configparser];
698 propagatedBuildInputs = with self; [configparser];
699 src = fetchurl {
699 src = fetchurl {
700 url = "https://code.rhodecode.com/upstream/entrypoints/archive/96e6d645684e1af3d7df5b5272f3fe85a546b233.tar.gz?md5=7db37771aea9ac9fefe093e5d6987313";
700 url = "https://code.rhodecode.com/upstream/entrypoints/archive/96e6d645684e1af3d7df5b5272f3fe85a546b233.tar.gz?md5=7db37771aea9ac9fefe093e5d6987313";
701 md5 = "7db37771aea9ac9fefe093e5d6987313";
701 md5 = "7db37771aea9ac9fefe093e5d6987313";
702 };
702 };
703 meta = {
703 meta = {
704 license = [ pkgs.lib.licenses.mit ];
704 license = [ pkgs.lib.licenses.mit ];
705 };
705 };
706 };
706 };
707 enum34 = super.buildPythonPackage {
707 enum34 = super.buildPythonPackage {
708 name = "enum34-1.1.6";
708 name = "enum34-1.1.6";
709 buildInputs = with self; [];
709 buildInputs = with self; [];
710 doCheck = false;
710 doCheck = false;
711 propagatedBuildInputs = with self; [];
711 propagatedBuildInputs = with self; [];
712 src = fetchurl {
712 src = fetchurl {
713 url = "https://pypi.python.org/packages/bf/3e/31d502c25302814a7c2f1d3959d2a3b3f78e509002ba91aea64993936876/enum34-1.1.6.tar.gz";
713 url = "https://pypi.python.org/packages/bf/3e/31d502c25302814a7c2f1d3959d2a3b3f78e509002ba91aea64993936876/enum34-1.1.6.tar.gz";
714 md5 = "5f13a0841a61f7fc295c514490d120d0";
714 md5 = "5f13a0841a61f7fc295c514490d120d0";
715 };
715 };
716 meta = {
716 meta = {
717 license = [ pkgs.lib.licenses.bsdOriginal ];
717 license = [ pkgs.lib.licenses.bsdOriginal ];
718 };
718 };
719 };
719 };
720 funcsigs = super.buildPythonPackage {
720 funcsigs = super.buildPythonPackage {
721 name = "funcsigs-1.0.2";
721 name = "funcsigs-1.0.2";
722 buildInputs = with self; [];
722 buildInputs = with self; [];
723 doCheck = false;
723 doCheck = false;
724 propagatedBuildInputs = with self; [];
724 propagatedBuildInputs = with self; [];
725 src = fetchurl {
725 src = fetchurl {
726 url = "https://pypi.python.org/packages/94/4a/db842e7a0545de1cdb0439bb80e6e42dfe82aaeaadd4072f2263a4fbed23/funcsigs-1.0.2.tar.gz";
726 url = "https://pypi.python.org/packages/94/4a/db842e7a0545de1cdb0439bb80e6e42dfe82aaeaadd4072f2263a4fbed23/funcsigs-1.0.2.tar.gz";
727 md5 = "7e583285b1fb8a76305d6d68f4ccc14e";
727 md5 = "7e583285b1fb8a76305d6d68f4ccc14e";
728 };
728 };
729 meta = {
729 meta = {
730 license = [ { fullName = "ASL"; } pkgs.lib.licenses.asl20 ];
730 license = [ { fullName = "ASL"; } pkgs.lib.licenses.asl20 ];
731 };
731 };
732 };
732 };
733 functools32 = super.buildPythonPackage {
733 functools32 = super.buildPythonPackage {
734 name = "functools32-3.2.3.post2";
734 name = "functools32-3.2.3.post2";
735 buildInputs = with self; [];
735 buildInputs = with self; [];
736 doCheck = false;
736 doCheck = false;
737 propagatedBuildInputs = with self; [];
737 propagatedBuildInputs = with self; [];
738 src = fetchurl {
738 src = fetchurl {
739 url = "https://pypi.python.org/packages/5e/1a/0aa2c8195a204a9f51284018562dea77e25511f02fe924fac202fc012172/functools32-3.2.3-2.zip";
739 url = "https://pypi.python.org/packages/5e/1a/0aa2c8195a204a9f51284018562dea77e25511f02fe924fac202fc012172/functools32-3.2.3-2.zip";
740 md5 = "d55232eb132ec779e6893c902a0bc5ad";
740 md5 = "d55232eb132ec779e6893c902a0bc5ad";
741 };
741 };
742 meta = {
742 meta = {
743 license = [ pkgs.lib.licenses.psfl ];
743 license = [ pkgs.lib.licenses.psfl ];
744 };
744 };
745 };
745 };
746 future = super.buildPythonPackage {
746 future = super.buildPythonPackage {
747 name = "future-0.14.3";
747 name = "future-0.14.3";
748 buildInputs = with self; [];
748 buildInputs = with self; [];
749 doCheck = false;
749 doCheck = false;
750 propagatedBuildInputs = with self; [];
750 propagatedBuildInputs = with self; [];
751 src = fetchurl {
751 src = fetchurl {
752 url = "https://pypi.python.org/packages/83/80/8ef3a11a15f8eaafafa0937b20c1b3f73527e69ab6b3fa1cf94a5a96aabb/future-0.14.3.tar.gz";
752 url = "https://pypi.python.org/packages/83/80/8ef3a11a15f8eaafafa0937b20c1b3f73527e69ab6b3fa1cf94a5a96aabb/future-0.14.3.tar.gz";
753 md5 = "e94079b0bd1fc054929e8769fc0f6083";
753 md5 = "e94079b0bd1fc054929e8769fc0f6083";
754 };
754 };
755 meta = {
755 meta = {
756 license = [ { fullName = "OSI Approved"; } pkgs.lib.licenses.mit ];
756 license = [ { fullName = "OSI Approved"; } pkgs.lib.licenses.mit ];
757 };
757 };
758 };
758 };
759 futures = super.buildPythonPackage {
759 futures = super.buildPythonPackage {
760 name = "futures-3.0.2";
760 name = "futures-3.0.2";
761 buildInputs = with self; [];
761 buildInputs = with self; [];
762 doCheck = false;
762 doCheck = false;
763 propagatedBuildInputs = with self; [];
763 propagatedBuildInputs = with self; [];
764 src = fetchurl {
764 src = fetchurl {
765 url = "https://pypi.python.org/packages/f8/e7/fc0fcbeb9193ba2d4de00b065e7fd5aecd0679e93ce95a07322b2b1434f4/futures-3.0.2.tar.gz";
765 url = "https://pypi.python.org/packages/f8/e7/fc0fcbeb9193ba2d4de00b065e7fd5aecd0679e93ce95a07322b2b1434f4/futures-3.0.2.tar.gz";
766 md5 = "42aaf1e4de48d6e871d77dc1f9d96d5a";
766 md5 = "42aaf1e4de48d6e871d77dc1f9d96d5a";
767 };
767 };
768 meta = {
768 meta = {
769 license = [ pkgs.lib.licenses.bsdOriginal ];
769 license = [ pkgs.lib.licenses.bsdOriginal ];
770 };
770 };
771 };
771 };
772 gevent = super.buildPythonPackage {
772 gevent = super.buildPythonPackage {
773 name = "gevent-1.2.2";
773 name = "gevent-1.2.2";
774 buildInputs = with self; [];
774 buildInputs = with self; [];
775 doCheck = false;
775 doCheck = false;
776 propagatedBuildInputs = with self; [greenlet];
776 propagatedBuildInputs = with self; [greenlet];
777 src = fetchurl {
777 src = fetchurl {
778 url = "https://pypi.python.org/packages/1b/92/b111f76e54d2be11375b47b213b56687214f258fd9dae703546d30b837be/gevent-1.2.2.tar.gz";
778 url = "https://pypi.python.org/packages/1b/92/b111f76e54d2be11375b47b213b56687214f258fd9dae703546d30b837be/gevent-1.2.2.tar.gz";
779 md5 = "7f0baf355384fe5ff2ecf66853422554";
779 md5 = "7f0baf355384fe5ff2ecf66853422554";
780 };
780 };
781 meta = {
781 meta = {
782 license = [ pkgs.lib.licenses.mit ];
782 license = [ pkgs.lib.licenses.mit ];
783 };
783 };
784 };
784 };
785 gnureadline = super.buildPythonPackage {
785 gnureadline = super.buildPythonPackage {
786 name = "gnureadline-6.3.3";
786 name = "gnureadline-6.3.3";
787 buildInputs = with self; [];
787 buildInputs = with self; [];
788 doCheck = false;
788 doCheck = false;
789 propagatedBuildInputs = with self; [];
789 propagatedBuildInputs = with self; [];
790 src = fetchurl {
790 src = fetchurl {
791 url = "https://pypi.python.org/packages/3a/ee/2c3f568b0a74974791ac590ec742ef6133e2fbd287a074ba72a53fa5e97c/gnureadline-6.3.3.tar.gz";
791 url = "https://pypi.python.org/packages/3a/ee/2c3f568b0a74974791ac590ec742ef6133e2fbd287a074ba72a53fa5e97c/gnureadline-6.3.3.tar.gz";
792 md5 = "c4af83c9a3fbeac8f2da9b5a7c60e51c";
792 md5 = "c4af83c9a3fbeac8f2da9b5a7c60e51c";
793 };
793 };
794 meta = {
794 meta = {
795 license = [ pkgs.lib.licenses.gpl1 ];
795 license = [ pkgs.lib.licenses.gpl1 ];
796 };
796 };
797 };
797 };
798 gprof2dot = super.buildPythonPackage {
798 gprof2dot = super.buildPythonPackage {
799 name = "gprof2dot-2016.10.13";
799 name = "gprof2dot-2016.10.13";
800 buildInputs = with self; [];
800 buildInputs = with self; [];
801 doCheck = false;
801 doCheck = false;
802 propagatedBuildInputs = with self; [];
802 propagatedBuildInputs = with self; [];
803 src = fetchurl {
803 src = fetchurl {
804 url = "https://pypi.python.org/packages/a0/e0/73c71baed306f0402a00a94ffc7b2be94ad1296dfcb8b46912655b93154c/gprof2dot-2016.10.13.tar.gz";
804 url = "https://pypi.python.org/packages/a0/e0/73c71baed306f0402a00a94ffc7b2be94ad1296dfcb8b46912655b93154c/gprof2dot-2016.10.13.tar.gz";
805 md5 = "0125401f15fd2afe1df686a76c64a4fd";
805 md5 = "0125401f15fd2afe1df686a76c64a4fd";
806 };
806 };
807 meta = {
807 meta = {
808 license = [ { fullName = "LGPL"; } ];
808 license = [ { fullName = "LGPL"; } ];
809 };
809 };
810 };
810 };
811 graphviz = super.buildPythonPackage {
811 graphviz = super.buildPythonPackage {
812 name = "graphviz-0.8";
812 name = "graphviz-0.8";
813 buildInputs = with self; [];
813 buildInputs = with self; [];
814 doCheck = false;
814 doCheck = false;
815 propagatedBuildInputs = with self; [];
815 propagatedBuildInputs = with self; [];
816 src = fetchurl {
816 src = fetchurl {
817 url = "https://pypi.python.org/packages/da/84/0e997520323d6b01124eb01c68d5c101814d0aab53083cd62bd75a90f70b/graphviz-0.8.zip";
817 url = "https://pypi.python.org/packages/da/84/0e997520323d6b01124eb01c68d5c101814d0aab53083cd62bd75a90f70b/graphviz-0.8.zip";
818 md5 = "9486a885360a5ee54a81eb2950470c71";
818 md5 = "9486a885360a5ee54a81eb2950470c71";
819 };
819 };
820 meta = {
820 meta = {
821 license = [ pkgs.lib.licenses.mit ];
821 license = [ pkgs.lib.licenses.mit ];
822 };
822 };
823 };
823 };
824 greenlet = super.buildPythonPackage {
824 greenlet = super.buildPythonPackage {
825 name = "greenlet-0.4.12";
825 name = "greenlet-0.4.12";
826 buildInputs = with self; [];
826 buildInputs = with self; [];
827 doCheck = false;
827 doCheck = false;
828 propagatedBuildInputs = with self; [];
828 propagatedBuildInputs = with self; [];
829 src = fetchurl {
829 src = fetchurl {
830 url = "https://pypi.python.org/packages/be/76/82af375d98724054b7e273b5d9369346937324f9bcc20980b45b068ef0b0/greenlet-0.4.12.tar.gz";
830 url = "https://pypi.python.org/packages/be/76/82af375d98724054b7e273b5d9369346937324f9bcc20980b45b068ef0b0/greenlet-0.4.12.tar.gz";
831 md5 = "e8637647d58a26c4a1f51ca393e53c00";
831 md5 = "e8637647d58a26c4a1f51ca393e53c00";
832 };
832 };
833 meta = {
833 meta = {
834 license = [ pkgs.lib.licenses.mit ];
834 license = [ pkgs.lib.licenses.mit ];
835 };
835 };
836 };
836 };
837 gunicorn = super.buildPythonPackage {
837 gunicorn = super.buildPythonPackage {
838 name = "gunicorn-19.7.1";
838 name = "gunicorn-19.7.1";
839 buildInputs = with self; [];
839 buildInputs = with self; [];
840 doCheck = false;
840 doCheck = false;
841 propagatedBuildInputs = with self; [];
841 propagatedBuildInputs = with self; [];
842 src = fetchurl {
842 src = fetchurl {
843 url = "https://pypi.python.org/packages/30/3a/10bb213cede0cc4d13ac2263316c872a64bf4c819000c8ccd801f1d5f822/gunicorn-19.7.1.tar.gz";
843 url = "https://pypi.python.org/packages/30/3a/10bb213cede0cc4d13ac2263316c872a64bf4c819000c8ccd801f1d5f822/gunicorn-19.7.1.tar.gz";
844 md5 = "174d3c3cd670a5be0404d84c484e590c";
844 md5 = "174d3c3cd670a5be0404d84c484e590c";
845 };
845 };
846 meta = {
846 meta = {
847 license = [ pkgs.lib.licenses.mit ];
847 license = [ pkgs.lib.licenses.mit ];
848 };
848 };
849 };
849 };
850 html5lib = super.buildPythonPackage {
850 html5lib = super.buildPythonPackage {
851 name = "html5lib-0.9999999";
851 name = "html5lib-0.9999999";
852 buildInputs = with self; [];
852 buildInputs = with self; [];
853 doCheck = false;
853 doCheck = false;
854 propagatedBuildInputs = with self; [six];
854 propagatedBuildInputs = with self; [six];
855 src = fetchurl {
855 src = fetchurl {
856 url = "https://pypi.python.org/packages/ae/ae/bcb60402c60932b32dfaf19bb53870b29eda2cd17551ba5639219fb5ebf9/html5lib-0.9999999.tar.gz";
856 url = "https://pypi.python.org/packages/ae/ae/bcb60402c60932b32dfaf19bb53870b29eda2cd17551ba5639219fb5ebf9/html5lib-0.9999999.tar.gz";
857 md5 = "ef43cb05e9e799f25d65d1135838a96f";
857 md5 = "ef43cb05e9e799f25d65d1135838a96f";
858 };
858 };
859 meta = {
859 meta = {
860 license = [ pkgs.lib.licenses.mit ];
860 license = [ pkgs.lib.licenses.mit ];
861 };
861 };
862 };
862 };
863 hupper = super.buildPythonPackage {
863 hupper = super.buildPythonPackage {
864 name = "hupper-1.0";
864 name = "hupper-1.0";
865 buildInputs = with self; [];
865 buildInputs = with self; [];
866 doCheck = false;
866 doCheck = false;
867 propagatedBuildInputs = with self; [];
867 propagatedBuildInputs = with self; [];
868 src = fetchurl {
868 src = fetchurl {
869 url = "https://pypi.python.org/packages/2e/07/df892c564dc09bb3cf6f6deb976c26adf9117db75ba218cb4353dbc9d826/hupper-1.0.tar.gz";
869 url = "https://pypi.python.org/packages/2e/07/df892c564dc09bb3cf6f6deb976c26adf9117db75ba218cb4353dbc9d826/hupper-1.0.tar.gz";
870 md5 = "26e77da7d5ac5858f59af050d1a6eb5a";
870 md5 = "26e77da7d5ac5858f59af050d1a6eb5a";
871 };
871 };
872 meta = {
872 meta = {
873 license = [ pkgs.lib.licenses.mit ];
873 license = [ pkgs.lib.licenses.mit ];
874 };
874 };
875 };
875 };
876 infrae.cache = super.buildPythonPackage {
876 infrae.cache = super.buildPythonPackage {
877 name = "infrae.cache-1.0.1";
877 name = "infrae.cache-1.0.1";
878 buildInputs = with self; [];
878 buildInputs = with self; [];
879 doCheck = false;
879 doCheck = false;
880 propagatedBuildInputs = with self; [Beaker repoze.lru];
880 propagatedBuildInputs = with self; [Beaker repoze.lru];
881 src = fetchurl {
881 src = fetchurl {
882 url = "https://pypi.python.org/packages/bb/f0/e7d5e984cf6592fd2807dc7bc44a93f9d18e04e6a61f87fdfb2622422d74/infrae.cache-1.0.1.tar.gz";
882 url = "https://pypi.python.org/packages/bb/f0/e7d5e984cf6592fd2807dc7bc44a93f9d18e04e6a61f87fdfb2622422d74/infrae.cache-1.0.1.tar.gz";
883 md5 = "b09076a766747e6ed2a755cc62088e32";
883 md5 = "b09076a766747e6ed2a755cc62088e32";
884 };
884 };
885 meta = {
885 meta = {
886 license = [ pkgs.lib.licenses.zpt21 ];
886 license = [ pkgs.lib.licenses.zpt21 ];
887 };
887 };
888 };
888 };
889 invoke = super.buildPythonPackage {
889 invoke = super.buildPythonPackage {
890 name = "invoke-0.13.0";
890 name = "invoke-0.13.0";
891 buildInputs = with self; [];
891 buildInputs = with self; [];
892 doCheck = false;
892 doCheck = false;
893 propagatedBuildInputs = with self; [];
893 propagatedBuildInputs = with self; [];
894 src = fetchurl {
894 src = fetchurl {
895 url = "https://pypi.python.org/packages/47/bf/d07ef52fa1ac645468858bbac7cb95b246a972a045e821493d17d89c81be/invoke-0.13.0.tar.gz";
895 url = "https://pypi.python.org/packages/47/bf/d07ef52fa1ac645468858bbac7cb95b246a972a045e821493d17d89c81be/invoke-0.13.0.tar.gz";
896 md5 = "c0d1ed4bfb34eaab551662d8cfee6540";
896 md5 = "c0d1ed4bfb34eaab551662d8cfee6540";
897 };
897 };
898 meta = {
898 meta = {
899 license = [ pkgs.lib.licenses.bsdOriginal ];
899 license = [ pkgs.lib.licenses.bsdOriginal ];
900 };
900 };
901 };
901 };
902 ipaddress = super.buildPythonPackage {
902 ipaddress = super.buildPythonPackage {
903 name = "ipaddress-1.0.18";
903 name = "ipaddress-1.0.18";
904 buildInputs = with self; [];
904 buildInputs = with self; [];
905 doCheck = false;
905 doCheck = false;
906 propagatedBuildInputs = with self; [];
906 propagatedBuildInputs = with self; [];
907 src = fetchurl {
907 src = fetchurl {
908 url = "https://pypi.python.org/packages/4e/13/774faf38b445d0b3a844b65747175b2e0500164b7c28d78e34987a5bfe06/ipaddress-1.0.18.tar.gz";
908 url = "https://pypi.python.org/packages/4e/13/774faf38b445d0b3a844b65747175b2e0500164b7c28d78e34987a5bfe06/ipaddress-1.0.18.tar.gz";
909 md5 = "310c2dfd64eb6f0df44aa8c59f2334a7";
909 md5 = "310c2dfd64eb6f0df44aa8c59f2334a7";
910 };
910 };
911 meta = {
911 meta = {
912 license = [ pkgs.lib.licenses.psfl ];
912 license = [ pkgs.lib.licenses.psfl ];
913 };
913 };
914 };
914 };
915 ipdb = super.buildPythonPackage {
915 ipdb = super.buildPythonPackage {
916 name = "ipdb-0.10.3";
916 name = "ipdb-0.10.3";
917 buildInputs = with self; [];
917 buildInputs = with self; [];
918 doCheck = false;
918 doCheck = false;
919 propagatedBuildInputs = with self; [setuptools ipython];
919 propagatedBuildInputs = with self; [setuptools ipython];
920 src = fetchurl {
920 src = fetchurl {
921 url = "https://pypi.python.org/packages/ad/cc/0e7298e1fbf2efd52667c9354a12aa69fb6f796ce230cca03525051718ef/ipdb-0.10.3.tar.gz";
921 url = "https://pypi.python.org/packages/ad/cc/0e7298e1fbf2efd52667c9354a12aa69fb6f796ce230cca03525051718ef/ipdb-0.10.3.tar.gz";
922 md5 = "def1f6ac075d54bdee07e6501263d4fa";
922 md5 = "def1f6ac075d54bdee07e6501263d4fa";
923 };
923 };
924 meta = {
924 meta = {
925 license = [ pkgs.lib.licenses.bsdOriginal ];
925 license = [ pkgs.lib.licenses.bsdOriginal ];
926 };
926 };
927 };
927 };
928 ipython = super.buildPythonPackage {
928 ipython = super.buildPythonPackage {
929 name = "ipython-5.1.0";
929 name = "ipython-5.1.0";
930 buildInputs = with self; [];
930 buildInputs = with self; [];
931 doCheck = false;
931 doCheck = false;
932 propagatedBuildInputs = with self; [setuptools decorator pickleshare simplegeneric traitlets prompt-toolkit Pygments pexpect backports.shutil-get-terminal-size pathlib2 pexpect];
932 propagatedBuildInputs = with self; [setuptools decorator pickleshare simplegeneric traitlets prompt-toolkit Pygments pexpect backports.shutil-get-terminal-size pathlib2 pexpect];
933 src = fetchurl {
933 src = fetchurl {
934 url = "https://pypi.python.org/packages/89/63/a9292f7cd9d0090a0f995e1167f3f17d5889dcbc9a175261719c513b9848/ipython-5.1.0.tar.gz";
934 url = "https://pypi.python.org/packages/89/63/a9292f7cd9d0090a0f995e1167f3f17d5889dcbc9a175261719c513b9848/ipython-5.1.0.tar.gz";
935 md5 = "47c8122420f65b58784cb4b9b4af35e3";
935 md5 = "47c8122420f65b58784cb4b9b4af35e3";
936 };
936 };
937 meta = {
937 meta = {
938 license = [ pkgs.lib.licenses.bsdOriginal ];
938 license = [ pkgs.lib.licenses.bsdOriginal ];
939 };
939 };
940 };
940 };
941 ipython-genutils = super.buildPythonPackage {
941 ipython-genutils = super.buildPythonPackage {
942 name = "ipython-genutils-0.2.0";
942 name = "ipython-genutils-0.2.0";
943 buildInputs = with self; [];
943 buildInputs = with self; [];
944 doCheck = false;
944 doCheck = false;
945 propagatedBuildInputs = with self; [];
945 propagatedBuildInputs = with self; [];
946 src = fetchurl {
946 src = fetchurl {
947 url = "https://pypi.python.org/packages/e8/69/fbeffffc05236398ebfcfb512b6d2511c622871dca1746361006da310399/ipython_genutils-0.2.0.tar.gz";
947 url = "https://pypi.python.org/packages/e8/69/fbeffffc05236398ebfcfb512b6d2511c622871dca1746361006da310399/ipython_genutils-0.2.0.tar.gz";
948 md5 = "5a4f9781f78466da0ea1a648f3e1f79f";
948 md5 = "5a4f9781f78466da0ea1a648f3e1f79f";
949 };
949 };
950 meta = {
950 meta = {
951 license = [ pkgs.lib.licenses.bsdOriginal ];
951 license = [ pkgs.lib.licenses.bsdOriginal ];
952 };
952 };
953 };
953 };
954 iso8601 = super.buildPythonPackage {
954 iso8601 = super.buildPythonPackage {
955 name = "iso8601-0.1.11";
955 name = "iso8601-0.1.11";
956 buildInputs = with self; [];
956 buildInputs = with self; [];
957 doCheck = false;
957 doCheck = false;
958 propagatedBuildInputs = with self; [];
958 propagatedBuildInputs = with self; [];
959 src = fetchurl {
959 src = fetchurl {
960 url = "https://pypi.python.org/packages/c0/75/c9209ee4d1b5975eb8c2cba4428bde6b61bd55664a98290dd015cdb18e98/iso8601-0.1.11.tar.gz";
960 url = "https://pypi.python.org/packages/c0/75/c9209ee4d1b5975eb8c2cba4428bde6b61bd55664a98290dd015cdb18e98/iso8601-0.1.11.tar.gz";
961 md5 = "b06d11cd14a64096f907086044f0fe38";
961 md5 = "b06d11cd14a64096f907086044f0fe38";
962 };
962 };
963 meta = {
963 meta = {
964 license = [ pkgs.lib.licenses.mit ];
964 license = [ pkgs.lib.licenses.mit ];
965 };
965 };
966 };
966 };
967 itsdangerous = super.buildPythonPackage {
967 itsdangerous = super.buildPythonPackage {
968 name = "itsdangerous-0.24";
968 name = "itsdangerous-0.24";
969 buildInputs = with self; [];
969 buildInputs = with self; [];
970 doCheck = false;
970 doCheck = false;
971 propagatedBuildInputs = with self; [];
971 propagatedBuildInputs = with self; [];
972 src = fetchurl {
972 src = fetchurl {
973 url = "https://pypi.python.org/packages/dc/b4/a60bcdba945c00f6d608d8975131ab3f25b22f2bcfe1dab221165194b2d4/itsdangerous-0.24.tar.gz";
973 url = "https://pypi.python.org/packages/dc/b4/a60bcdba945c00f6d608d8975131ab3f25b22f2bcfe1dab221165194b2d4/itsdangerous-0.24.tar.gz";
974 md5 = "a3d55aa79369aef5345c036a8a26307f";
974 md5 = "a3d55aa79369aef5345c036a8a26307f";
975 };
975 };
976 meta = {
976 meta = {
977 license = [ pkgs.lib.licenses.bsdOriginal ];
977 license = [ pkgs.lib.licenses.bsdOriginal ];
978 };
978 };
979 };
979 };
980 jsonschema = super.buildPythonPackage {
980 jsonschema = super.buildPythonPackage {
981 name = "jsonschema-2.6.0";
981 name = "jsonschema-2.6.0";
982 buildInputs = with self; [];
982 buildInputs = with self; [];
983 doCheck = false;
983 doCheck = false;
984 propagatedBuildInputs = with self; [functools32];
984 propagatedBuildInputs = with self; [functools32];
985 src = fetchurl {
985 src = fetchurl {
986 url = "https://pypi.python.org/packages/58/b9/171dbb07e18c6346090a37f03c7e74410a1a56123f847efed59af260a298/jsonschema-2.6.0.tar.gz";
986 url = "https://pypi.python.org/packages/58/b9/171dbb07e18c6346090a37f03c7e74410a1a56123f847efed59af260a298/jsonschema-2.6.0.tar.gz";
987 md5 = "50c6b69a373a8b55ff1e0ec6e78f13f4";
987 md5 = "50c6b69a373a8b55ff1e0ec6e78f13f4";
988 };
988 };
989 meta = {
989 meta = {
990 license = [ pkgs.lib.licenses.mit ];
990 license = [ pkgs.lib.licenses.mit ];
991 };
991 };
992 };
992 };
993 jupyter-client = super.buildPythonPackage {
993 jupyter-client = super.buildPythonPackage {
994 name = "jupyter-client-5.0.0";
994 name = "jupyter-client-5.0.0";
995 buildInputs = with self; [];
995 buildInputs = with self; [];
996 doCheck = false;
996 doCheck = false;
997 propagatedBuildInputs = with self; [traitlets jupyter-core pyzmq python-dateutil];
997 propagatedBuildInputs = with self; [traitlets jupyter-core pyzmq python-dateutil];
998 src = fetchurl {
998 src = fetchurl {
999 url = "https://pypi.python.org/packages/e5/6f/65412ed462202b90134b7e761b0b7e7f949e07a549c1755475333727b3d0/jupyter_client-5.0.0.tar.gz";
999 url = "https://pypi.python.org/packages/e5/6f/65412ed462202b90134b7e761b0b7e7f949e07a549c1755475333727b3d0/jupyter_client-5.0.0.tar.gz";
1000 md5 = "1acd331b5c9fb4d79dae9939e79f2426";
1000 md5 = "1acd331b5c9fb4d79dae9939e79f2426";
1001 };
1001 };
1002 meta = {
1002 meta = {
1003 license = [ pkgs.lib.licenses.bsdOriginal ];
1003 license = [ pkgs.lib.licenses.bsdOriginal ];
1004 };
1004 };
1005 };
1005 };
1006 jupyter-core = super.buildPythonPackage {
1006 jupyter-core = super.buildPythonPackage {
1007 name = "jupyter-core-4.3.0";
1007 name = "jupyter-core-4.3.0";
1008 buildInputs = with self; [];
1008 buildInputs = with self; [];
1009 doCheck = false;
1009 doCheck = false;
1010 propagatedBuildInputs = with self; [traitlets];
1010 propagatedBuildInputs = with self; [traitlets];
1011 src = fetchurl {
1011 src = fetchurl {
1012 url = "https://pypi.python.org/packages/2f/39/5138f975100ce14d150938df48a83cd852a3fd8e24b1244f4113848e69e2/jupyter_core-4.3.0.tar.gz";
1012 url = "https://pypi.python.org/packages/2f/39/5138f975100ce14d150938df48a83cd852a3fd8e24b1244f4113848e69e2/jupyter_core-4.3.0.tar.gz";
1013 md5 = "18819511a809afdeed9a995a9c27bcfb";
1013 md5 = "18819511a809afdeed9a995a9c27bcfb";
1014 };
1014 };
1015 meta = {
1015 meta = {
1016 license = [ pkgs.lib.licenses.bsdOriginal ];
1016 license = [ pkgs.lib.licenses.bsdOriginal ];
1017 };
1017 };
1018 };
1018 };
1019 kombu = super.buildPythonPackage {
1019 kombu = super.buildPythonPackage {
1020 name = "kombu-1.5.1";
1020 name = "kombu-1.5.1";
1021 buildInputs = with self; [];
1021 buildInputs = with self; [];
1022 doCheck = false;
1022 doCheck = false;
1023 propagatedBuildInputs = with self; [anyjson amqplib];
1023 propagatedBuildInputs = with self; [anyjson amqplib];
1024 src = fetchurl {
1024 src = fetchurl {
1025 url = "https://pypi.python.org/packages/19/53/74bf2a624644b45f0850a638752514fc10a8e1cbd738f10804951a6df3f5/kombu-1.5.1.tar.gz";
1025 url = "https://pypi.python.org/packages/19/53/74bf2a624644b45f0850a638752514fc10a8e1cbd738f10804951a6df3f5/kombu-1.5.1.tar.gz";
1026 md5 = "50662f3c7e9395b3d0721fb75d100b63";
1026 md5 = "50662f3c7e9395b3d0721fb75d100b63";
1027 };
1027 };
1028 meta = {
1028 meta = {
1029 license = [ pkgs.lib.licenses.bsdOriginal ];
1029 license = [ pkgs.lib.licenses.bsdOriginal ];
1030 };
1030 };
1031 };
1031 };
1032 lxml = super.buildPythonPackage {
1032 lxml = super.buildPythonPackage {
1033 name = "lxml-3.7.3";
1033 name = "lxml-3.7.3";
1034 buildInputs = with self; [];
1034 buildInputs = with self; [];
1035 doCheck = false;
1035 doCheck = false;
1036 propagatedBuildInputs = with self; [];
1036 propagatedBuildInputs = with self; [];
1037 src = fetchurl {
1037 src = fetchurl {
1038 url = "https://pypi.python.org/packages/39/e8/a8e0b1fa65dd021d48fe21464f71783655f39a41f218293c1c590d54eb82/lxml-3.7.3.tar.gz";
1038 url = "https://pypi.python.org/packages/39/e8/a8e0b1fa65dd021d48fe21464f71783655f39a41f218293c1c590d54eb82/lxml-3.7.3.tar.gz";
1039 md5 = "075692ce442e69bbd604d44e21c02753";
1039 md5 = "075692ce442e69bbd604d44e21c02753";
1040 };
1040 };
1041 meta = {
1041 meta = {
1042 license = [ pkgs.lib.licenses.bsdOriginal ];
1042 license = [ pkgs.lib.licenses.bsdOriginal ];
1043 };
1043 };
1044 };
1044 };
1045 meld3 = super.buildPythonPackage {
1045 meld3 = super.buildPythonPackage {
1046 name = "meld3-1.0.2";
1046 name = "meld3-1.0.2";
1047 buildInputs = with self; [];
1047 buildInputs = with self; [];
1048 doCheck = false;
1048 doCheck = false;
1049 propagatedBuildInputs = with self; [];
1049 propagatedBuildInputs = with self; [];
1050 src = fetchurl {
1050 src = fetchurl {
1051 url = "https://pypi.python.org/packages/45/a0/317c6422b26c12fe0161e936fc35f36552069ba8e6f7ecbd99bbffe32a5f/meld3-1.0.2.tar.gz";
1051 url = "https://pypi.python.org/packages/45/a0/317c6422b26c12fe0161e936fc35f36552069ba8e6f7ecbd99bbffe32a5f/meld3-1.0.2.tar.gz";
1052 md5 = "3ccc78cd79cffd63a751ad7684c02c91";
1052 md5 = "3ccc78cd79cffd63a751ad7684c02c91";
1053 };
1053 };
1054 meta = {
1054 meta = {
1055 license = [ { fullName = "BSD-derived (http://www.repoze.org/LICENSE.txt)"; } ];
1055 license = [ { fullName = "BSD-derived (http://www.repoze.org/LICENSE.txt)"; } ];
1056 };
1056 };
1057 };
1057 };
1058 mistune = super.buildPythonPackage {
1058 mistune = super.buildPythonPackage {
1059 name = "mistune-0.7.4";
1059 name = "mistune-0.7.4";
1060 buildInputs = with self; [];
1060 buildInputs = with self; [];
1061 doCheck = false;
1061 doCheck = false;
1062 propagatedBuildInputs = with self; [];
1062 propagatedBuildInputs = with self; [];
1063 src = fetchurl {
1063 src = fetchurl {
1064 url = "https://pypi.python.org/packages/25/a4/12a584c0c59c9fed529f8b3c47ca8217c0cf8bcc5e1089d3256410cfbdbc/mistune-0.7.4.tar.gz";
1064 url = "https://pypi.python.org/packages/25/a4/12a584c0c59c9fed529f8b3c47ca8217c0cf8bcc5e1089d3256410cfbdbc/mistune-0.7.4.tar.gz";
1065 md5 = "92d01cb717e9e74429e9bde9d29ac43b";
1065 md5 = "92d01cb717e9e74429e9bde9d29ac43b";
1066 };
1066 };
1067 meta = {
1067 meta = {
1068 license = [ pkgs.lib.licenses.bsdOriginal ];
1068 license = [ pkgs.lib.licenses.bsdOriginal ];
1069 };
1069 };
1070 };
1070 };
1071 mock = super.buildPythonPackage {
1071 mock = super.buildPythonPackage {
1072 name = "mock-1.0.1";
1072 name = "mock-1.0.1";
1073 buildInputs = with self; [];
1073 buildInputs = with self; [];
1074 doCheck = false;
1074 doCheck = false;
1075 propagatedBuildInputs = with self; [];
1075 propagatedBuildInputs = with self; [];
1076 src = fetchurl {
1076 src = fetchurl {
1077 url = "https://pypi.python.org/packages/15/45/30273ee91feb60dabb8fbb2da7868520525f02cf910279b3047182feed80/mock-1.0.1.zip";
1077 url = "https://pypi.python.org/packages/15/45/30273ee91feb60dabb8fbb2da7868520525f02cf910279b3047182feed80/mock-1.0.1.zip";
1078 md5 = "869f08d003c289a97c1a6610faf5e913";
1078 md5 = "869f08d003c289a97c1a6610faf5e913";
1079 };
1079 };
1080 meta = {
1080 meta = {
1081 license = [ pkgs.lib.licenses.bsdOriginal ];
1081 license = [ pkgs.lib.licenses.bsdOriginal ];
1082 };
1082 };
1083 };
1083 };
1084 msgpack-python = super.buildPythonPackage {
1084 msgpack-python = super.buildPythonPackage {
1085 name = "msgpack-python-0.4.8";
1085 name = "msgpack-python-0.4.8";
1086 buildInputs = with self; [];
1086 buildInputs = with self; [];
1087 doCheck = false;
1087 doCheck = false;
1088 propagatedBuildInputs = with self; [];
1088 propagatedBuildInputs = with self; [];
1089 src = fetchurl {
1089 src = fetchurl {
1090 url = "https://pypi.python.org/packages/21/27/8a1d82041c7a2a51fcc73675875a5f9ea06c2663e02fcfeb708be1d081a0/msgpack-python-0.4.8.tar.gz";
1090 url = "https://pypi.python.org/packages/21/27/8a1d82041c7a2a51fcc73675875a5f9ea06c2663e02fcfeb708be1d081a0/msgpack-python-0.4.8.tar.gz";
1091 md5 = "dcd854fb41ee7584ebbf35e049e6be98";
1091 md5 = "dcd854fb41ee7584ebbf35e049e6be98";
1092 };
1092 };
1093 meta = {
1093 meta = {
1094 license = [ pkgs.lib.licenses.asl20 ];
1094 license = [ pkgs.lib.licenses.asl20 ];
1095 };
1095 };
1096 };
1096 };
1097 nbconvert = super.buildPythonPackage {
1097 nbconvert = super.buildPythonPackage {
1098 name = "nbconvert-5.1.1";
1098 name = "nbconvert-5.1.1";
1099 buildInputs = with self; [];
1099 buildInputs = with self; [];
1100 doCheck = false;
1100 doCheck = false;
1101 propagatedBuildInputs = with self; [mistune Jinja2 Pygments traitlets jupyter-core nbformat entrypoints bleach pandocfilters testpath];
1101 propagatedBuildInputs = with self; [mistune Jinja2 Pygments traitlets jupyter-core nbformat entrypoints bleach pandocfilters testpath];
1102 src = fetchurl {
1102 src = fetchurl {
1103 url = "https://pypi.python.org/packages/95/58/df1c91f1658ee5df19097f915a1e71c91fc824a708d82d2b2e35f8b80e9a/nbconvert-5.1.1.tar.gz";
1103 url = "https://pypi.python.org/packages/95/58/df1c91f1658ee5df19097f915a1e71c91fc824a708d82d2b2e35f8b80e9a/nbconvert-5.1.1.tar.gz";
1104 md5 = "d0263fb03a44db2f94eea09a608ed813";
1104 md5 = "d0263fb03a44db2f94eea09a608ed813";
1105 };
1105 };
1106 meta = {
1106 meta = {
1107 license = [ pkgs.lib.licenses.bsdOriginal ];
1107 license = [ pkgs.lib.licenses.bsdOriginal ];
1108 };
1108 };
1109 };
1109 };
1110 nbformat = super.buildPythonPackage {
1110 nbformat = super.buildPythonPackage {
1111 name = "nbformat-4.3.0";
1111 name = "nbformat-4.3.0";
1112 buildInputs = with self; [];
1112 buildInputs = with self; [];
1113 doCheck = false;
1113 doCheck = false;
1114 propagatedBuildInputs = with self; [ipython-genutils traitlets jsonschema jupyter-core];
1114 propagatedBuildInputs = with self; [ipython-genutils traitlets jsonschema jupyter-core];
1115 src = fetchurl {
1115 src = fetchurl {
1116 url = "https://pypi.python.org/packages/f9/c5/89df4abf906f766727f976e170caa85b4f1c1d1feb1f45d716016e68e19f/nbformat-4.3.0.tar.gz";
1116 url = "https://pypi.python.org/packages/f9/c5/89df4abf906f766727f976e170caa85b4f1c1d1feb1f45d716016e68e19f/nbformat-4.3.0.tar.gz";
1117 md5 = "9a00d20425914cd5ba5f97769d9963ca";
1117 md5 = "9a00d20425914cd5ba5f97769d9963ca";
1118 };
1118 };
1119 meta = {
1119 meta = {
1120 license = [ pkgs.lib.licenses.bsdOriginal ];
1120 license = [ pkgs.lib.licenses.bsdOriginal ];
1121 };
1121 };
1122 };
1122 };
1123 nose = super.buildPythonPackage {
1123 nose = super.buildPythonPackage {
1124 name = "nose-1.3.6";
1124 name = "nose-1.3.6";
1125 buildInputs = with self; [];
1125 buildInputs = with self; [];
1126 doCheck = false;
1126 doCheck = false;
1127 propagatedBuildInputs = with self; [];
1127 propagatedBuildInputs = with self; [];
1128 src = fetchurl {
1128 src = fetchurl {
1129 url = "https://pypi.python.org/packages/70/c7/469e68148d17a0d3db5ed49150242fd70a74a8147b8f3f8b87776e028d99/nose-1.3.6.tar.gz";
1129 url = "https://pypi.python.org/packages/70/c7/469e68148d17a0d3db5ed49150242fd70a74a8147b8f3f8b87776e028d99/nose-1.3.6.tar.gz";
1130 md5 = "0ca546d81ca8309080fc80cb389e7a16";
1130 md5 = "0ca546d81ca8309080fc80cb389e7a16";
1131 };
1131 };
1132 meta = {
1132 meta = {
1133 license = [ { fullName = "GNU Library or Lesser General Public License (LGPL)"; } { fullName = "GNU LGPL"; } ];
1133 license = [ { fullName = "GNU Library or Lesser General Public License (LGPL)"; } { fullName = "GNU LGPL"; } ];
1134 };
1134 };
1135 };
1135 };
1136 objgraph = super.buildPythonPackage {
1136 objgraph = super.buildPythonPackage {
1137 name = "objgraph-3.1.0";
1137 name = "objgraph-3.1.0";
1138 buildInputs = with self; [];
1138 buildInputs = with self; [];
1139 doCheck = false;
1139 doCheck = false;
1140 propagatedBuildInputs = with self; [graphviz];
1140 propagatedBuildInputs = with self; [graphviz];
1141 src = fetchurl {
1141 src = fetchurl {
1142 url = "https://pypi.python.org/packages/f4/b3/082e54e62094cb2ec84f8d5a49e0142cef99016491cecba83309cff920ae/objgraph-3.1.0.tar.gz";
1142 url = "https://pypi.python.org/packages/f4/b3/082e54e62094cb2ec84f8d5a49e0142cef99016491cecba83309cff920ae/objgraph-3.1.0.tar.gz";
1143 md5 = "eddbd96039796bfbd13eee403701e64a";
1143 md5 = "eddbd96039796bfbd13eee403701e64a";
1144 };
1144 };
1145 meta = {
1145 meta = {
1146 license = [ pkgs.lib.licenses.mit ];
1146 license = [ pkgs.lib.licenses.mit ];
1147 };
1147 };
1148 };
1148 };
1149 packaging = super.buildPythonPackage {
1149 packaging = super.buildPythonPackage {
1150 name = "packaging-15.2";
1150 name = "packaging-15.2";
1151 buildInputs = with self; [];
1151 buildInputs = with self; [];
1152 doCheck = false;
1152 doCheck = false;
1153 propagatedBuildInputs = with self; [];
1153 propagatedBuildInputs = with self; [];
1154 src = fetchurl {
1154 src = fetchurl {
1155 url = "https://pypi.python.org/packages/24/c4/185da1304f07047dc9e0c46c31db75c0351bd73458ac3efad7da3dbcfbe1/packaging-15.2.tar.gz";
1155 url = "https://pypi.python.org/packages/24/c4/185da1304f07047dc9e0c46c31db75c0351bd73458ac3efad7da3dbcfbe1/packaging-15.2.tar.gz";
1156 md5 = "c16093476f6ced42128bf610e5db3784";
1156 md5 = "c16093476f6ced42128bf610e5db3784";
1157 };
1157 };
1158 meta = {
1158 meta = {
1159 license = [ pkgs.lib.licenses.asl20 ];
1159 license = [ pkgs.lib.licenses.asl20 ];
1160 };
1160 };
1161 };
1161 };
1162 pandocfilters = super.buildPythonPackage {
1162 pandocfilters = super.buildPythonPackage {
1163 name = "pandocfilters-1.4.1";
1163 name = "pandocfilters-1.4.1";
1164 buildInputs = with self; [];
1164 buildInputs = with self; [];
1165 doCheck = false;
1165 doCheck = false;
1166 propagatedBuildInputs = with self; [];
1166 propagatedBuildInputs = with self; [];
1167 src = fetchurl {
1167 src = fetchurl {
1168 url = "https://pypi.python.org/packages/e3/1f/21d1b7e8ca571e80b796c758d361fdf5554335ff138158654684bc5401d8/pandocfilters-1.4.1.tar.gz";
1168 url = "https://pypi.python.org/packages/e3/1f/21d1b7e8ca571e80b796c758d361fdf5554335ff138158654684bc5401d8/pandocfilters-1.4.1.tar.gz";
1169 md5 = "7680d9f9ec07397dd17f380ee3818b9d";
1169 md5 = "7680d9f9ec07397dd17f380ee3818b9d";
1170 };
1170 };
1171 meta = {
1171 meta = {
1172 license = [ pkgs.lib.licenses.bsdOriginal ];
1172 license = [ pkgs.lib.licenses.bsdOriginal ];
1173 };
1173 };
1174 };
1174 };
1175 paramiko = super.buildPythonPackage {
1176 name = "paramiko-1.15.1";
1177 buildInputs = with self; [];
1178 doCheck = false;
1179 propagatedBuildInputs = with self; [pycrypto ecdsa];
1180 src = fetchurl {
1181 url = "https://pypi.python.org/packages/04/2b/a22d2a560c1951abbbf95a0628e245945565f70dc082d9e784666887222c/paramiko-1.15.1.tar.gz";
1182 md5 = "48c274c3f9b1282932567b21f6acf3b5";
1183 };
1184 meta = {
1185 license = [ { fullName = "LGPL"; } { fullName = "GNU Library or Lesser General Public License (LGPL)"; } ];
1186 };
1187 };
1188 pathlib2 = super.buildPythonPackage {
1175 pathlib2 = super.buildPythonPackage {
1189 name = "pathlib2-2.3.0";
1176 name = "pathlib2-2.3.0";
1190 buildInputs = with self; [];
1177 buildInputs = with self; [];
1191 doCheck = false;
1178 doCheck = false;
1192 propagatedBuildInputs = with self; [six scandir];
1179 propagatedBuildInputs = with self; [six scandir];
1193 src = fetchurl {
1180 src = fetchurl {
1194 url = "https://pypi.python.org/packages/a1/14/df0deb867c2733f7d857523c10942b3d6612a1b222502fdffa9439943dfb/pathlib2-2.3.0.tar.gz";
1181 url = "https://pypi.python.org/packages/a1/14/df0deb867c2733f7d857523c10942b3d6612a1b222502fdffa9439943dfb/pathlib2-2.3.0.tar.gz";
1195 md5 = "89c90409d11fd5947966b6a30a47d18c";
1182 md5 = "89c90409d11fd5947966b6a30a47d18c";
1196 };
1183 };
1197 meta = {
1184 meta = {
1198 license = [ pkgs.lib.licenses.mit ];
1185 license = [ pkgs.lib.licenses.mit ];
1199 };
1186 };
1200 };
1187 };
1201 peppercorn = super.buildPythonPackage {
1188 peppercorn = super.buildPythonPackage {
1202 name = "peppercorn-0.5";
1189 name = "peppercorn-0.5";
1203 buildInputs = with self; [];
1190 buildInputs = with self; [];
1204 doCheck = false;
1191 doCheck = false;
1205 propagatedBuildInputs = with self; [];
1192 propagatedBuildInputs = with self; [];
1206 src = fetchurl {
1193 src = fetchurl {
1207 url = "https://pypi.python.org/packages/45/ec/a62ec317d1324a01567c5221b420742f094f05ee48097e5157d32be3755c/peppercorn-0.5.tar.gz";
1194 url = "https://pypi.python.org/packages/45/ec/a62ec317d1324a01567c5221b420742f094f05ee48097e5157d32be3755c/peppercorn-0.5.tar.gz";
1208 md5 = "f08efbca5790019ab45d76b7244abd40";
1195 md5 = "f08efbca5790019ab45d76b7244abd40";
1209 };
1196 };
1210 meta = {
1197 meta = {
1211 license = [ { fullName = "BSD-derived (http://www.repoze.org/LICENSE.txt)"; } ];
1198 license = [ { fullName = "BSD-derived (http://www.repoze.org/LICENSE.txt)"; } ];
1212 };
1199 };
1213 };
1200 };
1214 pexpect = super.buildPythonPackage {
1201 pexpect = super.buildPythonPackage {
1215 name = "pexpect-4.2.1";
1202 name = "pexpect-4.2.1";
1216 buildInputs = with self; [];
1203 buildInputs = with self; [];
1217 doCheck = false;
1204 doCheck = false;
1218 propagatedBuildInputs = with self; [ptyprocess];
1205 propagatedBuildInputs = with self; [ptyprocess];
1219 src = fetchurl {
1206 src = fetchurl {
1220 url = "https://pypi.python.org/packages/e8/13/d0b0599099d6cd23663043a2a0bb7c61e58c6ba359b2656e6fb000ef5b98/pexpect-4.2.1.tar.gz";
1207 url = "https://pypi.python.org/packages/e8/13/d0b0599099d6cd23663043a2a0bb7c61e58c6ba359b2656e6fb000ef5b98/pexpect-4.2.1.tar.gz";
1221 md5 = "3694410001a99dff83f0b500a1ca1c95";
1208 md5 = "3694410001a99dff83f0b500a1ca1c95";
1222 };
1209 };
1223 meta = {
1210 meta = {
1224 license = [ pkgs.lib.licenses.isc { fullName = "ISC License (ISCL)"; } ];
1211 license = [ pkgs.lib.licenses.isc { fullName = "ISC License (ISCL)"; } ];
1225 };
1212 };
1226 };
1213 };
1227 pickleshare = super.buildPythonPackage {
1214 pickleshare = super.buildPythonPackage {
1228 name = "pickleshare-0.7.4";
1215 name = "pickleshare-0.7.4";
1229 buildInputs = with self; [];
1216 buildInputs = with self; [];
1230 doCheck = false;
1217 doCheck = false;
1231 propagatedBuildInputs = with self; [pathlib2];
1218 propagatedBuildInputs = with self; [pathlib2];
1232 src = fetchurl {
1219 src = fetchurl {
1233 url = "https://pypi.python.org/packages/69/fe/dd137d84daa0fd13a709e448138e310d9ea93070620c9db5454e234af525/pickleshare-0.7.4.tar.gz";
1220 url = "https://pypi.python.org/packages/69/fe/dd137d84daa0fd13a709e448138e310d9ea93070620c9db5454e234af525/pickleshare-0.7.4.tar.gz";
1234 md5 = "6a9e5dd8dfc023031f6b7b3f824cab12";
1221 md5 = "6a9e5dd8dfc023031f6b7b3f824cab12";
1235 };
1222 };
1236 meta = {
1223 meta = {
1237 license = [ pkgs.lib.licenses.mit ];
1224 license = [ pkgs.lib.licenses.mit ];
1238 };
1225 };
1239 };
1226 };
1240 plaster = super.buildPythonPackage {
1227 plaster = super.buildPythonPackage {
1241 name = "plaster-0.5";
1228 name = "plaster-0.5";
1242 buildInputs = with self; [];
1229 buildInputs = with self; [];
1243 doCheck = false;
1230 doCheck = false;
1244 propagatedBuildInputs = with self; [setuptools];
1231 propagatedBuildInputs = with self; [setuptools];
1245 src = fetchurl {
1232 src = fetchurl {
1246 url = "https://pypi.python.org/packages/99/b3/d7ca1fe31d2b56dba68a238721fda6820770f9c2a3de17a582d4b5b2edcc/plaster-0.5.tar.gz";
1233 url = "https://pypi.python.org/packages/99/b3/d7ca1fe31d2b56dba68a238721fda6820770f9c2a3de17a582d4b5b2edcc/plaster-0.5.tar.gz";
1247 md5 = "c59345a67a860cfcaa1bd6a81451399d";
1234 md5 = "c59345a67a860cfcaa1bd6a81451399d";
1248 };
1235 };
1249 meta = {
1236 meta = {
1250 license = [ pkgs.lib.licenses.mit ];
1237 license = [ pkgs.lib.licenses.mit ];
1251 };
1238 };
1252 };
1239 };
1253 plaster-pastedeploy = super.buildPythonPackage {
1240 plaster-pastedeploy = super.buildPythonPackage {
1254 name = "plaster-pastedeploy-0.4.1";
1241 name = "plaster-pastedeploy-0.4.1";
1255 buildInputs = with self; [];
1242 buildInputs = with self; [];
1256 doCheck = false;
1243 doCheck = false;
1257 propagatedBuildInputs = with self; [PasteDeploy plaster];
1244 propagatedBuildInputs = with self; [PasteDeploy plaster];
1258 src = fetchurl {
1245 src = fetchurl {
1259 url = "https://pypi.python.org/packages/9d/6e/f8be01ed41c94e6c54ac97cf2eb142a702aae0c8cce31c846f785e525b40/plaster_pastedeploy-0.4.1.tar.gz";
1246 url = "https://pypi.python.org/packages/9d/6e/f8be01ed41c94e6c54ac97cf2eb142a702aae0c8cce31c846f785e525b40/plaster_pastedeploy-0.4.1.tar.gz";
1260 md5 = "f48d5344b922e56c4978eebf1cd2e0d3";
1247 md5 = "f48d5344b922e56c4978eebf1cd2e0d3";
1261 };
1248 };
1262 meta = {
1249 meta = {
1263 license = [ pkgs.lib.licenses.mit ];
1250 license = [ pkgs.lib.licenses.mit ];
1264 };
1251 };
1265 };
1252 };
1266 prompt-toolkit = super.buildPythonPackage {
1253 prompt-toolkit = super.buildPythonPackage {
1267 name = "prompt-toolkit-1.0.14";
1254 name = "prompt-toolkit-1.0.14";
1268 buildInputs = with self; [];
1255 buildInputs = with self; [];
1269 doCheck = false;
1256 doCheck = false;
1270 propagatedBuildInputs = with self; [six wcwidth];
1257 propagatedBuildInputs = with self; [six wcwidth];
1271 src = fetchurl {
1258 src = fetchurl {
1272 url = "https://pypi.python.org/packages/55/56/8c39509b614bda53e638b7500f12577d663ac1b868aef53426fc6a26c3f5/prompt_toolkit-1.0.14.tar.gz";
1259 url = "https://pypi.python.org/packages/55/56/8c39509b614bda53e638b7500f12577d663ac1b868aef53426fc6a26c3f5/prompt_toolkit-1.0.14.tar.gz";
1273 md5 = "f24061ae133ed32c6b764e92bd48c496";
1260 md5 = "f24061ae133ed32c6b764e92bd48c496";
1274 };
1261 };
1275 meta = {
1262 meta = {
1276 license = [ pkgs.lib.licenses.bsdOriginal ];
1263 license = [ pkgs.lib.licenses.bsdOriginal ];
1277 };
1264 };
1278 };
1265 };
1279 psutil = super.buildPythonPackage {
1266 psutil = super.buildPythonPackage {
1280 name = "psutil-4.3.1";
1267 name = "psutil-4.3.1";
1281 buildInputs = with self; [];
1268 buildInputs = with self; [];
1282 doCheck = false;
1269 doCheck = false;
1283 propagatedBuildInputs = with self; [];
1270 propagatedBuildInputs = with self; [];
1284 src = fetchurl {
1271 src = fetchurl {
1285 url = "https://pypi.python.org/packages/78/cc/f267a1371f229bf16db6a4e604428c3b032b823b83155bd33cef45e49a53/psutil-4.3.1.tar.gz";
1272 url = "https://pypi.python.org/packages/78/cc/f267a1371f229bf16db6a4e604428c3b032b823b83155bd33cef45e49a53/psutil-4.3.1.tar.gz";
1286 md5 = "199a366dba829c88bddaf5b41d19ddc0";
1273 md5 = "199a366dba829c88bddaf5b41d19ddc0";
1287 };
1274 };
1288 meta = {
1275 meta = {
1289 license = [ pkgs.lib.licenses.bsdOriginal ];
1276 license = [ pkgs.lib.licenses.bsdOriginal ];
1290 };
1277 };
1291 };
1278 };
1292 psycopg2 = super.buildPythonPackage {
1279 psycopg2 = super.buildPythonPackage {
1293 name = "psycopg2-2.7.1";
1280 name = "psycopg2-2.7.1";
1294 buildInputs = with self; [];
1281 buildInputs = with self; [];
1295 doCheck = false;
1282 doCheck = false;
1296 propagatedBuildInputs = with self; [];
1283 propagatedBuildInputs = with self; [];
1297 src = fetchurl {
1284 src = fetchurl {
1298 url = "https://pypi.python.org/packages/f8/e9/5793369ce8a41bf5467623ded8d59a434dfef9c136351aca4e70c2657ba0/psycopg2-2.7.1.tar.gz";
1285 url = "https://pypi.python.org/packages/f8/e9/5793369ce8a41bf5467623ded8d59a434dfef9c136351aca4e70c2657ba0/psycopg2-2.7.1.tar.gz";
1299 md5 = "67848ac33af88336046802f6ef7081f3";
1286 md5 = "67848ac33af88336046802f6ef7081f3";
1300 };
1287 };
1301 meta = {
1288 meta = {
1302 license = [ pkgs.lib.licenses.zpt21 { fullName = "GNU Library or Lesser General Public License (LGPL)"; } { fullName = "LGPL with exceptions or ZPL"; } ];
1289 license = [ pkgs.lib.licenses.zpt21 { fullName = "GNU Library or Lesser General Public License (LGPL)"; } { fullName = "LGPL with exceptions or ZPL"; } ];
1303 };
1290 };
1304 };
1291 };
1305 ptyprocess = super.buildPythonPackage {
1292 ptyprocess = super.buildPythonPackage {
1306 name = "ptyprocess-0.5.2";
1293 name = "ptyprocess-0.5.2";
1307 buildInputs = with self; [];
1294 buildInputs = with self; [];
1308 doCheck = false;
1295 doCheck = false;
1309 propagatedBuildInputs = with self; [];
1296 propagatedBuildInputs = with self; [];
1310 src = fetchurl {
1297 src = fetchurl {
1311 url = "https://pypi.python.org/packages/51/83/5d07dc35534640b06f9d9f1a1d2bc2513fb9cc7595a1b0e28ae5477056ce/ptyprocess-0.5.2.tar.gz";
1298 url = "https://pypi.python.org/packages/51/83/5d07dc35534640b06f9d9f1a1d2bc2513fb9cc7595a1b0e28ae5477056ce/ptyprocess-0.5.2.tar.gz";
1312 md5 = "d3b8febae1b8c53b054bd818d0bb8665";
1299 md5 = "d3b8febae1b8c53b054bd818d0bb8665";
1313 };
1300 };
1314 meta = {
1301 meta = {
1315 license = [ ];
1302 license = [ ];
1316 };
1303 };
1317 };
1304 };
1318 py = super.buildPythonPackage {
1305 py = super.buildPythonPackage {
1319 name = "py-1.4.34";
1306 name = "py-1.4.34";
1320 buildInputs = with self; [];
1307 buildInputs = with self; [];
1321 doCheck = false;
1308 doCheck = false;
1322 propagatedBuildInputs = with self; [];
1309 propagatedBuildInputs = with self; [];
1323 src = fetchurl {
1310 src = fetchurl {
1324 url = "https://pypi.python.org/packages/68/35/58572278f1c097b403879c1e9369069633d1cbad5239b9057944bb764782/py-1.4.34.tar.gz";
1311 url = "https://pypi.python.org/packages/68/35/58572278f1c097b403879c1e9369069633d1cbad5239b9057944bb764782/py-1.4.34.tar.gz";
1325 md5 = "d9c3d8f734b0819ff48e355d77bf1730";
1312 md5 = "d9c3d8f734b0819ff48e355d77bf1730";
1326 };
1313 };
1327 meta = {
1314 meta = {
1328 license = [ pkgs.lib.licenses.mit ];
1315 license = [ pkgs.lib.licenses.mit ];
1329 };
1316 };
1330 };
1317 };
1331 py-bcrypt = super.buildPythonPackage {
1318 py-bcrypt = super.buildPythonPackage {
1332 name = "py-bcrypt-0.4";
1319 name = "py-bcrypt-0.4";
1333 buildInputs = with self; [];
1320 buildInputs = with self; [];
1334 doCheck = false;
1321 doCheck = false;
1335 propagatedBuildInputs = with self; [];
1322 propagatedBuildInputs = with self; [];
1336 src = fetchurl {
1323 src = fetchurl {
1337 url = "https://pypi.python.org/packages/68/b1/1c3068c5c4d2e35c48b38dcc865301ebfdf45f54507086ac65ced1fd3b3d/py-bcrypt-0.4.tar.gz";
1324 url = "https://pypi.python.org/packages/68/b1/1c3068c5c4d2e35c48b38dcc865301ebfdf45f54507086ac65ced1fd3b3d/py-bcrypt-0.4.tar.gz";
1338 md5 = "dd8b367d6b716a2ea2e72392525f4e36";
1325 md5 = "dd8b367d6b716a2ea2e72392525f4e36";
1339 };
1326 };
1340 meta = {
1327 meta = {
1341 license = [ pkgs.lib.licenses.bsdOriginal ];
1328 license = [ pkgs.lib.licenses.bsdOriginal ];
1342 };
1329 };
1343 };
1330 };
1344 py-gfm = super.buildPythonPackage {
1331 py-gfm = super.buildPythonPackage {
1345 name = "py-gfm-0.1.3";
1332 name = "py-gfm-0.1.3";
1346 buildInputs = with self; [];
1333 buildInputs = with self; [];
1347 doCheck = false;
1334 doCheck = false;
1348 propagatedBuildInputs = with self; [setuptools Markdown];
1335 propagatedBuildInputs = with self; [setuptools Markdown];
1349 src = fetchurl {
1336 src = fetchurl {
1350 url = "https://code.rhodecode.com/upstream/py-gfm/archive/0d66a19bc16e3d49de273c0f797d4e4781e8c0f2.tar.gz?md5=0d0d5385bfb629eea636a80b9c2bfd16";
1337 url = "https://code.rhodecode.com/upstream/py-gfm/archive/0d66a19bc16e3d49de273c0f797d4e4781e8c0f2.tar.gz?md5=0d0d5385bfb629eea636a80b9c2bfd16";
1351 md5 = "0d0d5385bfb629eea636a80b9c2bfd16";
1338 md5 = "0d0d5385bfb629eea636a80b9c2bfd16";
1352 };
1339 };
1353 meta = {
1340 meta = {
1354 license = [ pkgs.lib.licenses.bsdOriginal ];
1341 license = [ pkgs.lib.licenses.bsdOriginal ];
1355 };
1342 };
1356 };
1343 };
1357 pycrypto = super.buildPythonPackage {
1344 pycrypto = super.buildPythonPackage {
1358 name = "pycrypto-2.6.1";
1345 name = "pycrypto-2.6.1";
1359 buildInputs = with self; [];
1346 buildInputs = with self; [];
1360 doCheck = false;
1347 doCheck = false;
1361 propagatedBuildInputs = with self; [];
1348 propagatedBuildInputs = with self; [];
1362 src = fetchurl {
1349 src = fetchurl {
1363 url = "https://pypi.python.org/packages/60/db/645aa9af249f059cc3a368b118de33889219e0362141e75d4eaf6f80f163/pycrypto-2.6.1.tar.gz";
1350 url = "https://pypi.python.org/packages/60/db/645aa9af249f059cc3a368b118de33889219e0362141e75d4eaf6f80f163/pycrypto-2.6.1.tar.gz";
1364 md5 = "55a61a054aa66812daf5161a0d5d7eda";
1351 md5 = "55a61a054aa66812daf5161a0d5d7eda";
1365 };
1352 };
1366 meta = {
1353 meta = {
1367 license = [ pkgs.lib.licenses.publicDomain ];
1354 license = [ pkgs.lib.licenses.publicDomain ];
1368 };
1355 };
1369 };
1356 };
1370 pycurl = super.buildPythonPackage {
1357 pycurl = super.buildPythonPackage {
1371 name = "pycurl-7.19.5";
1358 name = "pycurl-7.19.5";
1372 buildInputs = with self; [];
1359 buildInputs = with self; [];
1373 doCheck = false;
1360 doCheck = false;
1374 propagatedBuildInputs = with self; [];
1361 propagatedBuildInputs = with self; [];
1375 src = fetchurl {
1362 src = fetchurl {
1376 url = "https://pypi.python.org/packages/6c/48/13bad289ef6f4869b1d8fc11ae54de8cfb3cc4a2eb9f7419c506f763be46/pycurl-7.19.5.tar.gz";
1363 url = "https://pypi.python.org/packages/6c/48/13bad289ef6f4869b1d8fc11ae54de8cfb3cc4a2eb9f7419c506f763be46/pycurl-7.19.5.tar.gz";
1377 md5 = "47b4eac84118e2606658122104e62072";
1364 md5 = "47b4eac84118e2606658122104e62072";
1378 };
1365 };
1379 meta = {
1366 meta = {
1380 license = [ pkgs.lib.licenses.mit { fullName = "LGPL/MIT"; } { fullName = "GNU Library or Lesser General Public License (LGPL)"; } ];
1367 license = [ pkgs.lib.licenses.mit { fullName = "LGPL/MIT"; } { fullName = "GNU Library or Lesser General Public License (LGPL)"; } ];
1381 };
1368 };
1382 };
1369 };
1383 pyflakes = super.buildPythonPackage {
1370 pyflakes = super.buildPythonPackage {
1384 name = "pyflakes-0.8.1";
1371 name = "pyflakes-0.8.1";
1385 buildInputs = with self; [];
1372 buildInputs = with self; [];
1386 doCheck = false;
1373 doCheck = false;
1387 propagatedBuildInputs = with self; [];
1374 propagatedBuildInputs = with self; [];
1388 src = fetchurl {
1375 src = fetchurl {
1389 url = "https://pypi.python.org/packages/75/22/a90ec0252f4f87f3ffb6336504de71fe16a49d69c4538dae2f12b9360a38/pyflakes-0.8.1.tar.gz";
1376 url = "https://pypi.python.org/packages/75/22/a90ec0252f4f87f3ffb6336504de71fe16a49d69c4538dae2f12b9360a38/pyflakes-0.8.1.tar.gz";
1390 md5 = "905fe91ad14b912807e8fdc2ac2e2c23";
1377 md5 = "905fe91ad14b912807e8fdc2ac2e2c23";
1391 };
1378 };
1392 meta = {
1379 meta = {
1393 license = [ pkgs.lib.licenses.mit ];
1380 license = [ pkgs.lib.licenses.mit ];
1394 };
1381 };
1395 };
1382 };
1396 pygments-markdown-lexer = super.buildPythonPackage {
1383 pygments-markdown-lexer = super.buildPythonPackage {
1397 name = "pygments-markdown-lexer-0.1.0.dev39";
1384 name = "pygments-markdown-lexer-0.1.0.dev39";
1398 buildInputs = with self; [];
1385 buildInputs = with self; [];
1399 doCheck = false;
1386 doCheck = false;
1400 propagatedBuildInputs = with self; [Pygments];
1387 propagatedBuildInputs = with self; [Pygments];
1401 src = fetchurl {
1388 src = fetchurl {
1402 url = "https://pypi.python.org/packages/c3/12/674cdee66635d638cedb2c5d9c85ce507b7b2f91bdba29e482f1b1160ff6/pygments-markdown-lexer-0.1.0.dev39.zip";
1389 url = "https://pypi.python.org/packages/c3/12/674cdee66635d638cedb2c5d9c85ce507b7b2f91bdba29e482f1b1160ff6/pygments-markdown-lexer-0.1.0.dev39.zip";
1403 md5 = "6360fe0f6d1f896e35b7a0142ce6459c";
1390 md5 = "6360fe0f6d1f896e35b7a0142ce6459c";
1404 };
1391 };
1405 meta = {
1392 meta = {
1406 license = [ pkgs.lib.licenses.asl20 ];
1393 license = [ pkgs.lib.licenses.asl20 ];
1407 };
1394 };
1408 };
1395 };
1409 pyparsing = super.buildPythonPackage {
1396 pyparsing = super.buildPythonPackage {
1410 name = "pyparsing-1.5.7";
1397 name = "pyparsing-1.5.7";
1411 buildInputs = with self; [];
1398 buildInputs = with self; [];
1412 doCheck = false;
1399 doCheck = false;
1413 propagatedBuildInputs = with self; [];
1400 propagatedBuildInputs = with self; [];
1414 src = fetchurl {
1401 src = fetchurl {
1415 url = "https://pypi.python.org/packages/2e/26/e8fb5b4256a5f5036be7ce115ef8db8d06bc537becfbdc46c6af008314ee/pyparsing-1.5.7.zip";
1402 url = "https://pypi.python.org/packages/2e/26/e8fb5b4256a5f5036be7ce115ef8db8d06bc537becfbdc46c6af008314ee/pyparsing-1.5.7.zip";
1416 md5 = "b86854857a368d6ccb4d5b6e76d0637f";
1403 md5 = "b86854857a368d6ccb4d5b6e76d0637f";
1417 };
1404 };
1418 meta = {
1405 meta = {
1419 license = [ pkgs.lib.licenses.mit ];
1406 license = [ pkgs.lib.licenses.mit ];
1420 };
1407 };
1421 };
1408 };
1422 pyramid = super.buildPythonPackage {
1409 pyramid = super.buildPythonPackage {
1423 name = "pyramid-1.9";
1410 name = "pyramid-1.9";
1424 buildInputs = with self; [];
1411 buildInputs = with self; [];
1425 doCheck = false;
1412 doCheck = false;
1426 propagatedBuildInputs = with self; [setuptools WebOb repoze.lru zope.interface zope.deprecation venusian translationstring PasteDeploy plaster plaster-pastedeploy hupper];
1413 propagatedBuildInputs = with self; [setuptools WebOb repoze.lru zope.interface zope.deprecation venusian translationstring PasteDeploy plaster plaster-pastedeploy hupper];
1427 src = fetchurl {
1414 src = fetchurl {
1428 url = "https://pypi.python.org/packages/b0/73/715321e129334f3e41430bede877620175a63ed075fd5d1fd2c25b7cb121/pyramid-1.9.tar.gz";
1415 url = "https://pypi.python.org/packages/b0/73/715321e129334f3e41430bede877620175a63ed075fd5d1fd2c25b7cb121/pyramid-1.9.tar.gz";
1429 md5 = "aa6c7c568f83151af51eb053ac633bc4";
1416 md5 = "aa6c7c568f83151af51eb053ac633bc4";
1430 };
1417 };
1431 meta = {
1418 meta = {
1432 license = [ { fullName = "Repoze Public License"; } { fullName = "BSD-derived (http://www.repoze.org/LICENSE.txt)"; } ];
1419 license = [ { fullName = "Repoze Public License"; } { fullName = "BSD-derived (http://www.repoze.org/LICENSE.txt)"; } ];
1433 };
1420 };
1434 };
1421 };
1435 pyramid-beaker = super.buildPythonPackage {
1422 pyramid-beaker = super.buildPythonPackage {
1436 name = "pyramid-beaker-0.8";
1423 name = "pyramid-beaker-0.8";
1437 buildInputs = with self; [];
1424 buildInputs = with self; [];
1438 doCheck = false;
1425 doCheck = false;
1439 propagatedBuildInputs = with self; [pyramid Beaker];
1426 propagatedBuildInputs = with self; [pyramid Beaker];
1440 src = fetchurl {
1427 src = fetchurl {
1441 url = "https://pypi.python.org/packages/d9/6e/b85426e00fd3d57f4545f74e1c3828552d8700f13ededeef9233f7bca8be/pyramid_beaker-0.8.tar.gz";
1428 url = "https://pypi.python.org/packages/d9/6e/b85426e00fd3d57f4545f74e1c3828552d8700f13ededeef9233f7bca8be/pyramid_beaker-0.8.tar.gz";
1442 md5 = "22f14be31b06549f80890e2c63a93834";
1429 md5 = "22f14be31b06549f80890e2c63a93834";
1443 };
1430 };
1444 meta = {
1431 meta = {
1445 license = [ { fullName = "BSD-derived (http://www.repoze.org/LICENSE.txt)"; } ];
1432 license = [ { fullName = "BSD-derived (http://www.repoze.org/LICENSE.txt)"; } ];
1446 };
1433 };
1447 };
1434 };
1448 pyramid-debugtoolbar = super.buildPythonPackage {
1435 pyramid-debugtoolbar = super.buildPythonPackage {
1449 name = "pyramid-debugtoolbar-4.2.1";
1436 name = "pyramid-debugtoolbar-4.2.1";
1450 buildInputs = with self; [];
1437 buildInputs = with self; [];
1451 doCheck = false;
1438 doCheck = false;
1452 propagatedBuildInputs = with self; [pyramid pyramid-mako repoze.lru Pygments ipaddress];
1439 propagatedBuildInputs = with self; [pyramid pyramid-mako repoze.lru Pygments ipaddress];
1453 src = fetchurl {
1440 src = fetchurl {
1454 url = "https://pypi.python.org/packages/db/26/94620b7752936e2cd74838263ff366db9b454f7394bfb62d1eb2f84b29c1/pyramid_debugtoolbar-4.2.1.tar.gz";
1441 url = "https://pypi.python.org/packages/db/26/94620b7752936e2cd74838263ff366db9b454f7394bfb62d1eb2f84b29c1/pyramid_debugtoolbar-4.2.1.tar.gz";
1455 md5 = "3dfaced2fab1644ff5284017be9d92b9";
1442 md5 = "3dfaced2fab1644ff5284017be9d92b9";
1456 };
1443 };
1457 meta = {
1444 meta = {
1458 license = [ { fullName = "Repoze Public License"; } pkgs.lib.licenses.bsdOriginal ];
1445 license = [ { fullName = "Repoze Public License"; } pkgs.lib.licenses.bsdOriginal ];
1459 };
1446 };
1460 };
1447 };
1461 pyramid-jinja2 = super.buildPythonPackage {
1448 pyramid-jinja2 = super.buildPythonPackage {
1462 name = "pyramid-jinja2-2.5";
1449 name = "pyramid-jinja2-2.5";
1463 buildInputs = with self; [];
1450 buildInputs = with self; [];
1464 doCheck = false;
1451 doCheck = false;
1465 propagatedBuildInputs = with self; [pyramid zope.deprecation Jinja2 MarkupSafe];
1452 propagatedBuildInputs = with self; [pyramid zope.deprecation Jinja2 MarkupSafe];
1466 src = fetchurl {
1453 src = fetchurl {
1467 url = "https://pypi.python.org/packages/a1/80/595e26ffab7deba7208676b6936b7e5a721875710f982e59899013cae1ed/pyramid_jinja2-2.5.tar.gz";
1454 url = "https://pypi.python.org/packages/a1/80/595e26ffab7deba7208676b6936b7e5a721875710f982e59899013cae1ed/pyramid_jinja2-2.5.tar.gz";
1468 md5 = "07cb6547204ac5e6f0b22a954ccee928";
1455 md5 = "07cb6547204ac5e6f0b22a954ccee928";
1469 };
1456 };
1470 meta = {
1457 meta = {
1471 license = [ { fullName = "Repoze Public License"; } { fullName = "BSD-derived (http://www.repoze.org/LICENSE.txt)"; } ];
1458 license = [ { fullName = "Repoze Public License"; } { fullName = "BSD-derived (http://www.repoze.org/LICENSE.txt)"; } ];
1472 };
1459 };
1473 };
1460 };
1474 pyramid-mako = super.buildPythonPackage {
1461 pyramid-mako = super.buildPythonPackage {
1475 name = "pyramid-mako-1.0.2";
1462 name = "pyramid-mako-1.0.2";
1476 buildInputs = with self; [];
1463 buildInputs = with self; [];
1477 doCheck = false;
1464 doCheck = false;
1478 propagatedBuildInputs = with self; [pyramid Mako];
1465 propagatedBuildInputs = with self; [pyramid Mako];
1479 src = fetchurl {
1466 src = fetchurl {
1480 url = "https://pypi.python.org/packages/f1/92/7e69bcf09676d286a71cb3bbb887b16595b96f9ba7adbdc239ffdd4b1eb9/pyramid_mako-1.0.2.tar.gz";
1467 url = "https://pypi.python.org/packages/f1/92/7e69bcf09676d286a71cb3bbb887b16595b96f9ba7adbdc239ffdd4b1eb9/pyramid_mako-1.0.2.tar.gz";
1481 md5 = "ee25343a97eb76bd90abdc2a774eb48a";
1468 md5 = "ee25343a97eb76bd90abdc2a774eb48a";
1482 };
1469 };
1483 meta = {
1470 meta = {
1484 license = [ { fullName = "Repoze Public License"; } { fullName = "BSD-derived (http://www.repoze.org/LICENSE.txt)"; } ];
1471 license = [ { fullName = "Repoze Public License"; } { fullName = "BSD-derived (http://www.repoze.org/LICENSE.txt)"; } ];
1485 };
1472 };
1486 };
1473 };
1487 pysqlite = super.buildPythonPackage {
1474 pysqlite = super.buildPythonPackage {
1488 name = "pysqlite-2.8.3";
1475 name = "pysqlite-2.8.3";
1489 buildInputs = with self; [];
1476 buildInputs = with self; [];
1490 doCheck = false;
1477 doCheck = false;
1491 propagatedBuildInputs = with self; [];
1478 propagatedBuildInputs = with self; [];
1492 src = fetchurl {
1479 src = fetchurl {
1493 url = "https://pypi.python.org/packages/42/02/981b6703e3c83c5b25a829c6e77aad059f9481b0bbacb47e6e8ca12bd731/pysqlite-2.8.3.tar.gz";
1480 url = "https://pypi.python.org/packages/42/02/981b6703e3c83c5b25a829c6e77aad059f9481b0bbacb47e6e8ca12bd731/pysqlite-2.8.3.tar.gz";
1494 md5 = "033f17b8644577715aee55e8832ac9fc";
1481 md5 = "033f17b8644577715aee55e8832ac9fc";
1495 };
1482 };
1496 meta = {
1483 meta = {
1497 license = [ { fullName = "zlib/libpng License"; } { fullName = "zlib/libpng license"; } ];
1484 license = [ { fullName = "zlib/libpng License"; } { fullName = "zlib/libpng license"; } ];
1498 };
1485 };
1499 };
1486 };
1500 pytest = super.buildPythonPackage {
1487 pytest = super.buildPythonPackage {
1501 name = "pytest-3.1.2";
1488 name = "pytest-3.1.2";
1502 buildInputs = with self; [];
1489 buildInputs = with self; [];
1503 doCheck = false;
1490 doCheck = false;
1504 propagatedBuildInputs = with self; [py setuptools];
1491 propagatedBuildInputs = with self; [py setuptools];
1505 src = fetchurl {
1492 src = fetchurl {
1506 url = "https://pypi.python.org/packages/72/2b/2d3155e01f45a5a04427857352ee88220ee39550b2bc078f9db3190aea46/pytest-3.1.2.tar.gz";
1493 url = "https://pypi.python.org/packages/72/2b/2d3155e01f45a5a04427857352ee88220ee39550b2bc078f9db3190aea46/pytest-3.1.2.tar.gz";
1507 md5 = "c4d179f89043cc925e1c169d03128e02";
1494 md5 = "c4d179f89043cc925e1c169d03128e02";
1508 };
1495 };
1509 meta = {
1496 meta = {
1510 license = [ pkgs.lib.licenses.mit ];
1497 license = [ pkgs.lib.licenses.mit ];
1511 };
1498 };
1512 };
1499 };
1513 pytest-catchlog = super.buildPythonPackage {
1500 pytest-catchlog = super.buildPythonPackage {
1514 name = "pytest-catchlog-1.2.2";
1501 name = "pytest-catchlog-1.2.2";
1515 buildInputs = with self; [];
1502 buildInputs = with self; [];
1516 doCheck = false;
1503 doCheck = false;
1517 propagatedBuildInputs = with self; [py pytest];
1504 propagatedBuildInputs = with self; [py pytest];
1518 src = fetchurl {
1505 src = fetchurl {
1519 url = "https://pypi.python.org/packages/f2/2b/2faccdb1a978fab9dd0bf31cca9f6847fbe9184a0bdcc3011ac41dd44191/pytest-catchlog-1.2.2.zip";
1506 url = "https://pypi.python.org/packages/f2/2b/2faccdb1a978fab9dd0bf31cca9f6847fbe9184a0bdcc3011ac41dd44191/pytest-catchlog-1.2.2.zip";
1520 md5 = "09d890c54c7456c818102b7ff8c182c8";
1507 md5 = "09d890c54c7456c818102b7ff8c182c8";
1521 };
1508 };
1522 meta = {
1509 meta = {
1523 license = [ pkgs.lib.licenses.mit ];
1510 license = [ pkgs.lib.licenses.mit ];
1524 };
1511 };
1525 };
1512 };
1526 pytest-cov = super.buildPythonPackage {
1513 pytest-cov = super.buildPythonPackage {
1527 name = "pytest-cov-2.5.1";
1514 name = "pytest-cov-2.5.1";
1528 buildInputs = with self; [];
1515 buildInputs = with self; [];
1529 doCheck = false;
1516 doCheck = false;
1530 propagatedBuildInputs = with self; [pytest coverage];
1517 propagatedBuildInputs = with self; [pytest coverage];
1531 src = fetchurl {
1518 src = fetchurl {
1532 url = "https://pypi.python.org/packages/24/b4/7290d65b2f3633db51393bdf8ae66309b37620bc3ec116c5e357e3e37238/pytest-cov-2.5.1.tar.gz";
1519 url = "https://pypi.python.org/packages/24/b4/7290d65b2f3633db51393bdf8ae66309b37620bc3ec116c5e357e3e37238/pytest-cov-2.5.1.tar.gz";
1533 md5 = "5acf38d4909e19819eb5c1754fbfc0ac";
1520 md5 = "5acf38d4909e19819eb5c1754fbfc0ac";
1534 };
1521 };
1535 meta = {
1522 meta = {
1536 license = [ pkgs.lib.licenses.bsdOriginal pkgs.lib.licenses.mit ];
1523 license = [ pkgs.lib.licenses.bsdOriginal pkgs.lib.licenses.mit ];
1537 };
1524 };
1538 };
1525 };
1539 pytest-profiling = super.buildPythonPackage {
1526 pytest-profiling = super.buildPythonPackage {
1540 name = "pytest-profiling-1.2.6";
1527 name = "pytest-profiling-1.2.6";
1541 buildInputs = with self; [];
1528 buildInputs = with self; [];
1542 doCheck = false;
1529 doCheck = false;
1543 propagatedBuildInputs = with self; [six pytest gprof2dot];
1530 propagatedBuildInputs = with self; [six pytest gprof2dot];
1544 src = fetchurl {
1531 src = fetchurl {
1545 url = "https://pypi.python.org/packages/f9/0d/df67fb9ce16c2cef201693da956321b1bccfbf9a4ead39748b9f9d1d74cb/pytest-profiling-1.2.6.tar.gz";
1532 url = "https://pypi.python.org/packages/f9/0d/df67fb9ce16c2cef201693da956321b1bccfbf9a4ead39748b9f9d1d74cb/pytest-profiling-1.2.6.tar.gz";
1546 md5 = "50eb4c66c3762a2f1a49669bedc0b894";
1533 md5 = "50eb4c66c3762a2f1a49669bedc0b894";
1547 };
1534 };
1548 meta = {
1535 meta = {
1549 license = [ pkgs.lib.licenses.mit ];
1536 license = [ pkgs.lib.licenses.mit ];
1550 };
1537 };
1551 };
1538 };
1552 pytest-runner = super.buildPythonPackage {
1539 pytest-runner = super.buildPythonPackage {
1553 name = "pytest-runner-2.11.1";
1540 name = "pytest-runner-2.11.1";
1554 buildInputs = with self; [];
1541 buildInputs = with self; [];
1555 doCheck = false;
1542 doCheck = false;
1556 propagatedBuildInputs = with self; [];
1543 propagatedBuildInputs = with self; [];
1557 src = fetchurl {
1544 src = fetchurl {
1558 url = "https://pypi.python.org/packages/9e/4d/08889e5e27a9f5d6096b9ad257f4dea1faabb03c5ded8f665ead448f5d8a/pytest-runner-2.11.1.tar.gz";
1545 url = "https://pypi.python.org/packages/9e/4d/08889e5e27a9f5d6096b9ad257f4dea1faabb03c5ded8f665ead448f5d8a/pytest-runner-2.11.1.tar.gz";
1559 md5 = "bdb73eb18eca2727944a2dcf963c5a81";
1546 md5 = "bdb73eb18eca2727944a2dcf963c5a81";
1560 };
1547 };
1561 meta = {
1548 meta = {
1562 license = [ pkgs.lib.licenses.mit ];
1549 license = [ pkgs.lib.licenses.mit ];
1563 };
1550 };
1564 };
1551 };
1565 pytest-sugar = super.buildPythonPackage {
1552 pytest-sugar = super.buildPythonPackage {
1566 name = "pytest-sugar-0.8.0";
1553 name = "pytest-sugar-0.8.0";
1567 buildInputs = with self; [];
1554 buildInputs = with self; [];
1568 doCheck = false;
1555 doCheck = false;
1569 propagatedBuildInputs = with self; [pytest termcolor];
1556 propagatedBuildInputs = with self; [pytest termcolor];
1570 src = fetchurl {
1557 src = fetchurl {
1571 url = "https://pypi.python.org/packages/a5/b0/b2773dee078f17773a5bf2dfad49b0be57b6354bbd84bbefe4313e509d87/pytest-sugar-0.8.0.tar.gz";
1558 url = "https://pypi.python.org/packages/a5/b0/b2773dee078f17773a5bf2dfad49b0be57b6354bbd84bbefe4313e509d87/pytest-sugar-0.8.0.tar.gz";
1572 md5 = "8cafbdad648068e0e44b8fc5f9faae42";
1559 md5 = "8cafbdad648068e0e44b8fc5f9faae42";
1573 };
1560 };
1574 meta = {
1561 meta = {
1575 license = [ pkgs.lib.licenses.bsdOriginal ];
1562 license = [ pkgs.lib.licenses.bsdOriginal ];
1576 };
1563 };
1577 };
1564 };
1578 pytest-timeout = super.buildPythonPackage {
1565 pytest-timeout = super.buildPythonPackage {
1579 name = "pytest-timeout-1.2.0";
1566 name = "pytest-timeout-1.2.0";
1580 buildInputs = with self; [];
1567 buildInputs = with self; [];
1581 doCheck = false;
1568 doCheck = false;
1582 propagatedBuildInputs = with self; [pytest];
1569 propagatedBuildInputs = with self; [pytest];
1583 src = fetchurl {
1570 src = fetchurl {
1584 url = "https://pypi.python.org/packages/cc/b7/b2a61365ea6b6d2e8881360ae7ed8dad0327ad2df89f2f0be4a02304deb2/pytest-timeout-1.2.0.tar.gz";
1571 url = "https://pypi.python.org/packages/cc/b7/b2a61365ea6b6d2e8881360ae7ed8dad0327ad2df89f2f0be4a02304deb2/pytest-timeout-1.2.0.tar.gz";
1585 md5 = "83607d91aa163562c7ee835da57d061d";
1572 md5 = "83607d91aa163562c7ee835da57d061d";
1586 };
1573 };
1587 meta = {
1574 meta = {
1588 license = [ pkgs.lib.licenses.mit { fullName = "DFSG approved"; } ];
1575 license = [ pkgs.lib.licenses.mit { fullName = "DFSG approved"; } ];
1589 };
1576 };
1590 };
1577 };
1591 python-dateutil = super.buildPythonPackage {
1578 python-dateutil = super.buildPythonPackage {
1592 name = "python-dateutil-2.1";
1579 name = "python-dateutil-2.1";
1593 buildInputs = with self; [];
1580 buildInputs = with self; [];
1594 doCheck = false;
1581 doCheck = false;
1595 propagatedBuildInputs = with self; [six];
1582 propagatedBuildInputs = with self; [six];
1596 src = fetchurl {
1583 src = fetchurl {
1597 url = "https://pypi.python.org/packages/65/52/9c18dac21f174ad31b65e22d24297864a954e6fe65876eba3f5773d2da43/python-dateutil-2.1.tar.gz";
1584 url = "https://pypi.python.org/packages/65/52/9c18dac21f174ad31b65e22d24297864a954e6fe65876eba3f5773d2da43/python-dateutil-2.1.tar.gz";
1598 md5 = "1534bb15cf311f07afaa3aacba1c028b";
1585 md5 = "1534bb15cf311f07afaa3aacba1c028b";
1599 };
1586 };
1600 meta = {
1587 meta = {
1601 license = [ { fullName = "Simplified BSD"; } ];
1588 license = [ { fullName = "Simplified BSD"; } ];
1602 };
1589 };
1603 };
1590 };
1604 python-editor = super.buildPythonPackage {
1591 python-editor = super.buildPythonPackage {
1605 name = "python-editor-1.0.3";
1592 name = "python-editor-1.0.3";
1606 buildInputs = with self; [];
1593 buildInputs = with self; [];
1607 doCheck = false;
1594 doCheck = false;
1608 propagatedBuildInputs = with self; [];
1595 propagatedBuildInputs = with self; [];
1609 src = fetchurl {
1596 src = fetchurl {
1610 url = "https://pypi.python.org/packages/65/1e/adf6e000ea5dc909aa420352d6ba37f16434c8a3c2fa030445411a1ed545/python-editor-1.0.3.tar.gz";
1597 url = "https://pypi.python.org/packages/65/1e/adf6e000ea5dc909aa420352d6ba37f16434c8a3c2fa030445411a1ed545/python-editor-1.0.3.tar.gz";
1611 md5 = "0aca5f2ef176ce68e98a5b7e31372835";
1598 md5 = "0aca5f2ef176ce68e98a5b7e31372835";
1612 };
1599 };
1613 meta = {
1600 meta = {
1614 license = [ pkgs.lib.licenses.asl20 { fullName = "Apache"; } ];
1601 license = [ pkgs.lib.licenses.asl20 { fullName = "Apache"; } ];
1615 };
1602 };
1616 };
1603 };
1617 python-ldap = super.buildPythonPackage {
1604 python-ldap = super.buildPythonPackage {
1618 name = "python-ldap-2.4.40";
1605 name = "python-ldap-2.4.40";
1619 buildInputs = with self; [];
1606 buildInputs = with self; [];
1620 doCheck = false;
1607 doCheck = false;
1621 propagatedBuildInputs = with self; [setuptools];
1608 propagatedBuildInputs = with self; [setuptools];
1622 src = fetchurl {
1609 src = fetchurl {
1623 url = "https://pypi.python.org/packages/4a/d8/7d70a7469058a3987d224061a81d778951ac2b48220bdcc511e4b1b37176/python-ldap-2.4.40.tar.gz";
1610 url = "https://pypi.python.org/packages/4a/d8/7d70a7469058a3987d224061a81d778951ac2b48220bdcc511e4b1b37176/python-ldap-2.4.40.tar.gz";
1624 md5 = "aea0233f7d39b0c7549fcd310deeb0e5";
1611 md5 = "aea0233f7d39b0c7549fcd310deeb0e5";
1625 };
1612 };
1626 meta = {
1613 meta = {
1627 license = [ pkgs.lib.licenses.psfl ];
1614 license = [ pkgs.lib.licenses.psfl ];
1628 };
1615 };
1629 };
1616 };
1630 python-memcached = super.buildPythonPackage {
1617 python-memcached = super.buildPythonPackage {
1631 name = "python-memcached-1.58";
1618 name = "python-memcached-1.58";
1632 buildInputs = with self; [];
1619 buildInputs = with self; [];
1633 doCheck = false;
1620 doCheck = false;
1634 propagatedBuildInputs = with self; [six];
1621 propagatedBuildInputs = with self; [six];
1635 src = fetchurl {
1622 src = fetchurl {
1636 url = "https://pypi.python.org/packages/f7/62/14b2448cfb04427366f24104c9da97cf8ea380d7258a3233f066a951a8d8/python-memcached-1.58.tar.gz";
1623 url = "https://pypi.python.org/packages/f7/62/14b2448cfb04427366f24104c9da97cf8ea380d7258a3233f066a951a8d8/python-memcached-1.58.tar.gz";
1637 md5 = "23b258105013d14d899828d334e6b044";
1624 md5 = "23b258105013d14d899828d334e6b044";
1638 };
1625 };
1639 meta = {
1626 meta = {
1640 license = [ pkgs.lib.licenses.psfl ];
1627 license = [ pkgs.lib.licenses.psfl ];
1641 };
1628 };
1642 };
1629 };
1643 python-pam = super.buildPythonPackage {
1630 python-pam = super.buildPythonPackage {
1644 name = "python-pam-1.8.2";
1631 name = "python-pam-1.8.2";
1645 buildInputs = with self; [];
1632 buildInputs = with self; [];
1646 doCheck = false;
1633 doCheck = false;
1647 propagatedBuildInputs = with self; [];
1634 propagatedBuildInputs = with self; [];
1648 src = fetchurl {
1635 src = fetchurl {
1649 url = "https://pypi.python.org/packages/de/8c/f8f5d38b4f26893af267ea0b39023d4951705ab0413a39e0cf7cf4900505/python-pam-1.8.2.tar.gz";
1636 url = "https://pypi.python.org/packages/de/8c/f8f5d38b4f26893af267ea0b39023d4951705ab0413a39e0cf7cf4900505/python-pam-1.8.2.tar.gz";
1650 md5 = "db71b6b999246fb05d78ecfbe166629d";
1637 md5 = "db71b6b999246fb05d78ecfbe166629d";
1651 };
1638 };
1652 meta = {
1639 meta = {
1653 license = [ { fullName = "License :: OSI Approved :: MIT License"; } pkgs.lib.licenses.mit ];
1640 license = [ { fullName = "License :: OSI Approved :: MIT License"; } pkgs.lib.licenses.mit ];
1654 };
1641 };
1655 };
1642 };
1656 pytz = super.buildPythonPackage {
1643 pytz = super.buildPythonPackage {
1657 name = "pytz-2015.4";
1644 name = "pytz-2015.4";
1658 buildInputs = with self; [];
1645 buildInputs = with self; [];
1659 doCheck = false;
1646 doCheck = false;
1660 propagatedBuildInputs = with self; [];
1647 propagatedBuildInputs = with self; [];
1661 src = fetchurl {
1648 src = fetchurl {
1662 url = "https://pypi.python.org/packages/7e/1a/f43b5c92df7b156822030fed151327ea096bcf417e45acc23bd1df43472f/pytz-2015.4.zip";
1649 url = "https://pypi.python.org/packages/7e/1a/f43b5c92df7b156822030fed151327ea096bcf417e45acc23bd1df43472f/pytz-2015.4.zip";
1663 md5 = "233f2a2b370d03f9b5911700cc9ebf3c";
1650 md5 = "233f2a2b370d03f9b5911700cc9ebf3c";
1664 };
1651 };
1665 meta = {
1652 meta = {
1666 license = [ pkgs.lib.licenses.mit ];
1653 license = [ pkgs.lib.licenses.mit ];
1667 };
1654 };
1668 };
1655 };
1669 pyzmq = super.buildPythonPackage {
1656 pyzmq = super.buildPythonPackage {
1670 name = "pyzmq-14.6.0";
1657 name = "pyzmq-14.6.0";
1671 buildInputs = with self; [];
1658 buildInputs = with self; [];
1672 doCheck = false;
1659 doCheck = false;
1673 propagatedBuildInputs = with self; [];
1660 propagatedBuildInputs = with self; [];
1674 src = fetchurl {
1661 src = fetchurl {
1675 url = "https://pypi.python.org/packages/8a/3b/5463d5a9d712cd8bbdac335daece0d69f6a6792da4e3dd89956c0db4e4e6/pyzmq-14.6.0.tar.gz";
1662 url = "https://pypi.python.org/packages/8a/3b/5463d5a9d712cd8bbdac335daece0d69f6a6792da4e3dd89956c0db4e4e6/pyzmq-14.6.0.tar.gz";
1676 md5 = "395b5de95a931afa5b14c9349a5b8024";
1663 md5 = "395b5de95a931afa5b14c9349a5b8024";
1677 };
1664 };
1678 meta = {
1665 meta = {
1679 license = [ pkgs.lib.licenses.bsdOriginal { fullName = "LGPL+BSD"; } { fullName = "GNU Library or Lesser General Public License (LGPL)"; } ];
1666 license = [ pkgs.lib.licenses.bsdOriginal { fullName = "LGPL+BSD"; } { fullName = "GNU Library or Lesser General Public License (LGPL)"; } ];
1680 };
1667 };
1681 };
1668 };
1682 recaptcha-client = super.buildPythonPackage {
1669 recaptcha-client = super.buildPythonPackage {
1683 name = "recaptcha-client-1.0.6";
1670 name = "recaptcha-client-1.0.6";
1684 buildInputs = with self; [];
1671 buildInputs = with self; [];
1685 doCheck = false;
1672 doCheck = false;
1686 propagatedBuildInputs = with self; [];
1673 propagatedBuildInputs = with self; [];
1687 src = fetchurl {
1674 src = fetchurl {
1688 url = "https://pypi.python.org/packages/0a/ea/5f2fbbfd894bdac1c68ef8d92019066cfcf9fbff5fe3d728d2b5c25c8db4/recaptcha-client-1.0.6.tar.gz";
1675 url = "https://pypi.python.org/packages/0a/ea/5f2fbbfd894bdac1c68ef8d92019066cfcf9fbff5fe3d728d2b5c25c8db4/recaptcha-client-1.0.6.tar.gz";
1689 md5 = "74228180f7e1fb76c4d7089160b0d919";
1676 md5 = "74228180f7e1fb76c4d7089160b0d919";
1690 };
1677 };
1691 meta = {
1678 meta = {
1692 license = [ { fullName = "MIT/X11"; } ];
1679 license = [ { fullName = "MIT/X11"; } ];
1693 };
1680 };
1694 };
1681 };
1695 repoze.lru = super.buildPythonPackage {
1682 repoze.lru = super.buildPythonPackage {
1696 name = "repoze.lru-0.6";
1683 name = "repoze.lru-0.6";
1697 buildInputs = with self; [];
1684 buildInputs = with self; [];
1698 doCheck = false;
1685 doCheck = false;
1699 propagatedBuildInputs = with self; [];
1686 propagatedBuildInputs = with self; [];
1700 src = fetchurl {
1687 src = fetchurl {
1701 url = "https://pypi.python.org/packages/6e/1e/aa15cc90217e086dc8769872c8778b409812ff036bf021b15795638939e4/repoze.lru-0.6.tar.gz";
1688 url = "https://pypi.python.org/packages/6e/1e/aa15cc90217e086dc8769872c8778b409812ff036bf021b15795638939e4/repoze.lru-0.6.tar.gz";
1702 md5 = "2c3b64b17a8e18b405f55d46173e14dd";
1689 md5 = "2c3b64b17a8e18b405f55d46173e14dd";
1703 };
1690 };
1704 meta = {
1691 meta = {
1705 license = [ { fullName = "Repoze Public License"; } { fullName = "BSD-derived (http://www.repoze.org/LICENSE.txt)"; } ];
1692 license = [ { fullName = "Repoze Public License"; } { fullName = "BSD-derived (http://www.repoze.org/LICENSE.txt)"; } ];
1706 };
1693 };
1707 };
1694 };
1708 requests = super.buildPythonPackage {
1695 requests = super.buildPythonPackage {
1709 name = "requests-2.9.1";
1696 name = "requests-2.9.1";
1710 buildInputs = with self; [];
1697 buildInputs = with self; [];
1711 doCheck = false;
1698 doCheck = false;
1712 propagatedBuildInputs = with self; [];
1699 propagatedBuildInputs = with self; [];
1713 src = fetchurl {
1700 src = fetchurl {
1714 url = "https://pypi.python.org/packages/f9/6d/07c44fb1ebe04d069459a189e7dab9e4abfe9432adcd4477367c25332748/requests-2.9.1.tar.gz";
1701 url = "https://pypi.python.org/packages/f9/6d/07c44fb1ebe04d069459a189e7dab9e4abfe9432adcd4477367c25332748/requests-2.9.1.tar.gz";
1715 md5 = "0b7f480d19012ec52bab78292efd976d";
1702 md5 = "0b7f480d19012ec52bab78292efd976d";
1716 };
1703 };
1717 meta = {
1704 meta = {
1718 license = [ pkgs.lib.licenses.asl20 ];
1705 license = [ pkgs.lib.licenses.asl20 ];
1719 };
1706 };
1720 };
1707 };
1721 rhodecode-enterprise-ce = super.buildPythonPackage {
1708 rhodecode-enterprise-ce = super.buildPythonPackage {
1722 name = "rhodecode-enterprise-ce-4.9.0";
1709 name = "rhodecode-enterprise-ce-4.9.0";
1723 buildInputs = with self; [pytest py pytest-cov pytest-sugar pytest-runner pytest-catchlog pytest-profiling gprof2dot pytest-timeout mock WebTest cov-core coverage configobj];
1710 buildInputs = with self; [pytest py pytest-cov pytest-sugar pytest-runner pytest-catchlog pytest-profiling gprof2dot pytest-timeout mock WebTest cov-core coverage configobj];
1724 doCheck = true;
1711 doCheck = true;
1725 propagatedBuildInputs = with self; [Babel Beaker FormEncode Mako Markdown MarkupSafe MySQL-python Paste PasteDeploy PasteScript Pygments pygments-markdown-lexer Pylons Routes SQLAlchemy Tempita URLObject WebError WebHelpers WebHelpers2 WebOb WebTest Whoosh alembic amqplib anyjson appenlight-client authomatic cssselect celery channelstream colander decorator deform docutils gevent gunicorn infrae.cache ipython iso8601 kombu lxml msgpack-python nbconvert packaging psycopg2 py-gfm pycrypto pycurl pyparsing pyramid pyramid-debugtoolbar pyramid-mako pyramid-beaker pysqlite python-dateutil python-ldap python-memcached python-pam recaptcha-client repoze.lru requests simplejson subprocess32 waitress zope.cachedescriptors dogpile.cache dogpile.core psutil py-bcrypt];
1712 propagatedBuildInputs = with self; [Babel Beaker FormEncode Mako Markdown MarkupSafe MySQL-python Paste PasteDeploy PasteScript Pygments pygments-markdown-lexer Pylons Routes SQLAlchemy Tempita URLObject WebError WebHelpers WebHelpers2 WebOb WebTest Whoosh alembic amqplib anyjson appenlight-client authomatic cssselect celery channelstream colander decorator deform docutils gevent gunicorn infrae.cache ipython iso8601 kombu lxml msgpack-python nbconvert packaging psycopg2 py-gfm pycrypto pycurl pyparsing pyramid pyramid-debugtoolbar pyramid-mako pyramid-beaker pysqlite python-dateutil python-ldap python-memcached python-pam recaptcha-client repoze.lru requests simplejson sshpubkeys subprocess32 waitress zope.cachedescriptors dogpile.cache dogpile.core psutil py-bcrypt];
1726 src = ./.;
1713 src = ./.;
1727 meta = {
1714 meta = {
1728 license = [ { fullName = "Affero GNU General Public License v3 or later (AGPLv3+)"; } { fullName = "AGPLv3, and Commercial License"; } ];
1715 license = [ { fullName = "Affero GNU General Public License v3 or later (AGPLv3+)"; } { fullName = "AGPLv3, and Commercial License"; } ];
1729 };
1716 };
1730 };
1717 };
1731 rhodecode-tools = super.buildPythonPackage {
1718 rhodecode-tools = super.buildPythonPackage {
1732 name = "rhodecode-tools-0.12.0";
1719 name = "rhodecode-tools-0.12.0";
1733 buildInputs = with self; [];
1720 buildInputs = with self; [];
1734 doCheck = false;
1721 doCheck = false;
1735 propagatedBuildInputs = with self; [click future six Mako MarkupSafe requests elasticsearch elasticsearch-dsl urllib3 Whoosh];
1722 propagatedBuildInputs = with self; [click future six Mako MarkupSafe requests elasticsearch elasticsearch-dsl urllib3 Whoosh];
1736 src = fetchurl {
1723 src = fetchurl {
1737 url = "https://code.rhodecode.com/rhodecode-tools-ce/archive/v0.12.0.tar.gz?md5=9ca040356fa7e38d3f64529a4cffdca4";
1724 url = "https://code.rhodecode.com/rhodecode-tools-ce/archive/v0.12.0.tar.gz?md5=9ca040356fa7e38d3f64529a4cffdca4";
1738 md5 = "9ca040356fa7e38d3f64529a4cffdca4";
1725 md5 = "9ca040356fa7e38d3f64529a4cffdca4";
1739 };
1726 };
1740 meta = {
1727 meta = {
1741 license = [ { fullName = "AGPLv3 and Proprietary"; } ];
1728 license = [ { fullName = "AGPLv3 and Proprietary"; } ];
1742 };
1729 };
1743 };
1730 };
1744 scandir = super.buildPythonPackage {
1731 scandir = super.buildPythonPackage {
1745 name = "scandir-1.5";
1732 name = "scandir-1.5";
1746 buildInputs = with self; [];
1733 buildInputs = with self; [];
1747 doCheck = false;
1734 doCheck = false;
1748 propagatedBuildInputs = with self; [];
1735 propagatedBuildInputs = with self; [];
1749 src = fetchurl {
1736 src = fetchurl {
1750 url = "https://pypi.python.org/packages/bd/f4/3143e0289faf0883228017dbc6387a66d0b468df646645e29e1eb89ea10e/scandir-1.5.tar.gz";
1737 url = "https://pypi.python.org/packages/bd/f4/3143e0289faf0883228017dbc6387a66d0b468df646645e29e1eb89ea10e/scandir-1.5.tar.gz";
1751 md5 = "a2713043de681bba6b084be42e7a8a44";
1738 md5 = "a2713043de681bba6b084be42e7a8a44";
1752 };
1739 };
1753 meta = {
1740 meta = {
1754 license = [ pkgs.lib.licenses.bsdOriginal { fullName = "New BSD License"; } ];
1741 license = [ pkgs.lib.licenses.bsdOriginal { fullName = "New BSD License"; } ];
1755 };
1742 };
1756 };
1743 };
1757 setproctitle = super.buildPythonPackage {
1744 setproctitle = super.buildPythonPackage {
1758 name = "setproctitle-1.1.8";
1745 name = "setproctitle-1.1.8";
1759 buildInputs = with self; [];
1746 buildInputs = with self; [];
1760 doCheck = false;
1747 doCheck = false;
1761 propagatedBuildInputs = with self; [];
1748 propagatedBuildInputs = with self; [];
1762 src = fetchurl {
1749 src = fetchurl {
1763 url = "https://pypi.python.org/packages/33/c3/ad367a4f4f1ca90468863ae727ac62f6edb558fc09a003d344a02cfc6ea6/setproctitle-1.1.8.tar.gz";
1750 url = "https://pypi.python.org/packages/33/c3/ad367a4f4f1ca90468863ae727ac62f6edb558fc09a003d344a02cfc6ea6/setproctitle-1.1.8.tar.gz";
1764 md5 = "728f4c8c6031bbe56083a48594027edd";
1751 md5 = "728f4c8c6031bbe56083a48594027edd";
1765 };
1752 };
1766 meta = {
1753 meta = {
1767 license = [ pkgs.lib.licenses.bsdOriginal ];
1754 license = [ pkgs.lib.licenses.bsdOriginal ];
1768 };
1755 };
1769 };
1756 };
1770 setuptools = super.buildPythonPackage {
1757 setuptools = super.buildPythonPackage {
1771 name = "setuptools-30.1.0";
1758 name = "setuptools-30.1.0";
1772 buildInputs = with self; [];
1759 buildInputs = with self; [];
1773 doCheck = false;
1760 doCheck = false;
1774 propagatedBuildInputs = with self; [];
1761 propagatedBuildInputs = with self; [];
1775 src = fetchurl {
1762 src = fetchurl {
1776 url = "https://pypi.python.org/packages/1e/43/002c8616db9a3e7be23c2556e39b90a32bb40ba0dc652de1999d5334d372/setuptools-30.1.0.tar.gz";
1763 url = "https://pypi.python.org/packages/1e/43/002c8616db9a3e7be23c2556e39b90a32bb40ba0dc652de1999d5334d372/setuptools-30.1.0.tar.gz";
1777 md5 = "cac497f42e5096ac8df29e38d3f81c3e";
1764 md5 = "cac497f42e5096ac8df29e38d3f81c3e";
1778 };
1765 };
1779 meta = {
1766 meta = {
1780 license = [ pkgs.lib.licenses.mit ];
1767 license = [ pkgs.lib.licenses.mit ];
1781 };
1768 };
1782 };
1769 };
1783 setuptools-scm = super.buildPythonPackage {
1770 setuptools-scm = super.buildPythonPackage {
1784 name = "setuptools-scm-1.15.0";
1771 name = "setuptools-scm-1.15.0";
1785 buildInputs = with self; [];
1772 buildInputs = with self; [];
1786 doCheck = false;
1773 doCheck = false;
1787 propagatedBuildInputs = with self; [];
1774 propagatedBuildInputs = with self; [];
1788 src = fetchurl {
1775 src = fetchurl {
1789 url = "https://pypi.python.org/packages/80/b7/31b6ae5fcb188e37f7e31abe75f9be90490a5456a72860fa6e643f8a3cbc/setuptools_scm-1.15.0.tar.gz";
1776 url = "https://pypi.python.org/packages/80/b7/31b6ae5fcb188e37f7e31abe75f9be90490a5456a72860fa6e643f8a3cbc/setuptools_scm-1.15.0.tar.gz";
1790 md5 = "b6916c78ed6253d6602444fad4279c5b";
1777 md5 = "b6916c78ed6253d6602444fad4279c5b";
1791 };
1778 };
1792 meta = {
1779 meta = {
1793 license = [ pkgs.lib.licenses.mit ];
1780 license = [ pkgs.lib.licenses.mit ];
1794 };
1781 };
1795 };
1782 };
1796 simplegeneric = super.buildPythonPackage {
1783 simplegeneric = super.buildPythonPackage {
1797 name = "simplegeneric-0.8.1";
1784 name = "simplegeneric-0.8.1";
1798 buildInputs = with self; [];
1785 buildInputs = with self; [];
1799 doCheck = false;
1786 doCheck = false;
1800 propagatedBuildInputs = with self; [];
1787 propagatedBuildInputs = with self; [];
1801 src = fetchurl {
1788 src = fetchurl {
1802 url = "https://pypi.python.org/packages/3d/57/4d9c9e3ae9a255cd4e1106bb57e24056d3d0709fc01b2e3e345898e49d5b/simplegeneric-0.8.1.zip";
1789 url = "https://pypi.python.org/packages/3d/57/4d9c9e3ae9a255cd4e1106bb57e24056d3d0709fc01b2e3e345898e49d5b/simplegeneric-0.8.1.zip";
1803 md5 = "f9c1fab00fd981be588fc32759f474e3";
1790 md5 = "f9c1fab00fd981be588fc32759f474e3";
1804 };
1791 };
1805 meta = {
1792 meta = {
1806 license = [ pkgs.lib.licenses.zpt21 ];
1793 license = [ pkgs.lib.licenses.zpt21 ];
1807 };
1794 };
1808 };
1795 };
1809 simplejson = super.buildPythonPackage {
1796 simplejson = super.buildPythonPackage {
1810 name = "simplejson-3.11.1";
1797 name = "simplejson-3.11.1";
1811 buildInputs = with self; [];
1798 buildInputs = with self; [];
1812 doCheck = false;
1799 doCheck = false;
1813 propagatedBuildInputs = with self; [];
1800 propagatedBuildInputs = with self; [];
1814 src = fetchurl {
1801 src = fetchurl {
1815 url = "https://pypi.python.org/packages/08/48/c97b668d6da7d7bebe7ea1817a6f76394b0ec959cb04214ca833c34359df/simplejson-3.11.1.tar.gz";
1802 url = "https://pypi.python.org/packages/08/48/c97b668d6da7d7bebe7ea1817a6f76394b0ec959cb04214ca833c34359df/simplejson-3.11.1.tar.gz";
1816 md5 = "6e2f1bd5fb0a926facf5d89d217a7183";
1803 md5 = "6e2f1bd5fb0a926facf5d89d217a7183";
1817 };
1804 };
1818 meta = {
1805 meta = {
1819 license = [ { fullName = "Academic Free License (AFL)"; } pkgs.lib.licenses.mit ];
1806 license = [ { fullName = "Academic Free License (AFL)"; } pkgs.lib.licenses.mit ];
1820 };
1807 };
1821 };
1808 };
1822 six = super.buildPythonPackage {
1809 six = super.buildPythonPackage {
1823 name = "six-1.9.0";
1810 name = "six-1.9.0";
1824 buildInputs = with self; [];
1811 buildInputs = with self; [];
1825 doCheck = false;
1812 doCheck = false;
1826 propagatedBuildInputs = with self; [];
1813 propagatedBuildInputs = with self; [];
1827 src = fetchurl {
1814 src = fetchurl {
1828 url = "https://pypi.python.org/packages/16/64/1dc5e5976b17466fd7d712e59cbe9fb1e18bec153109e5ba3ed6c9102f1a/six-1.9.0.tar.gz";
1815 url = "https://pypi.python.org/packages/16/64/1dc5e5976b17466fd7d712e59cbe9fb1e18bec153109e5ba3ed6c9102f1a/six-1.9.0.tar.gz";
1829 md5 = "476881ef4012262dfc8adc645ee786c4";
1816 md5 = "476881ef4012262dfc8adc645ee786c4";
1830 };
1817 };
1831 meta = {
1818 meta = {
1832 license = [ pkgs.lib.licenses.mit ];
1819 license = [ pkgs.lib.licenses.mit ];
1833 };
1820 };
1834 };
1821 };
1822 sshpubkeys = super.buildPythonPackage {
1823 name = "sshpubkeys-2.2.0";
1824 buildInputs = with self; [];
1825 doCheck = false;
1826 propagatedBuildInputs = with self; [pycrypto ecdsa];
1827 src = fetchurl {
1828 url = "https://pypi.python.org/packages/27/da/337fabeb3dca6b62039a93ceaa636f25065e0ae92b575b1235342076cf0a/sshpubkeys-2.2.0.tar.gz";
1829 md5 = "458e45f6b92b1afa84f0ffe1f1c90935";
1830 };
1831 meta = {
1832 license = [ pkgs.lib.licenses.bsdOriginal ];
1833 };
1834 };
1835 subprocess32 = super.buildPythonPackage {
1835 subprocess32 = super.buildPythonPackage {
1836 name = "subprocess32-3.2.7";
1836 name = "subprocess32-3.2.7";
1837 buildInputs = with self; [];
1837 buildInputs = with self; [];
1838 doCheck = false;
1838 doCheck = false;
1839 propagatedBuildInputs = with self; [];
1839 propagatedBuildInputs = with self; [];
1840 src = fetchurl {
1840 src = fetchurl {
1841 url = "https://pypi.python.org/packages/b8/2f/49e53b0d0e94611a2dc624a1ad24d41b6d94d0f1b0a078443407ea2214c2/subprocess32-3.2.7.tar.gz";
1841 url = "https://pypi.python.org/packages/b8/2f/49e53b0d0e94611a2dc624a1ad24d41b6d94d0f1b0a078443407ea2214c2/subprocess32-3.2.7.tar.gz";
1842 md5 = "824c801e479d3e916879aae3e9c15e16";
1842 md5 = "824c801e479d3e916879aae3e9c15e16";
1843 };
1843 };
1844 meta = {
1844 meta = {
1845 license = [ pkgs.lib.licenses.psfl ];
1845 license = [ pkgs.lib.licenses.psfl ];
1846 };
1846 };
1847 };
1847 };
1848 supervisor = super.buildPythonPackage {
1848 supervisor = super.buildPythonPackage {
1849 name = "supervisor-3.3.2";
1849 name = "supervisor-3.3.2";
1850 buildInputs = with self; [];
1850 buildInputs = with self; [];
1851 doCheck = false;
1851 doCheck = false;
1852 propagatedBuildInputs = with self; [meld3];
1852 propagatedBuildInputs = with self; [meld3];
1853 src = fetchurl {
1853 src = fetchurl {
1854 url = "https://pypi.python.org/packages/7b/17/88adf8cb25f80e2bc0d18e094fcd7ab300632ea00b601cbbbb84c2419eae/supervisor-3.3.2.tar.gz";
1854 url = "https://pypi.python.org/packages/7b/17/88adf8cb25f80e2bc0d18e094fcd7ab300632ea00b601cbbbb84c2419eae/supervisor-3.3.2.tar.gz";
1855 md5 = "04766d62864da13d6a12f7429e75314f";
1855 md5 = "04766d62864da13d6a12f7429e75314f";
1856 };
1856 };
1857 meta = {
1857 meta = {
1858 license = [ { fullName = "BSD-derived (http://www.repoze.org/LICENSE.txt)"; } ];
1858 license = [ { fullName = "BSD-derived (http://www.repoze.org/LICENSE.txt)"; } ];
1859 };
1859 };
1860 };
1860 };
1861 termcolor = super.buildPythonPackage {
1861 termcolor = super.buildPythonPackage {
1862 name = "termcolor-1.1.0";
1862 name = "termcolor-1.1.0";
1863 buildInputs = with self; [];
1863 buildInputs = with self; [];
1864 doCheck = false;
1864 doCheck = false;
1865 propagatedBuildInputs = with self; [];
1865 propagatedBuildInputs = with self; [];
1866 src = fetchurl {
1866 src = fetchurl {
1867 url = "https://pypi.python.org/packages/8a/48/a76be51647d0eb9f10e2a4511bf3ffb8cc1e6b14e9e4fab46173aa79f981/termcolor-1.1.0.tar.gz";
1867 url = "https://pypi.python.org/packages/8a/48/a76be51647d0eb9f10e2a4511bf3ffb8cc1e6b14e9e4fab46173aa79f981/termcolor-1.1.0.tar.gz";
1868 md5 = "043e89644f8909d462fbbfa511c768df";
1868 md5 = "043e89644f8909d462fbbfa511c768df";
1869 };
1869 };
1870 meta = {
1870 meta = {
1871 license = [ pkgs.lib.licenses.mit ];
1871 license = [ pkgs.lib.licenses.mit ];
1872 };
1872 };
1873 };
1873 };
1874 testpath = super.buildPythonPackage {
1874 testpath = super.buildPythonPackage {
1875 name = "testpath-0.3.1";
1875 name = "testpath-0.3.1";
1876 buildInputs = with self; [];
1876 buildInputs = with self; [];
1877 doCheck = false;
1877 doCheck = false;
1878 propagatedBuildInputs = with self; [];
1878 propagatedBuildInputs = with self; [];
1879 src = fetchurl {
1879 src = fetchurl {
1880 url = "https://pypi.python.org/packages/f4/8b/b71e9ee10e5f751e9d959bc750ab122ba04187f5aa52aabdc4e63b0e31a7/testpath-0.3.1.tar.gz";
1880 url = "https://pypi.python.org/packages/f4/8b/b71e9ee10e5f751e9d959bc750ab122ba04187f5aa52aabdc4e63b0e31a7/testpath-0.3.1.tar.gz";
1881 md5 = "2cd5ed5522fda781bb497c9d80ae2fc9";
1881 md5 = "2cd5ed5522fda781bb497c9d80ae2fc9";
1882 };
1882 };
1883 meta = {
1883 meta = {
1884 license = [ pkgs.lib.licenses.mit ];
1884 license = [ pkgs.lib.licenses.mit ];
1885 };
1885 };
1886 };
1886 };
1887 traitlets = super.buildPythonPackage {
1887 traitlets = super.buildPythonPackage {
1888 name = "traitlets-4.3.2";
1888 name = "traitlets-4.3.2";
1889 buildInputs = with self; [];
1889 buildInputs = with self; [];
1890 doCheck = false;
1890 doCheck = false;
1891 propagatedBuildInputs = with self; [ipython-genutils six decorator enum34];
1891 propagatedBuildInputs = with self; [ipython-genutils six decorator enum34];
1892 src = fetchurl {
1892 src = fetchurl {
1893 url = "https://pypi.python.org/packages/a5/98/7f5ef2fe9e9e071813aaf9cb91d1a732e0a68b6c44a32b38cb8e14c3f069/traitlets-4.3.2.tar.gz";
1893 url = "https://pypi.python.org/packages/a5/98/7f5ef2fe9e9e071813aaf9cb91d1a732e0a68b6c44a32b38cb8e14c3f069/traitlets-4.3.2.tar.gz";
1894 md5 = "3068663f2f38fd939a9eb3a500ccc154";
1894 md5 = "3068663f2f38fd939a9eb3a500ccc154";
1895 };
1895 };
1896 meta = {
1896 meta = {
1897 license = [ pkgs.lib.licenses.bsdOriginal ];
1897 license = [ pkgs.lib.licenses.bsdOriginal ];
1898 };
1898 };
1899 };
1899 };
1900 transifex-client = super.buildPythonPackage {
1900 transifex-client = super.buildPythonPackage {
1901 name = "transifex-client-0.10";
1901 name = "transifex-client-0.10";
1902 buildInputs = with self; [];
1902 buildInputs = with self; [];
1903 doCheck = false;
1903 doCheck = false;
1904 propagatedBuildInputs = with self; [];
1904 propagatedBuildInputs = with self; [];
1905 src = fetchurl {
1905 src = fetchurl {
1906 url = "https://pypi.python.org/packages/f3/4e/7b925192aee656fb3e04fa6381c8b3dc40198047c3b4a356f6cfd642c809/transifex-client-0.10.tar.gz";
1906 url = "https://pypi.python.org/packages/f3/4e/7b925192aee656fb3e04fa6381c8b3dc40198047c3b4a356f6cfd642c809/transifex-client-0.10.tar.gz";
1907 md5 = "5549538d84b8eede6b254cd81ae024fa";
1907 md5 = "5549538d84b8eede6b254cd81ae024fa";
1908 };
1908 };
1909 meta = {
1909 meta = {
1910 license = [ pkgs.lib.licenses.gpl2 ];
1910 license = [ pkgs.lib.licenses.gpl2 ];
1911 };
1911 };
1912 };
1912 };
1913 translationstring = super.buildPythonPackage {
1913 translationstring = super.buildPythonPackage {
1914 name = "translationstring-1.3";
1914 name = "translationstring-1.3";
1915 buildInputs = with self; [];
1915 buildInputs = with self; [];
1916 doCheck = false;
1916 doCheck = false;
1917 propagatedBuildInputs = with self; [];
1917 propagatedBuildInputs = with self; [];
1918 src = fetchurl {
1918 src = fetchurl {
1919 url = "https://pypi.python.org/packages/5e/eb/bee578cc150b44c653b63f5ebe258b5d0d812ddac12497e5f80fcad5d0b4/translationstring-1.3.tar.gz";
1919 url = "https://pypi.python.org/packages/5e/eb/bee578cc150b44c653b63f5ebe258b5d0d812ddac12497e5f80fcad5d0b4/translationstring-1.3.tar.gz";
1920 md5 = "a4b62e0f3c189c783a1685b3027f7c90";
1920 md5 = "a4b62e0f3c189c783a1685b3027f7c90";
1921 };
1921 };
1922 meta = {
1922 meta = {
1923 license = [ { fullName = "BSD-like (http://repoze.org/license.html)"; } ];
1923 license = [ { fullName = "BSD-like (http://repoze.org/license.html)"; } ];
1924 };
1924 };
1925 };
1925 };
1926 trollius = super.buildPythonPackage {
1926 trollius = super.buildPythonPackage {
1927 name = "trollius-1.0.4";
1927 name = "trollius-1.0.4";
1928 buildInputs = with self; [];
1928 buildInputs = with self; [];
1929 doCheck = false;
1929 doCheck = false;
1930 propagatedBuildInputs = with self; [futures];
1930 propagatedBuildInputs = with self; [futures];
1931 src = fetchurl {
1931 src = fetchurl {
1932 url = "https://pypi.python.org/packages/aa/e6/4141db437f55e6ee7a3fb69663239e3fde7841a811b4bef293145ad6c836/trollius-1.0.4.tar.gz";
1932 url = "https://pypi.python.org/packages/aa/e6/4141db437f55e6ee7a3fb69663239e3fde7841a811b4bef293145ad6c836/trollius-1.0.4.tar.gz";
1933 md5 = "3631a464d49d0cbfd30ab2918ef2b783";
1933 md5 = "3631a464d49d0cbfd30ab2918ef2b783";
1934 };
1934 };
1935 meta = {
1935 meta = {
1936 license = [ pkgs.lib.licenses.asl20 ];
1936 license = [ pkgs.lib.licenses.asl20 ];
1937 };
1937 };
1938 };
1938 };
1939 uWSGI = super.buildPythonPackage {
1939 uWSGI = super.buildPythonPackage {
1940 name = "uWSGI-2.0.15";
1940 name = "uWSGI-2.0.15";
1941 buildInputs = with self; [];
1941 buildInputs = with self; [];
1942 doCheck = false;
1942 doCheck = false;
1943 propagatedBuildInputs = with self; [];
1943 propagatedBuildInputs = with self; [];
1944 src = fetchurl {
1944 src = fetchurl {
1945 url = "https://pypi.python.org/packages/bb/0a/45e5aa80dc135889594bb371c082d20fb7ee7303b174874c996888cc8511/uwsgi-2.0.15.tar.gz";
1945 url = "https://pypi.python.org/packages/bb/0a/45e5aa80dc135889594bb371c082d20fb7ee7303b174874c996888cc8511/uwsgi-2.0.15.tar.gz";
1946 md5 = "fc50bd9e83b7602fa474b032167010a7";
1946 md5 = "fc50bd9e83b7602fa474b032167010a7";
1947 };
1947 };
1948 meta = {
1948 meta = {
1949 license = [ pkgs.lib.licenses.gpl2 ];
1949 license = [ pkgs.lib.licenses.gpl2 ];
1950 };
1950 };
1951 };
1951 };
1952 urllib3 = super.buildPythonPackage {
1952 urllib3 = super.buildPythonPackage {
1953 name = "urllib3-1.16";
1953 name = "urllib3-1.16";
1954 buildInputs = with self; [];
1954 buildInputs = with self; [];
1955 doCheck = false;
1955 doCheck = false;
1956 propagatedBuildInputs = with self; [];
1956 propagatedBuildInputs = with self; [];
1957 src = fetchurl {
1957 src = fetchurl {
1958 url = "https://pypi.python.org/packages/3b/f0/e763169124e3f5db0926bc3dbfcd580a105f9ca44cf5d8e6c7a803c9f6b5/urllib3-1.16.tar.gz";
1958 url = "https://pypi.python.org/packages/3b/f0/e763169124e3f5db0926bc3dbfcd580a105f9ca44cf5d8e6c7a803c9f6b5/urllib3-1.16.tar.gz";
1959 md5 = "fcaab1c5385c57deeb7053d3d7d81d59";
1959 md5 = "fcaab1c5385c57deeb7053d3d7d81d59";
1960 };
1960 };
1961 meta = {
1961 meta = {
1962 license = [ pkgs.lib.licenses.mit ];
1962 license = [ pkgs.lib.licenses.mit ];
1963 };
1963 };
1964 };
1964 };
1965 venusian = super.buildPythonPackage {
1965 venusian = super.buildPythonPackage {
1966 name = "venusian-1.1.0";
1966 name = "venusian-1.1.0";
1967 buildInputs = with self; [];
1967 buildInputs = with self; [];
1968 doCheck = false;
1968 doCheck = false;
1969 propagatedBuildInputs = with self; [];
1969 propagatedBuildInputs = with self; [];
1970 src = fetchurl {
1970 src = fetchurl {
1971 url = "https://pypi.python.org/packages/38/24/b4b470ab9e0a2e2e9b9030c7735828c8934b4c6b45befd1bb713ec2aeb2d/venusian-1.1.0.tar.gz";
1971 url = "https://pypi.python.org/packages/38/24/b4b470ab9e0a2e2e9b9030c7735828c8934b4c6b45befd1bb713ec2aeb2d/venusian-1.1.0.tar.gz";
1972 md5 = "56bc5e6756e4bda37bcdb94f74a72b8f";
1972 md5 = "56bc5e6756e4bda37bcdb94f74a72b8f";
1973 };
1973 };
1974 meta = {
1974 meta = {
1975 license = [ { fullName = "BSD-derived (http://www.repoze.org/LICENSE.txt)"; } ];
1975 license = [ { fullName = "BSD-derived (http://www.repoze.org/LICENSE.txt)"; } ];
1976 };
1976 };
1977 };
1977 };
1978 waitress = super.buildPythonPackage {
1978 waitress = super.buildPythonPackage {
1979 name = "waitress-1.0.2";
1979 name = "waitress-1.0.2";
1980 buildInputs = with self; [];
1980 buildInputs = with self; [];
1981 doCheck = false;
1981 doCheck = false;
1982 propagatedBuildInputs = with self; [];
1982 propagatedBuildInputs = with self; [];
1983 src = fetchurl {
1983 src = fetchurl {
1984 url = "https://pypi.python.org/packages/cd/f4/400d00863afa1e03618e31fd7e2092479a71b8c9718b00eb1eeb603746c6/waitress-1.0.2.tar.gz";
1984 url = "https://pypi.python.org/packages/cd/f4/400d00863afa1e03618e31fd7e2092479a71b8c9718b00eb1eeb603746c6/waitress-1.0.2.tar.gz";
1985 md5 = "b968f39e95d609f6194c6e50425d4bb7";
1985 md5 = "b968f39e95d609f6194c6e50425d4bb7";
1986 };
1986 };
1987 meta = {
1987 meta = {
1988 license = [ pkgs.lib.licenses.zpt21 ];
1988 license = [ pkgs.lib.licenses.zpt21 ];
1989 };
1989 };
1990 };
1990 };
1991 wcwidth = super.buildPythonPackage {
1991 wcwidth = super.buildPythonPackage {
1992 name = "wcwidth-0.1.7";
1992 name = "wcwidth-0.1.7";
1993 buildInputs = with self; [];
1993 buildInputs = with self; [];
1994 doCheck = false;
1994 doCheck = false;
1995 propagatedBuildInputs = with self; [];
1995 propagatedBuildInputs = with self; [];
1996 src = fetchurl {
1996 src = fetchurl {
1997 url = "https://pypi.python.org/packages/55/11/e4a2bb08bb450fdbd42cc709dd40de4ed2c472cf0ccb9e64af22279c5495/wcwidth-0.1.7.tar.gz";
1997 url = "https://pypi.python.org/packages/55/11/e4a2bb08bb450fdbd42cc709dd40de4ed2c472cf0ccb9e64af22279c5495/wcwidth-0.1.7.tar.gz";
1998 md5 = "b3b6a0a08f0c8a34d1de8cf44150a4ad";
1998 md5 = "b3b6a0a08f0c8a34d1de8cf44150a4ad";
1999 };
1999 };
2000 meta = {
2000 meta = {
2001 license = [ pkgs.lib.licenses.mit ];
2001 license = [ pkgs.lib.licenses.mit ];
2002 };
2002 };
2003 };
2003 };
2004 ws4py = super.buildPythonPackage {
2004 ws4py = super.buildPythonPackage {
2005 name = "ws4py-0.3.5";
2005 name = "ws4py-0.3.5";
2006 buildInputs = with self; [];
2006 buildInputs = with self; [];
2007 doCheck = false;
2007 doCheck = false;
2008 propagatedBuildInputs = with self; [];
2008 propagatedBuildInputs = with self; [];
2009 src = fetchurl {
2009 src = fetchurl {
2010 url = "https://pypi.python.org/packages/b6/4f/34af703be86939629479e74d6e650e39f3bd73b3b09212c34e5125764cbc/ws4py-0.3.5.zip";
2010 url = "https://pypi.python.org/packages/b6/4f/34af703be86939629479e74d6e650e39f3bd73b3b09212c34e5125764cbc/ws4py-0.3.5.zip";
2011 md5 = "a261b75c20b980e55ce7451a3576a867";
2011 md5 = "a261b75c20b980e55ce7451a3576a867";
2012 };
2012 };
2013 meta = {
2013 meta = {
2014 license = [ pkgs.lib.licenses.bsdOriginal ];
2014 license = [ pkgs.lib.licenses.bsdOriginal ];
2015 };
2015 };
2016 };
2016 };
2017 wsgiref = super.buildPythonPackage {
2017 wsgiref = super.buildPythonPackage {
2018 name = "wsgiref-0.1.2";
2018 name = "wsgiref-0.1.2";
2019 buildInputs = with self; [];
2019 buildInputs = with self; [];
2020 doCheck = false;
2020 doCheck = false;
2021 propagatedBuildInputs = with self; [];
2021 propagatedBuildInputs = with self; [];
2022 src = fetchurl {
2022 src = fetchurl {
2023 url = "https://pypi.python.org/packages/41/9e/309259ce8dff8c596e8c26df86dbc4e848b9249fd36797fd60be456f03fc/wsgiref-0.1.2.zip";
2023 url = "https://pypi.python.org/packages/41/9e/309259ce8dff8c596e8c26df86dbc4e848b9249fd36797fd60be456f03fc/wsgiref-0.1.2.zip";
2024 md5 = "29b146e6ebd0f9fb119fe321f7bcf6cb";
2024 md5 = "29b146e6ebd0f9fb119fe321f7bcf6cb";
2025 };
2025 };
2026 meta = {
2026 meta = {
2027 license = [ { fullName = "PSF or ZPL"; } ];
2027 license = [ { fullName = "PSF or ZPL"; } ];
2028 };
2028 };
2029 };
2029 };
2030 zope.cachedescriptors = super.buildPythonPackage {
2030 zope.cachedescriptors = super.buildPythonPackage {
2031 name = "zope.cachedescriptors-4.0.0";
2031 name = "zope.cachedescriptors-4.0.0";
2032 buildInputs = with self; [];
2032 buildInputs = with self; [];
2033 doCheck = false;
2033 doCheck = false;
2034 propagatedBuildInputs = with self; [setuptools];
2034 propagatedBuildInputs = with self; [setuptools];
2035 src = fetchurl {
2035 src = fetchurl {
2036 url = "https://pypi.python.org/packages/40/33/694b6644c37f28553f4b9f20b3c3a20fb709a22574dff20b5bdffb09ecd5/zope.cachedescriptors-4.0.0.tar.gz";
2036 url = "https://pypi.python.org/packages/40/33/694b6644c37f28553f4b9f20b3c3a20fb709a22574dff20b5bdffb09ecd5/zope.cachedescriptors-4.0.0.tar.gz";
2037 md5 = "8d308de8c936792c8e758058fcb7d0f0";
2037 md5 = "8d308de8c936792c8e758058fcb7d0f0";
2038 };
2038 };
2039 meta = {
2039 meta = {
2040 license = [ pkgs.lib.licenses.zpt21 ];
2040 license = [ pkgs.lib.licenses.zpt21 ];
2041 };
2041 };
2042 };
2042 };
2043 zope.deprecation = super.buildPythonPackage {
2043 zope.deprecation = super.buildPythonPackage {
2044 name = "zope.deprecation-4.1.2";
2044 name = "zope.deprecation-4.1.2";
2045 buildInputs = with self; [];
2045 buildInputs = with self; [];
2046 doCheck = false;
2046 doCheck = false;
2047 propagatedBuildInputs = with self; [setuptools];
2047 propagatedBuildInputs = with self; [setuptools];
2048 src = fetchurl {
2048 src = fetchurl {
2049 url = "https://pypi.python.org/packages/c1/d3/3919492d5e57d8dd01b36f30b34fc8404a30577392b1eb817c303499ad20/zope.deprecation-4.1.2.tar.gz";
2049 url = "https://pypi.python.org/packages/c1/d3/3919492d5e57d8dd01b36f30b34fc8404a30577392b1eb817c303499ad20/zope.deprecation-4.1.2.tar.gz";
2050 md5 = "e9a663ded58f4f9f7881beb56cae2782";
2050 md5 = "e9a663ded58f4f9f7881beb56cae2782";
2051 };
2051 };
2052 meta = {
2052 meta = {
2053 license = [ pkgs.lib.licenses.zpt21 ];
2053 license = [ pkgs.lib.licenses.zpt21 ];
2054 };
2054 };
2055 };
2055 };
2056 zope.event = super.buildPythonPackage {
2056 zope.event = super.buildPythonPackage {
2057 name = "zope.event-4.0.3";
2057 name = "zope.event-4.0.3";
2058 buildInputs = with self; [];
2058 buildInputs = with self; [];
2059 doCheck = false;
2059 doCheck = false;
2060 propagatedBuildInputs = with self; [setuptools];
2060 propagatedBuildInputs = with self; [setuptools];
2061 src = fetchurl {
2061 src = fetchurl {
2062 url = "https://pypi.python.org/packages/c1/29/91ba884d7d6d96691df592e9e9c2bfa57a47040ec1ff47eff18c85137152/zope.event-4.0.3.tar.gz";
2062 url = "https://pypi.python.org/packages/c1/29/91ba884d7d6d96691df592e9e9c2bfa57a47040ec1ff47eff18c85137152/zope.event-4.0.3.tar.gz";
2063 md5 = "9a3780916332b18b8b85f522bcc3e249";
2063 md5 = "9a3780916332b18b8b85f522bcc3e249";
2064 };
2064 };
2065 meta = {
2065 meta = {
2066 license = [ pkgs.lib.licenses.zpt21 ];
2066 license = [ pkgs.lib.licenses.zpt21 ];
2067 };
2067 };
2068 };
2068 };
2069 zope.interface = super.buildPythonPackage {
2069 zope.interface = super.buildPythonPackage {
2070 name = "zope.interface-4.1.3";
2070 name = "zope.interface-4.1.3";
2071 buildInputs = with self; [];
2071 buildInputs = with self; [];
2072 doCheck = false;
2072 doCheck = false;
2073 propagatedBuildInputs = with self; [setuptools];
2073 propagatedBuildInputs = with self; [setuptools];
2074 src = fetchurl {
2074 src = fetchurl {
2075 url = "https://pypi.python.org/packages/9d/81/2509ca3c6f59080123c1a8a97125eb48414022618cec0e64eb1313727bfe/zope.interface-4.1.3.tar.gz";
2075 url = "https://pypi.python.org/packages/9d/81/2509ca3c6f59080123c1a8a97125eb48414022618cec0e64eb1313727bfe/zope.interface-4.1.3.tar.gz";
2076 md5 = "9ae3d24c0c7415deb249dd1a132f0f79";
2076 md5 = "9ae3d24c0c7415deb249dd1a132f0f79";
2077 };
2077 };
2078 meta = {
2078 meta = {
2079 license = [ pkgs.lib.licenses.zpt21 ];
2079 license = [ pkgs.lib.licenses.zpt21 ];
2080 };
2080 };
2081 };
2081 };
2082
2082
2083 ### Test requirements
2083 ### Test requirements
2084
2084
2085
2085
2086 }
2086 }
@@ -1,135 +1,135 b''
1 ## core
1 ## core
2 setuptools==30.1.0
2 setuptools==30.1.0
3 setuptools-scm==1.15.0
3 setuptools-scm==1.15.0
4
4
5 amqplib==1.0.2
5 amqplib==1.0.2
6 anyjson==0.3.3
6 anyjson==0.3.3
7 authomatic==0.1.0.post1
7 authomatic==0.1.0.post1
8 Babel==1.3
8 Babel==1.3
9 Beaker==1.9.0
9 Beaker==1.9.0
10 celery==2.2.10
10 celery==2.2.10
11 Chameleon==2.24
11 Chameleon==2.24
12 channelstream==0.5.2
12 channelstream==0.5.2
13 click==5.1
13 click==5.1
14 colander==1.3.3
14 colander==1.3.3
15 configobj==5.0.6
15 configobj==5.0.6
16 cssselect==1.0.1
16 cssselect==1.0.1
17 decorator==4.0.11
17 decorator==4.0.11
18 deform==2.0.4
18 deform==2.0.4
19 docutils==0.13.1
19 docutils==0.13.1
20 dogpile.cache==0.6.4
20 dogpile.cache==0.6.4
21 dogpile.core==0.4.1
21 dogpile.core==0.4.1
22 ecdsa==0.11
22 ecdsa==0.13
23 FormEncode==1.2.4
23 FormEncode==1.2.4
24 future==0.14.3
24 future==0.14.3
25 futures==3.0.2
25 futures==3.0.2
26 gnureadline==6.3.3
26 gnureadline==6.3.3
27 infrae.cache==1.0.1
27 infrae.cache==1.0.1
28 iso8601==0.1.11
28 iso8601==0.1.11
29 itsdangerous==0.24
29 itsdangerous==0.24
30 Jinja2==2.7.3
30 Jinja2==2.7.3
31 kombu==1.5.1
31 kombu==1.5.1
32 lxml==3.7.3
32 lxml==3.7.3
33 Mako==1.0.6
33 Mako==1.0.6
34 Markdown==2.6.8
34 Markdown==2.6.8
35 MarkupSafe==0.23
35 MarkupSafe==0.23
36 meld3==1.0.2
36 meld3==1.0.2
37 msgpack-python==0.4.8
37 msgpack-python==0.4.8
38 MySQL-python==1.2.5
38 MySQL-python==1.2.5
39 nose==1.3.6
39 nose==1.3.6
40 objgraph==3.1.0
40 objgraph==3.1.0
41 packaging==15.2
41 packaging==15.2
42 paramiko==1.15.1
43 Paste==2.0.3
42 Paste==2.0.3
44 PasteDeploy==1.5.2
43 PasteDeploy==1.5.2
45 PasteScript==1.7.5
44 PasteScript==1.7.5
46 pathlib2==2.3.0
45 pathlib2==2.3.0
47 psutil==4.3.1
46 psutil==4.3.1
48 psycopg2==2.7.1
47 psycopg2==2.7.1
49 py-bcrypt==0.4
48 py-bcrypt==0.4
50 pycrypto==2.6.1
49 pycrypto==2.6.1
51 pycurl==7.19.5
50 pycurl==7.19.5
52 pyflakes==0.8.1
51 pyflakes==0.8.1
53 pygments-markdown-lexer==0.1.0.dev39
52 pygments-markdown-lexer==0.1.0.dev39
54 Pygments==2.2.0
53 Pygments==2.2.0
55 pyparsing==1.5.7
54 pyparsing==1.5.7
56 pyramid-beaker==0.8
55 pyramid-beaker==0.8
57 pyramid-debugtoolbar==4.2.1
56 pyramid-debugtoolbar==4.2.1
58 pyramid-jinja2==2.5
57 pyramid-jinja2==2.5
59 pyramid-mako==1.0.2
58 pyramid-mako==1.0.2
60 pyramid==1.9.0
59 pyramid==1.9.0
61 pysqlite==2.8.3
60 pysqlite==2.8.3
62 python-dateutil==2.1
61 python-dateutil==2.1
63 python-ldap==2.4.40
62 python-ldap==2.4.40
64 python-memcached==1.58
63 python-memcached==1.58
65 python-pam==1.8.2
64 python-pam==1.8.2
66 pytz==2015.4
65 pytz==2015.4
67 pyzmq==14.6.0
66 pyzmq==14.6.0
68 recaptcha-client==1.0.6
67 recaptcha-client==1.0.6
69 repoze.lru==0.6
68 repoze.lru==0.6
70 requests==2.9.1
69 requests==2.9.1
71 Routes==1.13
70 Routes==1.13
72 setproctitle==1.1.8
71 setproctitle==1.1.8
73 simplejson==3.11.1
72 simplejson==3.11.1
74 six==1.9.0
73 six==1.9.0
75 Sphinx==1.2.2
74 Sphinx==1.2.2
76 SQLAlchemy==1.1.11
75 SQLAlchemy==1.1.11
76 sshpubkeys==2.2.0
77 subprocess32==3.2.7
77 subprocess32==3.2.7
78 supervisor==3.3.2
78 supervisor==3.3.2
79 Tempita==0.5.2
79 Tempita==0.5.2
80 translationstring==1.3
80 translationstring==1.3
81 trollius==1.0.4
81 trollius==1.0.4
82 urllib3==1.16
82 urllib3==1.16
83 URLObject==2.4.0
83 URLObject==2.4.0
84 venusian==1.1.0
84 venusian==1.1.0
85 WebError==0.10.3
85 WebError==0.10.3
86 WebHelpers2==2.0
86 WebHelpers2==2.0
87 WebHelpers==1.3
87 WebHelpers==1.3
88 WebOb==1.7.3
88 WebOb==1.7.3
89 Whoosh==2.7.4
89 Whoosh==2.7.4
90 wsgiref==0.1.2
90 wsgiref==0.1.2
91 zope.cachedescriptors==4.0.0
91 zope.cachedescriptors==4.0.0
92 zope.deprecation==4.1.2
92 zope.deprecation==4.1.2
93 zope.event==4.0.3
93 zope.event==4.0.3
94 zope.interface==4.1.3
94 zope.interface==4.1.3
95
95
96 ## customized/patched libs
96 ## customized/patched libs
97 # our patched version of Pylons==1.0.2
97 # our patched version of Pylons==1.0.2
98 https://code.rhodecode.com/upstream/pylons/archive/707354ee4261b9c10450404fc9852ccea4fd667d.tar.gz?md5=f26633726fa2cd3a340316ee6a5d218f#egg=Pylons==1.0.2.rhodecode-patch-1
98 https://code.rhodecode.com/upstream/pylons/archive/707354ee4261b9c10450404fc9852ccea4fd667d.tar.gz?md5=f26633726fa2cd3a340316ee6a5d218f#egg=Pylons==1.0.2.rhodecode-patch-1
99 # not released py-gfm==0.1.3
99 # not released py-gfm==0.1.3
100 https://code.rhodecode.com/upstream/py-gfm/archive/0d66a19bc16e3d49de273c0f797d4e4781e8c0f2.tar.gz?md5=0d0d5385bfb629eea636a80b9c2bfd16#egg=py-gfm==0.1.3.rhodecode-upstream1
100 https://code.rhodecode.com/upstream/py-gfm/archive/0d66a19bc16e3d49de273c0f797d4e4781e8c0f2.tar.gz?md5=0d0d5385bfb629eea636a80b9c2bfd16#egg=py-gfm==0.1.3.rhodecode-upstream1
101
101
102 # IPYTHON RENDERING
102 # IPYTHON RENDERING
103 # entrypoints backport, pypi version doesn't support egg installs
103 # entrypoints backport, pypi version doesn't support egg installs
104 https://code.rhodecode.com/upstream/entrypoints/archive/96e6d645684e1af3d7df5b5272f3fe85a546b233.tar.gz?md5=7db37771aea9ac9fefe093e5d6987313#egg=entrypoints==0.2.2.rhodecode-upstream1
104 https://code.rhodecode.com/upstream/entrypoints/archive/96e6d645684e1af3d7df5b5272f3fe85a546b233.tar.gz?md5=7db37771aea9ac9fefe093e5d6987313#egg=entrypoints==0.2.2.rhodecode-upstream1
105 nbconvert==5.1.1
105 nbconvert==5.1.1
106 nbformat==4.3.0
106 nbformat==4.3.0
107 jupyter_client==5.0.0
107 jupyter_client==5.0.0
108
108
109 ## cli tools
109 ## cli tools
110 alembic==0.9.2
110 alembic==0.9.2
111 invoke==0.13.0
111 invoke==0.13.0
112 bumpversion==0.5.3
112 bumpversion==0.5.3
113 transifex-client==0.10
113 transifex-client==0.10
114
114
115 ## http servers
115 ## http servers
116 gevent==1.2.2
116 gevent==1.2.2
117 greenlet==0.4.12
117 greenlet==0.4.12
118 gunicorn==19.7.1
118 gunicorn==19.7.1
119 waitress==1.0.2
119 waitress==1.0.2
120 uWSGI==2.0.15
120 uWSGI==2.0.15
121
121
122 ## debug
122 ## debug
123 ipdb==0.10.3
123 ipdb==0.10.3
124 ipython==5.1.0
124 ipython==5.1.0
125 CProfileV==1.0.7
125 CProfileV==1.0.7
126 bottle==0.12.8
126 bottle==0.12.8
127
127
128 ## rhodecode-tools, special case
128 ## rhodecode-tools, special case
129 https://code.rhodecode.com/rhodecode-tools-ce/archive/v0.12.0.tar.gz?md5=9ca040356fa7e38d3f64529a4cffdca4#egg=rhodecode-tools==0.12.0
129 https://code.rhodecode.com/rhodecode-tools-ce/archive/v0.12.0.tar.gz?md5=9ca040356fa7e38d3f64529a4cffdca4#egg=rhodecode-tools==0.12.0
130
130
131 ## appenlight
131 ## appenlight
132 appenlight-client==0.6.21
132 appenlight-client==0.6.21
133
133
134 ## test related requirements
134 ## test related requirements
135 -r requirements_test.txt
135 -r requirements_test.txt
@@ -1,63 +1,63 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2
2
3 # Copyright (C) 2010-2017 RhodeCode GmbH
3 # Copyright (C) 2010-2017 RhodeCode GmbH
4 #
4 #
5 # This program is free software: you can redistribute it and/or modify
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License, version 3
6 # it under the terms of the GNU Affero General Public License, version 3
7 # (only), as published by the Free Software Foundation.
7 # (only), as published by the Free Software Foundation.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU Affero General Public License
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 #
16 #
17 # This program is dual-licensed. If you wish to learn more about the
17 # This program is dual-licensed. If you wish to learn more about the
18 # RhodeCode Enterprise Edition, including its added features, Support services,
18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
20
21 """
21 """
22
22
23 RhodeCode, a web based repository management software
23 RhodeCode, a web based repository management software
24 versioning implementation: http://www.python.org/dev/peps/pep-0386/
24 versioning implementation: http://www.python.org/dev/peps/pep-0386/
25 """
25 """
26
26
27 import os
27 import os
28 import sys
28 import sys
29 import platform
29 import platform
30
30
31 VERSION = tuple(open(os.path.join(
31 VERSION = tuple(open(os.path.join(
32 os.path.dirname(__file__), 'VERSION')).read().split('.'))
32 os.path.dirname(__file__), 'VERSION')).read().split('.'))
33
33
34 BACKENDS = {
34 BACKENDS = {
35 'hg': 'Mercurial repository',
35 'hg': 'Mercurial repository',
36 'git': 'Git repository',
36 'git': 'Git repository',
37 'svn': 'Subversion repository',
37 'svn': 'Subversion repository',
38 }
38 }
39
39
40 CELERY_ENABLED = False
40 CELERY_ENABLED = False
41 CELERY_EAGER = False
41 CELERY_EAGER = False
42
42
43 # link to config for pylons
43 # link to config for pylons
44 CONFIG = {}
44 CONFIG = {}
45
45
46 # Populated with the settings dictionary from application init in
46 # Populated with the settings dictionary from application init in
47 # rhodecode.conf.environment.load_pyramid_environment
47 # rhodecode.conf.environment.load_pyramid_environment
48 PYRAMID_SETTINGS = {}
48 PYRAMID_SETTINGS = {}
49
49
50 # Linked module for extensions
50 # Linked module for extensions
51 EXTENSIONS = {}
51 EXTENSIONS = {}
52
52
53 __version__ = ('.'.join((str(each) for each in VERSION[:3])))
53 __version__ = ('.'.join((str(each) for each in VERSION[:3])))
54 __dbversion__ = 79 # defines current db version for migrations
54 __dbversion__ = 80 # defines current db version for migrations
55 __platform__ = platform.system()
55 __platform__ = platform.system()
56 __license__ = 'AGPLv3, and Commercial License'
56 __license__ = 'AGPLv3, and Commercial License'
57 __author__ = 'RhodeCode GmbH'
57 __author__ = 'RhodeCode GmbH'
58 __url__ = 'https://code.rhodecode.com'
58 __url__ = 'https://code.rhodecode.com'
59
59
60 is_windows = __platform__ in ['Windows']
60 is_windows = __platform__ in ['Windows']
61 is_unix = not is_windows
61 is_unix = not is_windows
62 is_test = False
62 is_test = False
63 disable_error_handler = False
63 disable_error_handler = False
@@ -1,192 +1,206 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2
2
3 # Copyright (C) 2016-2017 RhodeCode GmbH
3 # Copyright (C) 2016-2017 RhodeCode GmbH
4 #
4 #
5 # This program is free software: you can redistribute it and/or modify
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License, version 3
6 # it under the terms of the GNU Affero General Public License, version 3
7 # (only), as published by the Free Software Foundation.
7 # (only), as published by the Free Software Foundation.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU Affero General Public License
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 #
16 #
17 # This program is dual-licensed. If you wish to learn more about the
17 # This program is dual-licensed. If you wish to learn more about the
18 # RhodeCode Enterprise Edition, including its added features, Support services,
18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
20
21
21
22 from rhodecode.apps.admin.navigation import NavigationRegistry
22 from rhodecode.apps.admin.navigation import NavigationRegistry
23 from rhodecode.config.routing import ADMIN_PREFIX
23 from rhodecode.config.routing import ADMIN_PREFIX
24 from rhodecode.lib.utils2 import str2bool
24 from rhodecode.lib.utils2 import str2bool
25
25
26
26
27 def admin_routes(config):
27 def admin_routes(config):
28 """
28 """
29 Admin prefixed routes
29 Admin prefixed routes
30 """
30 """
31
31
32 config.add_route(
32 config.add_route(
33 name='admin_audit_logs',
33 name='admin_audit_logs',
34 pattern='/audit_logs')
34 pattern='/audit_logs')
35
35
36 config.add_route(
36 config.add_route(
37 name='pull_requests_global_0', # backward compat
37 name='pull_requests_global_0', # backward compat
38 pattern='/pull_requests/{pull_request_id:\d+}')
38 pattern='/pull_requests/{pull_request_id:\d+}')
39 config.add_route(
39 config.add_route(
40 name='pull_requests_global_1', # backward compat
40 name='pull_requests_global_1', # backward compat
41 pattern='/pull-requests/{pull_request_id:\d+}')
41 pattern='/pull-requests/{pull_request_id:\d+}')
42 config.add_route(
42 config.add_route(
43 name='pull_requests_global',
43 name='pull_requests_global',
44 pattern='/pull-request/{pull_request_id:\d+}')
44 pattern='/pull-request/{pull_request_id:\d+}')
45
45
46 config.add_route(
46 config.add_route(
47 name='admin_settings_open_source',
47 name='admin_settings_open_source',
48 pattern='/settings/open_source')
48 pattern='/settings/open_source')
49 config.add_route(
49 config.add_route(
50 name='admin_settings_vcs_svn_generate_cfg',
50 name='admin_settings_vcs_svn_generate_cfg',
51 pattern='/settings/vcs/svn_generate_cfg')
51 pattern='/settings/vcs/svn_generate_cfg')
52
52
53 config.add_route(
53 config.add_route(
54 name='admin_settings_system',
54 name='admin_settings_system',
55 pattern='/settings/system')
55 pattern='/settings/system')
56 config.add_route(
56 config.add_route(
57 name='admin_settings_system_update',
57 name='admin_settings_system_update',
58 pattern='/settings/system/updates')
58 pattern='/settings/system/updates')
59
59
60 config.add_route(
60 config.add_route(
61 name='admin_settings_sessions',
61 name='admin_settings_sessions',
62 pattern='/settings/sessions')
62 pattern='/settings/sessions')
63 config.add_route(
63 config.add_route(
64 name='admin_settings_sessions_cleanup',
64 name='admin_settings_sessions_cleanup',
65 pattern='/settings/sessions/cleanup')
65 pattern='/settings/sessions/cleanup')
66
66
67 config.add_route(
67 config.add_route(
68 name='admin_settings_process_management',
68 name='admin_settings_process_management',
69 pattern='/settings/process_management')
69 pattern='/settings/process_management')
70 config.add_route(
70 config.add_route(
71 name='admin_settings_process_management_signal',
71 name='admin_settings_process_management_signal',
72 pattern='/settings/process_management/signal')
72 pattern='/settings/process_management/signal')
73
73
74 # global permissions
74 # global permissions
75
75
76 config.add_route(
76 config.add_route(
77 name='admin_permissions_application',
77 name='admin_permissions_application',
78 pattern='/permissions/application')
78 pattern='/permissions/application')
79 config.add_route(
79 config.add_route(
80 name='admin_permissions_application_update',
80 name='admin_permissions_application_update',
81 pattern='/permissions/application/update')
81 pattern='/permissions/application/update')
82
82
83 config.add_route(
83 config.add_route(
84 name='admin_permissions_global',
84 name='admin_permissions_global',
85 pattern='/permissions/global')
85 pattern='/permissions/global')
86 config.add_route(
86 config.add_route(
87 name='admin_permissions_global_update',
87 name='admin_permissions_global_update',
88 pattern='/permissions/global/update')
88 pattern='/permissions/global/update')
89
89
90 config.add_route(
90 config.add_route(
91 name='admin_permissions_object',
91 name='admin_permissions_object',
92 pattern='/permissions/object')
92 pattern='/permissions/object')
93 config.add_route(
93 config.add_route(
94 name='admin_permissions_object_update',
94 name='admin_permissions_object_update',
95 pattern='/permissions/object/update')
95 pattern='/permissions/object/update')
96
96
97 config.add_route(
97 config.add_route(
98 name='admin_permissions_ips',
98 name='admin_permissions_ips',
99 pattern='/permissions/ips')
99 pattern='/permissions/ips')
100
100
101 config.add_route(
101 config.add_route(
102 name='admin_permissions_overview',
102 name='admin_permissions_overview',
103 pattern='/permissions/overview')
103 pattern='/permissions/overview')
104
104
105 config.add_route(
105 config.add_route(
106 name='admin_permissions_auth_token_access',
106 name='admin_permissions_auth_token_access',
107 pattern='/permissions/auth_token_access')
107 pattern='/permissions/auth_token_access')
108
108
109 # users admin
109 # users admin
110 config.add_route(
110 config.add_route(
111 name='users',
111 name='users',
112 pattern='/users')
112 pattern='/users')
113
113
114 config.add_route(
114 config.add_route(
115 name='users_data',
115 name='users_data',
116 pattern='/users_data')
116 pattern='/users_data')
117
117
118 # user auth tokens
118 # user auth tokens
119 config.add_route(
119 config.add_route(
120 name='edit_user_auth_tokens',
120 name='edit_user_auth_tokens',
121 pattern='/users/{user_id:\d+}/edit/auth_tokens')
121 pattern='/users/{user_id:\d+}/edit/auth_tokens')
122 config.add_route(
122 config.add_route(
123 name='edit_user_auth_tokens_add',
123 name='edit_user_auth_tokens_add',
124 pattern='/users/{user_id:\d+}/edit/auth_tokens/new')
124 pattern='/users/{user_id:\d+}/edit/auth_tokens/new')
125 config.add_route(
125 config.add_route(
126 name='edit_user_auth_tokens_delete',
126 name='edit_user_auth_tokens_delete',
127 pattern='/users/{user_id:\d+}/edit/auth_tokens/delete')
127 pattern='/users/{user_id:\d+}/edit/auth_tokens/delete')
128
128
129 # user ssh keys
130 config.add_route(
131 name='edit_user_ssh_keys',
132 pattern='/users/{user_id:\d+}/edit/ssh_keys')
133 config.add_route(
134 name='edit_user_ssh_keys_generate_keypair',
135 pattern='/users/{user_id:\d+}/edit/ssh_keys/generate')
136 config.add_route(
137 name='edit_user_ssh_keys_add',
138 pattern='/users/{user_id:\d+}/edit/ssh_keys/new')
139 config.add_route(
140 name='edit_user_ssh_keys_delete',
141 pattern='/users/{user_id:\d+}/edit/ssh_keys/delete')
142
129 # user emails
143 # user emails
130 config.add_route(
144 config.add_route(
131 name='edit_user_emails',
145 name='edit_user_emails',
132 pattern='/users/{user_id:\d+}/edit/emails')
146 pattern='/users/{user_id:\d+}/edit/emails')
133 config.add_route(
147 config.add_route(
134 name='edit_user_emails_add',
148 name='edit_user_emails_add',
135 pattern='/users/{user_id:\d+}/edit/emails/new')
149 pattern='/users/{user_id:\d+}/edit/emails/new')
136 config.add_route(
150 config.add_route(
137 name='edit_user_emails_delete',
151 name='edit_user_emails_delete',
138 pattern='/users/{user_id:\d+}/edit/emails/delete')
152 pattern='/users/{user_id:\d+}/edit/emails/delete')
139
153
140 # user IPs
154 # user IPs
141 config.add_route(
155 config.add_route(
142 name='edit_user_ips',
156 name='edit_user_ips',
143 pattern='/users/{user_id:\d+}/edit/ips')
157 pattern='/users/{user_id:\d+}/edit/ips')
144 config.add_route(
158 config.add_route(
145 name='edit_user_ips_add',
159 name='edit_user_ips_add',
146 pattern='/users/{user_id:\d+}/edit/ips/new')
160 pattern='/users/{user_id:\d+}/edit/ips/new')
147 config.add_route(
161 config.add_route(
148 name='edit_user_ips_delete',
162 name='edit_user_ips_delete',
149 pattern='/users/{user_id:\d+}/edit/ips/delete')
163 pattern='/users/{user_id:\d+}/edit/ips/delete')
150
164
151 # user groups management
165 # user groups management
152 config.add_route(
166 config.add_route(
153 name='edit_user_groups_management',
167 name='edit_user_groups_management',
154 pattern='/users/{user_id:\d+}/edit/groups_management')
168 pattern='/users/{user_id:\d+}/edit/groups_management')
155
169
156 config.add_route(
170 config.add_route(
157 name='edit_user_groups_management_updates',
171 name='edit_user_groups_management_updates',
158 pattern='/users/{user_id:\d+}/edit/edit_user_groups_management/updates')
172 pattern='/users/{user_id:\d+}/edit/edit_user_groups_management/updates')
159
173
160 # user audit logs
174 # user audit logs
161 config.add_route(
175 config.add_route(
162 name='edit_user_audit_logs',
176 name='edit_user_audit_logs',
163 pattern='/users/{user_id:\d+}/edit/audit')
177 pattern='/users/{user_id:\d+}/edit/audit')
164
178
165 # user groups admin
179 # user groups admin
166 config.add_route(
180 config.add_route(
167 name='user_groups',
181 name='user_groups',
168 pattern='/user_groups')
182 pattern='/user_groups')
169
183
170 config.add_route(
184 config.add_route(
171 name='user_groups_data',
185 name='user_groups_data',
172 pattern='/user_groups_data')
186 pattern='/user_groups_data')
173
187
174 config.add_route(
188 config.add_route(
175 name='user_group_members_data',
189 name='user_group_members_data',
176 pattern='/user_groups/{user_group_id:\d+}/members')
190 pattern='/user_groups/{user_group_id:\d+}/members')
177
191
178
192
179 def includeme(config):
193 def includeme(config):
180 settings = config.get_settings()
194 settings = config.get_settings()
181
195
182 # Create admin navigation registry and add it to the pyramid registry.
196 # Create admin navigation registry and add it to the pyramid registry.
183 labs_active = str2bool(settings.get('labs_settings_active', False))
197 labs_active = str2bool(settings.get('labs_settings_active', False))
184 navigation_registry = NavigationRegistry(labs_active=labs_active)
198 navigation_registry = NavigationRegistry(labs_active=labs_active)
185 config.registry.registerUtility(navigation_registry)
199 config.registry.registerUtility(navigation_registry)
186
200
187 # main admin routes
201 # main admin routes
188 config.add_route(name='admin_home', pattern=ADMIN_PREFIX)
202 config.add_route(name='admin_home', pattern=ADMIN_PREFIX)
189 config.include(admin_routes, route_prefix=ADMIN_PREFIX)
203 config.include(admin_routes, route_prefix=ADMIN_PREFIX)
190
204
191 # Scan module for configuration decorators.
205 # Scan module for configuration decorators.
192 config.scan('.views', ignore='.tests')
206 config.scan('.views', ignore='.tests')
@@ -1,510 +1,630 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2
2
3 # Copyright (C) 2016-2017 RhodeCode GmbH
3 # Copyright (C) 2016-2017 RhodeCode GmbH
4 #
4 #
5 # This program is free software: you can redistribute it and/or modify
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License, version 3
6 # it under the terms of the GNU Affero General Public License, version 3
7 # (only), as published by the Free Software Foundation.
7 # (only), as published by the Free Software Foundation.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU Affero General Public License
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 #
16 #
17 # This program is dual-licensed. If you wish to learn more about the
17 # This program is dual-licensed. If you wish to learn more about the
18 # RhodeCode Enterprise Edition, including its added features, Support services,
18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
20
21 import logging
21 import logging
22 import datetime
22 import datetime
23 import formencode
23 import formencode
24
24
25 from pyramid.httpexceptions import HTTPFound
25 from pyramid.httpexceptions import HTTPFound
26 from pyramid.view import view_config
26 from pyramid.view import view_config
27 from sqlalchemy.sql.functions import coalesce
27 from sqlalchemy.sql.functions import coalesce
28 from sqlalchemy.exc import IntegrityError
28
29
29 from rhodecode.apps._base import BaseAppView, DataGridAppView
30 from rhodecode.apps._base import BaseAppView, DataGridAppView
30
31
31 from rhodecode.lib import audit_logger
32 from rhodecode.lib import audit_logger
32 from rhodecode.lib.ext_json import json
33 from rhodecode.lib.ext_json import json
33 from rhodecode.lib.auth import (
34 from rhodecode.lib.auth import (
34 LoginRequired, HasPermissionAllDecorator, CSRFRequired)
35 LoginRequired, HasPermissionAllDecorator, CSRFRequired)
35 from rhodecode.lib import helpers as h
36 from rhodecode.lib import helpers as h
36 from rhodecode.lib.utils2 import safe_int, safe_unicode
37 from rhodecode.lib.utils2 import safe_int, safe_unicode
37 from rhodecode.model.auth_token import AuthTokenModel
38 from rhodecode.model.auth_token import AuthTokenModel
39 from rhodecode.model.ssh_key import SshKeyModel
38 from rhodecode.model.user import UserModel
40 from rhodecode.model.user import UserModel
39 from rhodecode.model.user_group import UserGroupModel
41 from rhodecode.model.user_group import UserGroupModel
40 from rhodecode.model.db import User, or_, UserIpMap, UserEmailMap, UserApiKeys
42 from rhodecode.model.db import (
43 or_, User, UserIpMap, UserEmailMap, UserApiKeys, UserSshKeys)
41 from rhodecode.model.meta import Session
44 from rhodecode.model.meta import Session
42
45
43 log = logging.getLogger(__name__)
46 log = logging.getLogger(__name__)
44
47
45
48
46 class AdminUsersView(BaseAppView, DataGridAppView):
49 class AdminUsersView(BaseAppView, DataGridAppView):
47 ALLOW_SCOPED_TOKENS = False
50 ALLOW_SCOPED_TOKENS = False
48 """
51 """
49 This view has alternative version inside EE, if modified please take a look
52 This view has alternative version inside EE, if modified please take a look
50 in there as well.
53 in there as well.
51 """
54 """
52
55
53 def load_default_context(self):
56 def load_default_context(self):
54 c = self._get_local_tmpl_context()
57 c = self._get_local_tmpl_context()
55 c.allow_scoped_tokens = self.ALLOW_SCOPED_TOKENS
58 c.allow_scoped_tokens = self.ALLOW_SCOPED_TOKENS
56 self._register_global_c(c)
59 self._register_global_c(c)
57 return c
60 return c
58
61
59 def _redirect_for_default_user(self, username):
62 def _redirect_for_default_user(self, username):
60 _ = self.request.translate
63 _ = self.request.translate
61 if username == User.DEFAULT_USER:
64 if username == User.DEFAULT_USER:
62 h.flash(_("You can't edit this user"), category='warning')
65 h.flash(_("You can't edit this user"), category='warning')
63 # TODO(marcink): redirect to 'users' admin panel once this
66 # TODO(marcink): redirect to 'users' admin panel once this
64 # is a pyramid view
67 # is a pyramid view
65 raise HTTPFound('/')
68 raise HTTPFound('/')
66
69
67 @HasPermissionAllDecorator('hg.admin')
70 @HasPermissionAllDecorator('hg.admin')
68 @view_config(
71 @view_config(
69 route_name='users', request_method='GET',
72 route_name='users', request_method='GET',
70 renderer='rhodecode:templates/admin/users/users.mako')
73 renderer='rhodecode:templates/admin/users/users.mako')
71 def users_list(self):
74 def users_list(self):
72 c = self.load_default_context()
75 c = self.load_default_context()
73 return self._get_template_context(c)
76 return self._get_template_context(c)
74
77
75 @HasPermissionAllDecorator('hg.admin')
78 @HasPermissionAllDecorator('hg.admin')
76 @view_config(
79 @view_config(
77 # renderer defined below
80 # renderer defined below
78 route_name='users_data', request_method='GET',
81 route_name='users_data', request_method='GET',
79 renderer='json_ext', xhr=True)
82 renderer='json_ext', xhr=True)
80 def users_list_data(self):
83 def users_list_data(self):
81 column_map = {
84 column_map = {
82 'first_name': 'name',
85 'first_name': 'name',
83 'last_name': 'lastname',
86 'last_name': 'lastname',
84 }
87 }
85 draw, start, limit = self._extract_chunk(self.request)
88 draw, start, limit = self._extract_chunk(self.request)
86 search_q, order_by, order_dir = self._extract_ordering(
89 search_q, order_by, order_dir = self._extract_ordering(
87 self.request, column_map=column_map)
90 self.request, column_map=column_map)
88
91
89 _render = self.request.get_partial_renderer(
92 _render = self.request.get_partial_renderer(
90 'data_table/_dt_elements.mako')
93 'data_table/_dt_elements.mako')
91
94
92 def user_actions(user_id, username):
95 def user_actions(user_id, username):
93 return _render("user_actions", user_id, username)
96 return _render("user_actions", user_id, username)
94
97
95 users_data_total_count = User.query()\
98 users_data_total_count = User.query()\
96 .filter(User.username != User.DEFAULT_USER) \
99 .filter(User.username != User.DEFAULT_USER) \
97 .count()
100 .count()
98
101
99 # json generate
102 # json generate
100 base_q = User.query().filter(User.username != User.DEFAULT_USER)
103 base_q = User.query().filter(User.username != User.DEFAULT_USER)
101
104
102 if search_q:
105 if search_q:
103 like_expression = u'%{}%'.format(safe_unicode(search_q))
106 like_expression = u'%{}%'.format(safe_unicode(search_q))
104 base_q = base_q.filter(or_(
107 base_q = base_q.filter(or_(
105 User.username.ilike(like_expression),
108 User.username.ilike(like_expression),
106 User._email.ilike(like_expression),
109 User._email.ilike(like_expression),
107 User.name.ilike(like_expression),
110 User.name.ilike(like_expression),
108 User.lastname.ilike(like_expression),
111 User.lastname.ilike(like_expression),
109 ))
112 ))
110
113
111 users_data_total_filtered_count = base_q.count()
114 users_data_total_filtered_count = base_q.count()
112
115
113 sort_col = getattr(User, order_by, None)
116 sort_col = getattr(User, order_by, None)
114 if sort_col:
117 if sort_col:
115 if order_dir == 'asc':
118 if order_dir == 'asc':
116 # handle null values properly to order by NULL last
119 # handle null values properly to order by NULL last
117 if order_by in ['last_activity']:
120 if order_by in ['last_activity']:
118 sort_col = coalesce(sort_col, datetime.date.max)
121 sort_col = coalesce(sort_col, datetime.date.max)
119 sort_col = sort_col.asc()
122 sort_col = sort_col.asc()
120 else:
123 else:
121 # handle null values properly to order by NULL last
124 # handle null values properly to order by NULL last
122 if order_by in ['last_activity']:
125 if order_by in ['last_activity']:
123 sort_col = coalesce(sort_col, datetime.date.min)
126 sort_col = coalesce(sort_col, datetime.date.min)
124 sort_col = sort_col.desc()
127 sort_col = sort_col.desc()
125
128
126 base_q = base_q.order_by(sort_col)
129 base_q = base_q.order_by(sort_col)
127 base_q = base_q.offset(start).limit(limit)
130 base_q = base_q.offset(start).limit(limit)
128
131
129 users_list = base_q.all()
132 users_list = base_q.all()
130
133
131 users_data = []
134 users_data = []
132 for user in users_list:
135 for user in users_list:
133 users_data.append({
136 users_data.append({
134 "username": h.gravatar_with_user(self.request, user.username),
137 "username": h.gravatar_with_user(self.request, user.username),
135 "email": user.email,
138 "email": user.email,
136 "first_name": user.first_name,
139 "first_name": user.first_name,
137 "last_name": user.last_name,
140 "last_name": user.last_name,
138 "last_login": h.format_date(user.last_login),
141 "last_login": h.format_date(user.last_login),
139 "last_activity": h.format_date(user.last_activity),
142 "last_activity": h.format_date(user.last_activity),
140 "active": h.bool2icon(user.active),
143 "active": h.bool2icon(user.active),
141 "active_raw": user.active,
144 "active_raw": user.active,
142 "admin": h.bool2icon(user.admin),
145 "admin": h.bool2icon(user.admin),
143 "extern_type": user.extern_type,
146 "extern_type": user.extern_type,
144 "extern_name": user.extern_name,
147 "extern_name": user.extern_name,
145 "action": user_actions(user.user_id, user.username),
148 "action": user_actions(user.user_id, user.username),
146 })
149 })
147
150
148 data = ({
151 data = ({
149 'draw': draw,
152 'draw': draw,
150 'data': users_data,
153 'data': users_data,
151 'recordsTotal': users_data_total_count,
154 'recordsTotal': users_data_total_count,
152 'recordsFiltered': users_data_total_filtered_count,
155 'recordsFiltered': users_data_total_filtered_count,
153 })
156 })
154
157
155 return data
158 return data
156
159
157 @LoginRequired()
160 @LoginRequired()
158 @HasPermissionAllDecorator('hg.admin')
161 @HasPermissionAllDecorator('hg.admin')
159 @view_config(
162 @view_config(
160 route_name='edit_user_auth_tokens', request_method='GET',
163 route_name='edit_user_auth_tokens', request_method='GET',
161 renderer='rhodecode:templates/admin/users/user_edit.mako')
164 renderer='rhodecode:templates/admin/users/user_edit.mako')
162 def auth_tokens(self):
165 def auth_tokens(self):
163 _ = self.request.translate
166 _ = self.request.translate
164 c = self.load_default_context()
167 c = self.load_default_context()
165
168
166 user_id = self.request.matchdict.get('user_id')
169 user_id = self.request.matchdict.get('user_id')
167 c.user = User.get_or_404(user_id)
170 c.user = User.get_or_404(user_id)
168 self._redirect_for_default_user(c.user.username)
171 self._redirect_for_default_user(c.user.username)
169
172
170 c.active = 'auth_tokens'
173 c.active = 'auth_tokens'
171
174
172 c.lifetime_values = [
175 c.lifetime_values = [
173 (str(-1), _('forever')),
176 (str(-1), _('forever')),
174 (str(5), _('5 minutes')),
177 (str(5), _('5 minutes')),
175 (str(60), _('1 hour')),
178 (str(60), _('1 hour')),
176 (str(60 * 24), _('1 day')),
179 (str(60 * 24), _('1 day')),
177 (str(60 * 24 * 30), _('1 month')),
180 (str(60 * 24 * 30), _('1 month')),
178 ]
181 ]
179 c.lifetime_options = [(c.lifetime_values, _("Lifetime"))]
182 c.lifetime_options = [(c.lifetime_values, _("Lifetime"))]
180 c.role_values = [
183 c.role_values = [
181 (x, AuthTokenModel.cls._get_role_name(x))
184 (x, AuthTokenModel.cls._get_role_name(x))
182 for x in AuthTokenModel.cls.ROLES]
185 for x in AuthTokenModel.cls.ROLES]
183 c.role_options = [(c.role_values, _("Role"))]
186 c.role_options = [(c.role_values, _("Role"))]
184 c.user_auth_tokens = AuthTokenModel().get_auth_tokens(
187 c.user_auth_tokens = AuthTokenModel().get_auth_tokens(
185 c.user.user_id, show_expired=True)
188 c.user.user_id, show_expired=True)
186 return self._get_template_context(c)
189 return self._get_template_context(c)
187
190
188 def maybe_attach_token_scope(self, token):
191 def maybe_attach_token_scope(self, token):
189 # implemented in EE edition
192 # implemented in EE edition
190 pass
193 pass
191
194
192 @LoginRequired()
195 @LoginRequired()
193 @HasPermissionAllDecorator('hg.admin')
196 @HasPermissionAllDecorator('hg.admin')
194 @CSRFRequired()
197 @CSRFRequired()
195 @view_config(
198 @view_config(
196 route_name='edit_user_auth_tokens_add', request_method='POST')
199 route_name='edit_user_auth_tokens_add', request_method='POST')
197 def auth_tokens_add(self):
200 def auth_tokens_add(self):
198 _ = self.request.translate
201 _ = self.request.translate
199 c = self.load_default_context()
202 c = self.load_default_context()
200
203
201 user_id = self.request.matchdict.get('user_id')
204 user_id = self.request.matchdict.get('user_id')
202 c.user = User.get_or_404(user_id)
205 c.user = User.get_or_404(user_id)
203
206
204 self._redirect_for_default_user(c.user.username)
207 self._redirect_for_default_user(c.user.username)
205
208
206 user_data = c.user.get_api_data()
209 user_data = c.user.get_api_data()
207 lifetime = safe_int(self.request.POST.get('lifetime'), -1)
210 lifetime = safe_int(self.request.POST.get('lifetime'), -1)
208 description = self.request.POST.get('description')
211 description = self.request.POST.get('description')
209 role = self.request.POST.get('role')
212 role = self.request.POST.get('role')
210
213
211 token = AuthTokenModel().create(
214 token = AuthTokenModel().create(
212 c.user.user_id, description, lifetime, role)
215 c.user.user_id, description, lifetime, role)
213 token_data = token.get_api_data()
216 token_data = token.get_api_data()
214
217
215 self.maybe_attach_token_scope(token)
218 self.maybe_attach_token_scope(token)
216 audit_logger.store_web(
219 audit_logger.store_web(
217 'user.edit.token.add', action_data={
220 'user.edit.token.add', action_data={
218 'data': {'token': token_data, 'user': user_data}},
221 'data': {'token': token_data, 'user': user_data}},
219 user=self._rhodecode_user, )
222 user=self._rhodecode_user, )
220 Session().commit()
223 Session().commit()
221
224
222 h.flash(_("Auth token successfully created"), category='success')
225 h.flash(_("Auth token successfully created"), category='success')
223 return HTTPFound(h.route_path('edit_user_auth_tokens', user_id=user_id))
226 return HTTPFound(h.route_path('edit_user_auth_tokens', user_id=user_id))
224
227
225 @LoginRequired()
228 @LoginRequired()
226 @HasPermissionAllDecorator('hg.admin')
229 @HasPermissionAllDecorator('hg.admin')
227 @CSRFRequired()
230 @CSRFRequired()
228 @view_config(
231 @view_config(
229 route_name='edit_user_auth_tokens_delete', request_method='POST')
232 route_name='edit_user_auth_tokens_delete', request_method='POST')
230 def auth_tokens_delete(self):
233 def auth_tokens_delete(self):
231 _ = self.request.translate
234 _ = self.request.translate
232 c = self.load_default_context()
235 c = self.load_default_context()
233
236
234 user_id = self.request.matchdict.get('user_id')
237 user_id = self.request.matchdict.get('user_id')
235 c.user = User.get_or_404(user_id)
238 c.user = User.get_or_404(user_id)
236 self._redirect_for_default_user(c.user.username)
239 self._redirect_for_default_user(c.user.username)
237 user_data = c.user.get_api_data()
240 user_data = c.user.get_api_data()
238
241
239 del_auth_token = self.request.POST.get('del_auth_token')
242 del_auth_token = self.request.POST.get('del_auth_token')
240
243
241 if del_auth_token:
244 if del_auth_token:
242 token = UserApiKeys.get_or_404(del_auth_token)
245 token = UserApiKeys.get_or_404(del_auth_token)
243 token_data = token.get_api_data()
246 token_data = token.get_api_data()
244
247
245 AuthTokenModel().delete(del_auth_token, c.user.user_id)
248 AuthTokenModel().delete(del_auth_token, c.user.user_id)
246 audit_logger.store_web(
249 audit_logger.store_web(
247 'user.edit.token.delete', action_data={
250 'user.edit.token.delete', action_data={
248 'data': {'token': token_data, 'user': user_data}},
251 'data': {'token': token_data, 'user': user_data}},
249 user=self._rhodecode_user,)
252 user=self._rhodecode_user,)
250 Session().commit()
253 Session().commit()
251 h.flash(_("Auth token successfully deleted"), category='success')
254 h.flash(_("Auth token successfully deleted"), category='success')
252
255
253 return HTTPFound(h.route_path('edit_user_auth_tokens', user_id=user_id))
256 return HTTPFound(h.route_path('edit_user_auth_tokens', user_id=user_id))
254
257
255 @LoginRequired()
258 @LoginRequired()
256 @HasPermissionAllDecorator('hg.admin')
259 @HasPermissionAllDecorator('hg.admin')
257 @view_config(
260 @view_config(
261 route_name='edit_user_ssh_keys', request_method='GET',
262 renderer='rhodecode:templates/admin/users/user_edit.mako')
263 def ssh_keys(self):
264 _ = self.request.translate
265 c = self.load_default_context()
266
267 user_id = self.request.matchdict.get('user_id')
268 c.user = User.get_or_404(user_id)
269 self._redirect_for_default_user(c.user.username)
270
271 c.active = 'ssh_keys'
272 c.default_key = self.request.GET.get('default_key')
273 c.user_ssh_keys = SshKeyModel().get_ssh_keys(c.user.user_id)
274 return self._get_template_context(c)
275
276 @LoginRequired()
277 @HasPermissionAllDecorator('hg.admin')
278 @view_config(
279 route_name='edit_user_ssh_keys_generate_keypair', request_method='GET',
280 renderer='rhodecode:templates/admin/users/user_edit.mako')
281 def ssh_keys_generate_keypair(self):
282 _ = self.request.translate
283 c = self.load_default_context()
284
285 user_id = self.request.matchdict.get('user_id')
286 c.user = User.get_or_404(user_id)
287 self._redirect_for_default_user(c.user.username)
288
289 c.active = 'ssh_keys_generate'
290 comment = 'RhodeCode-SSH {}'.format(c.user.email or '')
291 c.private, c.public = SshKeyModel().generate_keypair(comment=comment)
292
293 return self._get_template_context(c)
294
295 @LoginRequired()
296 @HasPermissionAllDecorator('hg.admin')
297 @CSRFRequired()
298 @view_config(
299 route_name='edit_user_ssh_keys_add', request_method='POST')
300 def ssh_keys_add(self):
301 _ = self.request.translate
302 c = self.load_default_context()
303
304 user_id = self.request.matchdict.get('user_id')
305 c.user = User.get_or_404(user_id)
306
307 self._redirect_for_default_user(c.user.username)
308
309 user_data = c.user.get_api_data()
310 key_data = self.request.POST.get('key_data')
311 description = self.request.POST.get('description')
312
313 try:
314 if not key_data:
315 raise ValueError('Please add a valid public key')
316
317 key = SshKeyModel().parse_key(key_data.strip())
318 fingerprint = key.hash_md5()
319
320 ssh_key = SshKeyModel().create(
321 c.user.user_id, fingerprint, key_data, description)
322 ssh_key_data = ssh_key.get_api_data()
323
324 audit_logger.store_web(
325 'user.edit.ssh_key.add', action_data={
326 'data': {'ssh_key': ssh_key_data, 'user': user_data}},
327 user=self._rhodecode_user, )
328 Session().commit()
329
330 h.flash(_("Ssh Key successfully created"), category='success')
331
332 except IntegrityError:
333 log.exception("Exception during ssh key saving")
334 h.flash(_('An error occurred during ssh key saving: {}').format(
335 'Such key already exists, please use a different one'),
336 category='error')
337 except Exception as e:
338 log.exception("Exception during ssh key saving")
339 h.flash(_('An error occurred during ssh key saving: {}').format(e),
340 category='error')
341
342 return HTTPFound(
343 h.route_path('edit_user_ssh_keys', user_id=user_id))
344
345 @LoginRequired()
346 @HasPermissionAllDecorator('hg.admin')
347 @CSRFRequired()
348 @view_config(
349 route_name='edit_user_ssh_keys_delete', request_method='POST')
350 def ssh_keys_delete(self):
351 _ = self.request.translate
352 c = self.load_default_context()
353
354 user_id = self.request.matchdict.get('user_id')
355 c.user = User.get_or_404(user_id)
356 self._redirect_for_default_user(c.user.username)
357 user_data = c.user.get_api_data()
358
359 del_ssh_key = self.request.POST.get('del_ssh_key')
360
361 if del_ssh_key:
362 ssh_key = UserSshKeys.get_or_404(del_ssh_key)
363 ssh_key_data = ssh_key.get_api_data()
364
365 SshKeyModel().delete(del_ssh_key, c.user.user_id)
366 audit_logger.store_web(
367 'user.edit.ssh_key.delete', action_data={
368 'data': {'ssh_key': ssh_key_data, 'user': user_data}},
369 user=self._rhodecode_user,)
370 Session().commit()
371 h.flash(_("Ssh key successfully deleted"), category='success')
372
373 return HTTPFound(h.route_path('edit_user_ssh_keys', user_id=user_id))
374
375 @LoginRequired()
376 @HasPermissionAllDecorator('hg.admin')
377 @view_config(
258 route_name='edit_user_emails', request_method='GET',
378 route_name='edit_user_emails', request_method='GET',
259 renderer='rhodecode:templates/admin/users/user_edit.mako')
379 renderer='rhodecode:templates/admin/users/user_edit.mako')
260 def emails(self):
380 def emails(self):
261 _ = self.request.translate
381 _ = self.request.translate
262 c = self.load_default_context()
382 c = self.load_default_context()
263
383
264 user_id = self.request.matchdict.get('user_id')
384 user_id = self.request.matchdict.get('user_id')
265 c.user = User.get_or_404(user_id)
385 c.user = User.get_or_404(user_id)
266 self._redirect_for_default_user(c.user.username)
386 self._redirect_for_default_user(c.user.username)
267
387
268 c.active = 'emails'
388 c.active = 'emails'
269 c.user_email_map = UserEmailMap.query() \
389 c.user_email_map = UserEmailMap.query() \
270 .filter(UserEmailMap.user == c.user).all()
390 .filter(UserEmailMap.user == c.user).all()
271
391
272 return self._get_template_context(c)
392 return self._get_template_context(c)
273
393
274 @LoginRequired()
394 @LoginRequired()
275 @HasPermissionAllDecorator('hg.admin')
395 @HasPermissionAllDecorator('hg.admin')
276 @CSRFRequired()
396 @CSRFRequired()
277 @view_config(
397 @view_config(
278 route_name='edit_user_emails_add', request_method='POST')
398 route_name='edit_user_emails_add', request_method='POST')
279 def emails_add(self):
399 def emails_add(self):
280 _ = self.request.translate
400 _ = self.request.translate
281 c = self.load_default_context()
401 c = self.load_default_context()
282
402
283 user_id = self.request.matchdict.get('user_id')
403 user_id = self.request.matchdict.get('user_id')
284 c.user = User.get_or_404(user_id)
404 c.user = User.get_or_404(user_id)
285 self._redirect_for_default_user(c.user.username)
405 self._redirect_for_default_user(c.user.username)
286
406
287 email = self.request.POST.get('new_email')
407 email = self.request.POST.get('new_email')
288 user_data = c.user.get_api_data()
408 user_data = c.user.get_api_data()
289 try:
409 try:
290 UserModel().add_extra_email(c.user.user_id, email)
410 UserModel().add_extra_email(c.user.user_id, email)
291 audit_logger.store_web(
411 audit_logger.store_web(
292 'user.edit.email.add', action_data={'email': email, 'user': user_data},
412 'user.edit.email.add', action_data={'email': email, 'user': user_data},
293 user=self._rhodecode_user)
413 user=self._rhodecode_user)
294 Session().commit()
414 Session().commit()
295 h.flash(_("Added new email address `%s` for user account") % email,
415 h.flash(_("Added new email address `%s` for user account") % email,
296 category='success')
416 category='success')
297 except formencode.Invalid as error:
417 except formencode.Invalid as error:
298 h.flash(h.escape(error.error_dict['email']), category='error')
418 h.flash(h.escape(error.error_dict['email']), category='error')
299 except Exception:
419 except Exception:
300 log.exception("Exception during email saving")
420 log.exception("Exception during email saving")
301 h.flash(_('An error occurred during email saving'),
421 h.flash(_('An error occurred during email saving'),
302 category='error')
422 category='error')
303 raise HTTPFound(h.route_path('edit_user_emails', user_id=user_id))
423 raise HTTPFound(h.route_path('edit_user_emails', user_id=user_id))
304
424
305 @LoginRequired()
425 @LoginRequired()
306 @HasPermissionAllDecorator('hg.admin')
426 @HasPermissionAllDecorator('hg.admin')
307 @CSRFRequired()
427 @CSRFRequired()
308 @view_config(
428 @view_config(
309 route_name='edit_user_emails_delete', request_method='POST')
429 route_name='edit_user_emails_delete', request_method='POST')
310 def emails_delete(self):
430 def emails_delete(self):
311 _ = self.request.translate
431 _ = self.request.translate
312 c = self.load_default_context()
432 c = self.load_default_context()
313
433
314 user_id = self.request.matchdict.get('user_id')
434 user_id = self.request.matchdict.get('user_id')
315 c.user = User.get_or_404(user_id)
435 c.user = User.get_or_404(user_id)
316 self._redirect_for_default_user(c.user.username)
436 self._redirect_for_default_user(c.user.username)
317
437
318 email_id = self.request.POST.get('del_email_id')
438 email_id = self.request.POST.get('del_email_id')
319 user_model = UserModel()
439 user_model = UserModel()
320
440
321 email = UserEmailMap.query().get(email_id).email
441 email = UserEmailMap.query().get(email_id).email
322 user_data = c.user.get_api_data()
442 user_data = c.user.get_api_data()
323 user_model.delete_extra_email(c.user.user_id, email_id)
443 user_model.delete_extra_email(c.user.user_id, email_id)
324 audit_logger.store_web(
444 audit_logger.store_web(
325 'user.edit.email.delete', action_data={'email': email, 'user': user_data},
445 'user.edit.email.delete', action_data={'email': email, 'user': user_data},
326 user=self._rhodecode_user)
446 user=self._rhodecode_user)
327 Session().commit()
447 Session().commit()
328 h.flash(_("Removed email address from user account"),
448 h.flash(_("Removed email address from user account"),
329 category='success')
449 category='success')
330 raise HTTPFound(h.route_path('edit_user_emails', user_id=user_id))
450 raise HTTPFound(h.route_path('edit_user_emails', user_id=user_id))
331
451
332 @LoginRequired()
452 @LoginRequired()
333 @HasPermissionAllDecorator('hg.admin')
453 @HasPermissionAllDecorator('hg.admin')
334 @view_config(
454 @view_config(
335 route_name='edit_user_ips', request_method='GET',
455 route_name='edit_user_ips', request_method='GET',
336 renderer='rhodecode:templates/admin/users/user_edit.mako')
456 renderer='rhodecode:templates/admin/users/user_edit.mako')
337 def ips(self):
457 def ips(self):
338 _ = self.request.translate
458 _ = self.request.translate
339 c = self.load_default_context()
459 c = self.load_default_context()
340
460
341 user_id = self.request.matchdict.get('user_id')
461 user_id = self.request.matchdict.get('user_id')
342 c.user = User.get_or_404(user_id)
462 c.user = User.get_or_404(user_id)
343 self._redirect_for_default_user(c.user.username)
463 self._redirect_for_default_user(c.user.username)
344
464
345 c.active = 'ips'
465 c.active = 'ips'
346 c.user_ip_map = UserIpMap.query() \
466 c.user_ip_map = UserIpMap.query() \
347 .filter(UserIpMap.user == c.user).all()
467 .filter(UserIpMap.user == c.user).all()
348
468
349 c.inherit_default_ips = c.user.inherit_default_permissions
469 c.inherit_default_ips = c.user.inherit_default_permissions
350 c.default_user_ip_map = UserIpMap.query() \
470 c.default_user_ip_map = UserIpMap.query() \
351 .filter(UserIpMap.user == User.get_default_user()).all()
471 .filter(UserIpMap.user == User.get_default_user()).all()
352
472
353 return self._get_template_context(c)
473 return self._get_template_context(c)
354
474
355 @LoginRequired()
475 @LoginRequired()
356 @HasPermissionAllDecorator('hg.admin')
476 @HasPermissionAllDecorator('hg.admin')
357 @CSRFRequired()
477 @CSRFRequired()
358 @view_config(
478 @view_config(
359 route_name='edit_user_ips_add', request_method='POST')
479 route_name='edit_user_ips_add', request_method='POST')
360 def ips_add(self):
480 def ips_add(self):
361 _ = self.request.translate
481 _ = self.request.translate
362 c = self.load_default_context()
482 c = self.load_default_context()
363
483
364 user_id = self.request.matchdict.get('user_id')
484 user_id = self.request.matchdict.get('user_id')
365 c.user = User.get_or_404(user_id)
485 c.user = User.get_or_404(user_id)
366 # NOTE(marcink): this view is allowed for default users, as we can
486 # NOTE(marcink): this view is allowed for default users, as we can
367 # edit their IP white list
487 # edit their IP white list
368
488
369 user_model = UserModel()
489 user_model = UserModel()
370 desc = self.request.POST.get('description')
490 desc = self.request.POST.get('description')
371 try:
491 try:
372 ip_list = user_model.parse_ip_range(
492 ip_list = user_model.parse_ip_range(
373 self.request.POST.get('new_ip'))
493 self.request.POST.get('new_ip'))
374 except Exception as e:
494 except Exception as e:
375 ip_list = []
495 ip_list = []
376 log.exception("Exception during ip saving")
496 log.exception("Exception during ip saving")
377 h.flash(_('An error occurred during ip saving:%s' % (e,)),
497 h.flash(_('An error occurred during ip saving:%s' % (e,)),
378 category='error')
498 category='error')
379 added = []
499 added = []
380 user_data = c.user.get_api_data()
500 user_data = c.user.get_api_data()
381 for ip in ip_list:
501 for ip in ip_list:
382 try:
502 try:
383 user_model.add_extra_ip(c.user.user_id, ip, desc)
503 user_model.add_extra_ip(c.user.user_id, ip, desc)
384 audit_logger.store_web(
504 audit_logger.store_web(
385 'user.edit.ip.add', action_data={'ip': ip, 'user': user_data},
505 'user.edit.ip.add', action_data={'ip': ip, 'user': user_data},
386 user=self._rhodecode_user)
506 user=self._rhodecode_user)
387 Session().commit()
507 Session().commit()
388 added.append(ip)
508 added.append(ip)
389 except formencode.Invalid as error:
509 except formencode.Invalid as error:
390 msg = error.error_dict['ip']
510 msg = error.error_dict['ip']
391 h.flash(msg, category='error')
511 h.flash(msg, category='error')
392 except Exception:
512 except Exception:
393 log.exception("Exception during ip saving")
513 log.exception("Exception during ip saving")
394 h.flash(_('An error occurred during ip saving'),
514 h.flash(_('An error occurred during ip saving'),
395 category='error')
515 category='error')
396 if added:
516 if added:
397 h.flash(
517 h.flash(
398 _("Added ips %s to user whitelist") % (', '.join(ip_list), ),
518 _("Added ips %s to user whitelist") % (', '.join(ip_list), ),
399 category='success')
519 category='success')
400 if 'default_user' in self.request.POST:
520 if 'default_user' in self.request.POST:
401 # case for editing global IP list we do it for 'DEFAULT' user
521 # case for editing global IP list we do it for 'DEFAULT' user
402 raise HTTPFound(h.route_path('admin_permissions_ips'))
522 raise HTTPFound(h.route_path('admin_permissions_ips'))
403 raise HTTPFound(h.route_path('edit_user_ips', user_id=user_id))
523 raise HTTPFound(h.route_path('edit_user_ips', user_id=user_id))
404
524
405 @LoginRequired()
525 @LoginRequired()
406 @HasPermissionAllDecorator('hg.admin')
526 @HasPermissionAllDecorator('hg.admin')
407 @CSRFRequired()
527 @CSRFRequired()
408 @view_config(
528 @view_config(
409 route_name='edit_user_ips_delete', request_method='POST')
529 route_name='edit_user_ips_delete', request_method='POST')
410 def ips_delete(self):
530 def ips_delete(self):
411 _ = self.request.translate
531 _ = self.request.translate
412 c = self.load_default_context()
532 c = self.load_default_context()
413
533
414 user_id = self.request.matchdict.get('user_id')
534 user_id = self.request.matchdict.get('user_id')
415 c.user = User.get_or_404(user_id)
535 c.user = User.get_or_404(user_id)
416 # NOTE(marcink): this view is allowed for default users, as we can
536 # NOTE(marcink): this view is allowed for default users, as we can
417 # edit their IP white list
537 # edit their IP white list
418
538
419 ip_id = self.request.POST.get('del_ip_id')
539 ip_id = self.request.POST.get('del_ip_id')
420 user_model = UserModel()
540 user_model = UserModel()
421 user_data = c.user.get_api_data()
541 user_data = c.user.get_api_data()
422 ip = UserIpMap.query().get(ip_id).ip_addr
542 ip = UserIpMap.query().get(ip_id).ip_addr
423 user_model.delete_extra_ip(c.user.user_id, ip_id)
543 user_model.delete_extra_ip(c.user.user_id, ip_id)
424 audit_logger.store_web(
544 audit_logger.store_web(
425 'user.edit.ip.delete', action_data={'ip': ip, 'user': user_data},
545 'user.edit.ip.delete', action_data={'ip': ip, 'user': user_data},
426 user=self._rhodecode_user)
546 user=self._rhodecode_user)
427 Session().commit()
547 Session().commit()
428 h.flash(_("Removed ip address from user whitelist"), category='success')
548 h.flash(_("Removed ip address from user whitelist"), category='success')
429
549
430 if 'default_user' in self.request.POST:
550 if 'default_user' in self.request.POST:
431 # case for editing global IP list we do it for 'DEFAULT' user
551 # case for editing global IP list we do it for 'DEFAULT' user
432 raise HTTPFound(h.route_path('admin_permissions_ips'))
552 raise HTTPFound(h.route_path('admin_permissions_ips'))
433 raise HTTPFound(h.route_path('edit_user_ips', user_id=user_id))
553 raise HTTPFound(h.route_path('edit_user_ips', user_id=user_id))
434
554
435 @LoginRequired()
555 @LoginRequired()
436 @HasPermissionAllDecorator('hg.admin')
556 @HasPermissionAllDecorator('hg.admin')
437 @view_config(
557 @view_config(
438 route_name='edit_user_groups_management', request_method='GET',
558 route_name='edit_user_groups_management', request_method='GET',
439 renderer='rhodecode:templates/admin/users/user_edit.mako')
559 renderer='rhodecode:templates/admin/users/user_edit.mako')
440 def groups_management(self):
560 def groups_management(self):
441 c = self.load_default_context()
561 c = self.load_default_context()
442
562
443 user_id = self.request.matchdict.get('user_id')
563 user_id = self.request.matchdict.get('user_id')
444 c.user = User.get_or_404(user_id)
564 c.user = User.get_or_404(user_id)
445 c.data = c.user.group_member
565 c.data = c.user.group_member
446 self._redirect_for_default_user(c.user.username)
566 self._redirect_for_default_user(c.user.username)
447 groups = [UserGroupModel.get_user_groups_as_dict(group.users_group)
567 groups = [UserGroupModel.get_user_groups_as_dict(group.users_group)
448 for group in c.user.group_member]
568 for group in c.user.group_member]
449 c.groups = json.dumps(groups)
569 c.groups = json.dumps(groups)
450 c.active = 'groups'
570 c.active = 'groups'
451
571
452 return self._get_template_context(c)
572 return self._get_template_context(c)
453
573
454 @LoginRequired()
574 @LoginRequired()
455 @HasPermissionAllDecorator('hg.admin')
575 @HasPermissionAllDecorator('hg.admin')
456 @CSRFRequired()
576 @CSRFRequired()
457 @view_config(
577 @view_config(
458 route_name='edit_user_groups_management_updates', request_method='POST')
578 route_name='edit_user_groups_management_updates', request_method='POST')
459 def groups_management_updates(self):
579 def groups_management_updates(self):
460 _ = self.request.translate
580 _ = self.request.translate
461 c = self.load_default_context()
581 c = self.load_default_context()
462
582
463 user_id = self.request.matchdict.get('user_id')
583 user_id = self.request.matchdict.get('user_id')
464 c.user = User.get_or_404(user_id)
584 c.user = User.get_or_404(user_id)
465 self._redirect_for_default_user(c.user.username)
585 self._redirect_for_default_user(c.user.username)
466
586
467 users_groups = set(self.request.POST.getall('users_group_id'))
587 users_groups = set(self.request.POST.getall('users_group_id'))
468 users_groups_model = []
588 users_groups_model = []
469
589
470 for ugid in users_groups:
590 for ugid in users_groups:
471 users_groups_model.append(UserGroupModel().get_group(safe_int(ugid)))
591 users_groups_model.append(UserGroupModel().get_group(safe_int(ugid)))
472 user_group_model = UserGroupModel()
592 user_group_model = UserGroupModel()
473 user_group_model.change_groups(c.user, users_groups_model)
593 user_group_model.change_groups(c.user, users_groups_model)
474
594
475 Session().commit()
595 Session().commit()
476 c.active = 'user_groups_management'
596 c.active = 'user_groups_management'
477 h.flash(_("Groups successfully changed"), category='success')
597 h.flash(_("Groups successfully changed"), category='success')
478
598
479 return HTTPFound(h.route_path(
599 return HTTPFound(h.route_path(
480 'edit_user_groups_management', user_id=user_id))
600 'edit_user_groups_management', user_id=user_id))
481
601
482 @LoginRequired()
602 @LoginRequired()
483 @HasPermissionAllDecorator('hg.admin')
603 @HasPermissionAllDecorator('hg.admin')
484 @view_config(
604 @view_config(
485 route_name='edit_user_audit_logs', request_method='GET',
605 route_name='edit_user_audit_logs', request_method='GET',
486 renderer='rhodecode:templates/admin/users/user_edit.mako')
606 renderer='rhodecode:templates/admin/users/user_edit.mako')
487 def user_audit_logs(self):
607 def user_audit_logs(self):
488 _ = self.request.translate
608 _ = self.request.translate
489 c = self.load_default_context()
609 c = self.load_default_context()
490
610
491 user_id = self.request.matchdict.get('user_id')
611 user_id = self.request.matchdict.get('user_id')
492 c.user = User.get_or_404(user_id)
612 c.user = User.get_or_404(user_id)
493 self._redirect_for_default_user(c.user.username)
613 self._redirect_for_default_user(c.user.username)
494 c.active = 'audit'
614 c.active = 'audit'
495
615
496 p = safe_int(self.request.GET.get('page', 1), 1)
616 p = safe_int(self.request.GET.get('page', 1), 1)
497
617
498 filter_term = self.request.GET.get('filter')
618 filter_term = self.request.GET.get('filter')
499 user_log = UserModel().get_user_log(c.user, filter_term)
619 user_log = UserModel().get_user_log(c.user, filter_term)
500
620
501 def url_generator(**kw):
621 def url_generator(**kw):
502 if filter_term:
622 if filter_term:
503 kw['filter'] = filter_term
623 kw['filter'] = filter_term
504 return self.request.current_route_path(_query=kw)
624 return self.request.current_route_path(_query=kw)
505
625
506 c.audit_logs = h.Page(
626 c.audit_logs = h.Page(
507 user_log, page=p, items_per_page=10, url=url_generator)
627 user_log, page=p, items_per_page=10, url=url_generator)
508 c.filter_term = filter_term
628 c.filter_term = filter_term
509 return self._get_template_context(c)
629 return self._get_template_context(c)
510
630
@@ -1,255 +1,257 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2
2
3 # Copyright (C) 2017-2017 RhodeCode GmbH
3 # Copyright (C) 2017-2017 RhodeCode GmbH
4 #
4 #
5 # This program is free software: you can redistribute it and/or modify
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License, version 3
6 # it under the terms of the GNU Affero General Public License, version 3
7 # (only), as published by the Free Software Foundation.
7 # (only), as published by the Free Software Foundation.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU Affero General Public License
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 #
16 #
17 # This program is dual-licensed. If you wish to learn more about the
17 # This program is dual-licensed. If you wish to learn more about the
18 # RhodeCode Enterprise Edition, including its added features, Support services,
18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
20
21 import logging
21 import logging
22 import datetime
22 import datetime
23
23
24 from rhodecode.model import meta
24 from rhodecode.model import meta
25 from rhodecode.model.db import User, UserLog, Repository
25 from rhodecode.model.db import User, UserLog, Repository
26
26
27
27
28 log = logging.getLogger(__name__)
28 log = logging.getLogger(__name__)
29
29
30 # action as key, and expected action_data as value
30 # action as key, and expected action_data as value
31 ACTIONS_V1 = {
31 ACTIONS_V1 = {
32 'user.login.success': {'user_agent': ''},
32 'user.login.success': {'user_agent': ''},
33 'user.login.failure': {'user_agent': ''},
33 'user.login.failure': {'user_agent': ''},
34 'user.logout': {'user_agent': ''},
34 'user.logout': {'user_agent': ''},
35 'user.password.reset_request': {},
35 'user.password.reset_request': {},
36 'user.push': {'user_agent': '', 'commit_ids': []},
36 'user.push': {'user_agent': '', 'commit_ids': []},
37 'user.pull': {'user_agent': ''},
37 'user.pull': {'user_agent': ''},
38
38
39 'user.create': {'data': {}},
39 'user.create': {'data': {}},
40 'user.delete': {'old_data': {}},
40 'user.delete': {'old_data': {}},
41 'user.edit': {'old_data': {}},
41 'user.edit': {'old_data': {}},
42 'user.edit.permissions': {},
42 'user.edit.permissions': {},
43 'user.edit.ip.add': {'ip': {}, 'user': {}},
43 'user.edit.ip.add': {'ip': {}, 'user': {}},
44 'user.edit.ip.delete': {'ip': {}, 'user': {}},
44 'user.edit.ip.delete': {'ip': {}, 'user': {}},
45 'user.edit.token.add': {'token': {}, 'user': {}},
45 'user.edit.token.add': {'token': {}, 'user': {}},
46 'user.edit.token.delete': {'token': {}, 'user': {}},
46 'user.edit.token.delete': {'token': {}, 'user': {}},
47 'user.edit.email.add': {'email': ''},
47 'user.edit.email.add': {'email': ''},
48 'user.edit.email.delete': {'email': ''},
48 'user.edit.email.delete': {'email': ''},
49 'user.edit.ssh_key.add': {'token': {}, 'user': {}},
50 'user.edit.ssh_key.delete': {'token': {}, 'user': {}},
49 'user.edit.password_reset.enabled': {},
51 'user.edit.password_reset.enabled': {},
50 'user.edit.password_reset.disabled': {},
52 'user.edit.password_reset.disabled': {},
51
53
52 'user_group.create': {'data': {}},
54 'user_group.create': {'data': {}},
53 'user_group.delete': {'old_data': {}},
55 'user_group.delete': {'old_data': {}},
54 'user_group.edit': {'old_data': {}},
56 'user_group.edit': {'old_data': {}},
55 'user_group.edit.permissions': {},
57 'user_group.edit.permissions': {},
56 'user_group.edit.member.add': {'user': {}},
58 'user_group.edit.member.add': {'user': {}},
57 'user_group.edit.member.delete': {'user': {}},
59 'user_group.edit.member.delete': {'user': {}},
58
60
59 'repo.create': {'data': {}},
61 'repo.create': {'data': {}},
60 'repo.fork': {'data': {}},
62 'repo.fork': {'data': {}},
61 'repo.edit': {'old_data': {}},
63 'repo.edit': {'old_data': {}},
62 'repo.edit.permissions': {},
64 'repo.edit.permissions': {},
63 'repo.delete': {'old_data': {}},
65 'repo.delete': {'old_data': {}},
64 'repo.commit.strip': {'commit_id': ''},
66 'repo.commit.strip': {'commit_id': ''},
65 'repo.archive.download': {'user_agent': '', 'archive_name': '',
67 'repo.archive.download': {'user_agent': '', 'archive_name': '',
66 'archive_spec': '', 'archive_cached': ''},
68 'archive_spec': '', 'archive_cached': ''},
67 'repo.pull_request.create': '',
69 'repo.pull_request.create': '',
68 'repo.pull_request.edit': '',
70 'repo.pull_request.edit': '',
69 'repo.pull_request.delete': '',
71 'repo.pull_request.delete': '',
70 'repo.pull_request.close': '',
72 'repo.pull_request.close': '',
71 'repo.pull_request.merge': '',
73 'repo.pull_request.merge': '',
72 'repo.pull_request.vote': '',
74 'repo.pull_request.vote': '',
73 'repo.pull_request.comment.create': '',
75 'repo.pull_request.comment.create': '',
74 'repo.pull_request.comment.delete': '',
76 'repo.pull_request.comment.delete': '',
75
77
76 'repo.pull_request.reviewer.add': '',
78 'repo.pull_request.reviewer.add': '',
77 'repo.pull_request.reviewer.delete': '',
79 'repo.pull_request.reviewer.delete': '',
78
80
79 'repo.commit.comment.create': {'data': {}},
81 'repo.commit.comment.create': {'data': {}},
80 'repo.commit.comment.delete': {'data': {}},
82 'repo.commit.comment.delete': {'data': {}},
81 'repo.commit.vote': '',
83 'repo.commit.vote': '',
82
84
83 'repo_group.create': {'data': {}},
85 'repo_group.create': {'data': {}},
84 'repo_group.edit': {'old_data': {}},
86 'repo_group.edit': {'old_data': {}},
85 'repo_group.edit.permissions': {},
87 'repo_group.edit.permissions': {},
86 'repo_group.delete': {'old_data': {}},
88 'repo_group.delete': {'old_data': {}},
87 }
89 }
88 ACTIONS = ACTIONS_V1
90 ACTIONS = ACTIONS_V1
89
91
90 SOURCE_WEB = 'source_web'
92 SOURCE_WEB = 'source_web'
91 SOURCE_API = 'source_api'
93 SOURCE_API = 'source_api'
92
94
93
95
94 class UserWrap(object):
96 class UserWrap(object):
95 """
97 """
96 Fake object used to imitate AuthUser
98 Fake object used to imitate AuthUser
97 """
99 """
98
100
99 def __init__(self, user_id=None, username=None, ip_addr=None):
101 def __init__(self, user_id=None, username=None, ip_addr=None):
100 self.user_id = user_id
102 self.user_id = user_id
101 self.username = username
103 self.username = username
102 self.ip_addr = ip_addr
104 self.ip_addr = ip_addr
103
105
104
106
105 class RepoWrap(object):
107 class RepoWrap(object):
106 """
108 """
107 Fake object used to imitate RepoObject that audit logger requires
109 Fake object used to imitate RepoObject that audit logger requires
108 """
110 """
109
111
110 def __init__(self, repo_id=None, repo_name=None):
112 def __init__(self, repo_id=None, repo_name=None):
111 self.repo_id = repo_id
113 self.repo_id = repo_id
112 self.repo_name = repo_name
114 self.repo_name = repo_name
113
115
114
116
115 def _store_log(action_name, action_data, user_id, username, user_data,
117 def _store_log(action_name, action_data, user_id, username, user_data,
116 ip_address, repository_id, repository_name):
118 ip_address, repository_id, repository_name):
117 user_log = UserLog()
119 user_log = UserLog()
118 user_log.version = UserLog.VERSION_2
120 user_log.version = UserLog.VERSION_2
119
121
120 user_log.action = action_name
122 user_log.action = action_name
121 user_log.action_data = action_data
123 user_log.action_data = action_data
122
124
123 user_log.user_ip = ip_address
125 user_log.user_ip = ip_address
124
126
125 user_log.user_id = user_id
127 user_log.user_id = user_id
126 user_log.username = username
128 user_log.username = username
127 user_log.user_data = user_data
129 user_log.user_data = user_data
128
130
129 user_log.repository_id = repository_id
131 user_log.repository_id = repository_id
130 user_log.repository_name = repository_name
132 user_log.repository_name = repository_name
131
133
132 user_log.action_date = datetime.datetime.now()
134 user_log.action_date = datetime.datetime.now()
133
135
134 log.info('AUDIT: Logging action: `%s` by user:id:%s[%s] ip:%s',
136 log.info('AUDIT: Logging action: `%s` by user:id:%s[%s] ip:%s',
135 action_name, user_id, username, ip_address)
137 action_name, user_id, username, ip_address)
136
138
137 return user_log
139 return user_log
138
140
139
141
140 def store_web(*args, **kwargs):
142 def store_web(*args, **kwargs):
141 if 'action_data' not in kwargs:
143 if 'action_data' not in kwargs:
142 kwargs['action_data'] = {}
144 kwargs['action_data'] = {}
143 kwargs['action_data'].update({
145 kwargs['action_data'].update({
144 'source': SOURCE_WEB
146 'source': SOURCE_WEB
145 })
147 })
146 return store(*args, **kwargs)
148 return store(*args, **kwargs)
147
149
148
150
149 def store_api(*args, **kwargs):
151 def store_api(*args, **kwargs):
150 if 'action_data' not in kwargs:
152 if 'action_data' not in kwargs:
151 kwargs['action_data'] = {}
153 kwargs['action_data'] = {}
152 kwargs['action_data'].update({
154 kwargs['action_data'].update({
153 'source': SOURCE_API
155 'source': SOURCE_API
154 })
156 })
155 return store(*args, **kwargs)
157 return store(*args, **kwargs)
156
158
157
159
158 def store(action, user, action_data=None, user_data=None, ip_addr=None,
160 def store(action, user, action_data=None, user_data=None, ip_addr=None,
159 repo=None, sa_session=None, commit=False):
161 repo=None, sa_session=None, commit=False):
160 """
162 """
161 Audit logger for various actions made by users, typically this
163 Audit logger for various actions made by users, typically this
162 results in a call such::
164 results in a call such::
163
165
164 from rhodecode.lib import audit_logger
166 from rhodecode.lib import audit_logger
165
167
166 audit_logger.store(
168 audit_logger.store(
167 'repo.edit', user=self._rhodecode_user)
169 'repo.edit', user=self._rhodecode_user)
168 audit_logger.store(
170 audit_logger.store(
169 'repo.delete', action_data={'data': repo_data},
171 'repo.delete', action_data={'data': repo_data},
170 user=audit_logger.UserWrap(username='itried-login', ip_addr='8.8.8.8'))
172 user=audit_logger.UserWrap(username='itried-login', ip_addr='8.8.8.8'))
171
173
172 # repo action
174 # repo action
173 audit_logger.store(
175 audit_logger.store(
174 'repo.delete',
176 'repo.delete',
175 user=audit_logger.UserWrap(username='itried-login', ip_addr='8.8.8.8'),
177 user=audit_logger.UserWrap(username='itried-login', ip_addr='8.8.8.8'),
176 repo=audit_logger.RepoWrap(repo_name='some-repo'))
178 repo=audit_logger.RepoWrap(repo_name='some-repo'))
177
179
178 # repo action, when we know and have the repository object already
180 # repo action, when we know and have the repository object already
179 audit_logger.store(
181 audit_logger.store(
180 'repo.delete', action_data={'source': audit_logger.SOURCE_WEB, },
182 'repo.delete', action_data={'source': audit_logger.SOURCE_WEB, },
181 user=self._rhodecode_user,
183 user=self._rhodecode_user,
182 repo=repo_object)
184 repo=repo_object)
183
185
184 # alternative wrapper to the above
186 # alternative wrapper to the above
185 audit_logger.store_web(
187 audit_logger.store_web(
186 'repo.delete', action_data={},
188 'repo.delete', action_data={},
187 user=self._rhodecode_user,
189 user=self._rhodecode_user,
188 repo=repo_object)
190 repo=repo_object)
189
191
190 # without an user ?
192 # without an user ?
191 audit_logger.store(
193 audit_logger.store(
192 'user.login.failure',
194 'user.login.failure',
193 user=audit_logger.UserWrap(
195 user=audit_logger.UserWrap(
194 username=self.request.params.get('username'),
196 username=self.request.params.get('username'),
195 ip_addr=self.request.remote_addr))
197 ip_addr=self.request.remote_addr))
196
198
197 """
199 """
198 from rhodecode.lib.utils2 import safe_unicode
200 from rhodecode.lib.utils2 import safe_unicode
199 from rhodecode.lib.auth import AuthUser
201 from rhodecode.lib.auth import AuthUser
200
202
201 action_spec = ACTIONS.get(action, None)
203 action_spec = ACTIONS.get(action, None)
202 if action_spec is None:
204 if action_spec is None:
203 raise ValueError('Action `{}` is not supported'.format(action))
205 raise ValueError('Action `{}` is not supported'.format(action))
204
206
205 if not sa_session:
207 if not sa_session:
206 sa_session = meta.Session()
208 sa_session = meta.Session()
207
209
208 try:
210 try:
209 username = getattr(user, 'username', None)
211 username = getattr(user, 'username', None)
210 if not username:
212 if not username:
211 pass
213 pass
212
214
213 user_id = getattr(user, 'user_id', None)
215 user_id = getattr(user, 'user_id', None)
214 if not user_id:
216 if not user_id:
215 # maybe we have username ? Try to figure user_id from username
217 # maybe we have username ? Try to figure user_id from username
216 if username:
218 if username:
217 user_id = getattr(
219 user_id = getattr(
218 User.get_by_username(username), 'user_id', None)
220 User.get_by_username(username), 'user_id', None)
219
221
220 ip_addr = ip_addr or getattr(user, 'ip_addr', None)
222 ip_addr = ip_addr or getattr(user, 'ip_addr', None)
221 if not ip_addr:
223 if not ip_addr:
222 pass
224 pass
223
225
224 if not user_data:
226 if not user_data:
225 # try to get this from the auth user
227 # try to get this from the auth user
226 if isinstance(user, AuthUser):
228 if isinstance(user, AuthUser):
227 user_data = {
229 user_data = {
228 'username': user.username,
230 'username': user.username,
229 'email': user.email,
231 'email': user.email,
230 }
232 }
231
233
232 repository_name = getattr(repo, 'repo_name', None)
234 repository_name = getattr(repo, 'repo_name', None)
233 repository_id = getattr(repo, 'repo_id', None)
235 repository_id = getattr(repo, 'repo_id', None)
234 if not repository_id:
236 if not repository_id:
235 # maybe we have repo_name ? Try to figure repo_id from repo_name
237 # maybe we have repo_name ? Try to figure repo_id from repo_name
236 if repository_name:
238 if repository_name:
237 repository_id = getattr(
239 repository_id = getattr(
238 Repository.get_by_repo_name(repository_name), 'repo_id', None)
240 Repository.get_by_repo_name(repository_name), 'repo_id', None)
239
241
240 user_log = _store_log(
242 user_log = _store_log(
241 action_name=safe_unicode(action),
243 action_name=safe_unicode(action),
242 action_data=action_data or {},
244 action_data=action_data or {},
243 user_id=user_id,
245 user_id=user_id,
244 username=username,
246 username=username,
245 user_data=user_data or {},
247 user_data=user_data or {},
246 ip_address=safe_unicode(ip_addr),
248 ip_address=safe_unicode(ip_addr),
247 repository_id=repository_id,
249 repository_id=repository_id,
248 repository_name=repository_name
250 repository_name=repository_name
249 )
251 )
250 sa_session.add(user_log)
252 sa_session.add(user_log)
251 if commit:
253 if commit:
252 sa_session.commit()
254 sa_session.commit()
253
255
254 except Exception:
256 except Exception:
255 log.exception('AUDIT: failed to store audit log')
257 log.exception('AUDIT: failed to store audit log')
@@ -1,4134 +1,4173 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2
2
3 # Copyright (C) 2010-2017 RhodeCode GmbH
3 # Copyright (C) 2010-2017 RhodeCode GmbH
4 #
4 #
5 # This program is free software: you can redistribute it and/or modify
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License, version 3
6 # it under the terms of the GNU Affero General Public License, version 3
7 # (only), as published by the Free Software Foundation.
7 # (only), as published by the Free Software Foundation.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU Affero General Public License
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 #
16 #
17 # This program is dual-licensed. If you wish to learn more about the
17 # This program is dual-licensed. If you wish to learn more about the
18 # RhodeCode Enterprise Edition, including its added features, Support services,
18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
20
21 """
21 """
22 Database Models for RhodeCode Enterprise
22 Database Models for RhodeCode Enterprise
23 """
23 """
24
24
25 import re
25 import re
26 import os
26 import os
27 import time
27 import time
28 import hashlib
28 import hashlib
29 import logging
29 import logging
30 import datetime
30 import datetime
31 import warnings
31 import warnings
32 import ipaddress
32 import ipaddress
33 import functools
33 import functools
34 import traceback
34 import traceback
35 import collections
35 import collections
36
36
37
37
38 from sqlalchemy import *
38 from sqlalchemy import *
39 from sqlalchemy.ext.declarative import declared_attr
39 from sqlalchemy.ext.declarative import declared_attr
40 from sqlalchemy.ext.hybrid import hybrid_property
40 from sqlalchemy.ext.hybrid import hybrid_property
41 from sqlalchemy.orm import (
41 from sqlalchemy.orm import (
42 relationship, joinedload, class_mapper, validates, aliased)
42 relationship, joinedload, class_mapper, validates, aliased)
43 from sqlalchemy.sql.expression import true
43 from sqlalchemy.sql.expression import true
44 from sqlalchemy.sql.functions import coalesce, count # noqa
44 from sqlalchemy.sql.functions import coalesce, count # noqa
45 from beaker.cache import cache_region
45 from beaker.cache import cache_region
46 from zope.cachedescriptors.property import Lazy as LazyProperty
46 from zope.cachedescriptors.property import Lazy as LazyProperty
47
47
48 from pyramid.threadlocal import get_current_request
48 from pyramid.threadlocal import get_current_request
49
49
50 from rhodecode.translation import _
50 from rhodecode.translation import _
51 from rhodecode.lib.vcs import get_vcs_instance
51 from rhodecode.lib.vcs import get_vcs_instance
52 from rhodecode.lib.vcs.backends.base import EmptyCommit, Reference
52 from rhodecode.lib.vcs.backends.base import EmptyCommit, Reference
53 from rhodecode.lib.utils2 import (
53 from rhodecode.lib.utils2 import (
54 str2bool, safe_str, get_commit_safe, safe_unicode, md5_safe,
54 str2bool, safe_str, get_commit_safe, safe_unicode, md5_safe,
55 time_to_datetime, aslist, Optional, safe_int, get_clone_url, AttributeDict,
55 time_to_datetime, aslist, Optional, safe_int, get_clone_url, AttributeDict,
56 glob2re, StrictAttributeDict, cleaned_uri)
56 glob2re, StrictAttributeDict, cleaned_uri)
57 from rhodecode.lib.jsonalchemy import MutationObj, MutationList, JsonType
57 from rhodecode.lib.jsonalchemy import MutationObj, MutationList, JsonType
58 from rhodecode.lib.ext_json import json
58 from rhodecode.lib.ext_json import json
59 from rhodecode.lib.caching_query import FromCache
59 from rhodecode.lib.caching_query import FromCache
60 from rhodecode.lib.encrypt import AESCipher
60 from rhodecode.lib.encrypt import AESCipher
61
61
62 from rhodecode.model.meta import Base, Session
62 from rhodecode.model.meta import Base, Session
63
63
64 URL_SEP = '/'
64 URL_SEP = '/'
65 log = logging.getLogger(__name__)
65 log = logging.getLogger(__name__)
66
66
67 # =============================================================================
67 # =============================================================================
68 # BASE CLASSES
68 # BASE CLASSES
69 # =============================================================================
69 # =============================================================================
70
70
71 # this is propagated from .ini file rhodecode.encrypted_values.secret or
71 # this is propagated from .ini file rhodecode.encrypted_values.secret or
72 # beaker.session.secret if first is not set.
72 # beaker.session.secret if first is not set.
73 # and initialized at environment.py
73 # and initialized at environment.py
74 ENCRYPTION_KEY = None
74 ENCRYPTION_KEY = None
75
75
76 # used to sort permissions by types, '#' used here is not allowed to be in
76 # used to sort permissions by types, '#' used here is not allowed to be in
77 # usernames, and it's very early in sorted string.printable table.
77 # usernames, and it's very early in sorted string.printable table.
78 PERMISSION_TYPE_SORT = {
78 PERMISSION_TYPE_SORT = {
79 'admin': '####',
79 'admin': '####',
80 'write': '###',
80 'write': '###',
81 'read': '##',
81 'read': '##',
82 'none': '#',
82 'none': '#',
83 }
83 }
84
84
85
85
86 def display_sort(obj):
86 def display_sort(obj):
87 """
87 """
88 Sort function used to sort permissions in .permissions() function of
88 Sort function used to sort permissions in .permissions() function of
89 Repository, RepoGroup, UserGroup. Also it put the default user in front
89 Repository, RepoGroup, UserGroup. Also it put the default user in front
90 of all other resources
90 of all other resources
91 """
91 """
92
92
93 if obj.username == User.DEFAULT_USER:
93 if obj.username == User.DEFAULT_USER:
94 return '#####'
94 return '#####'
95 prefix = PERMISSION_TYPE_SORT.get(obj.permission.split('.')[-1], '')
95 prefix = PERMISSION_TYPE_SORT.get(obj.permission.split('.')[-1], '')
96 return prefix + obj.username
96 return prefix + obj.username
97
97
98
98
99 def _hash_key(k):
99 def _hash_key(k):
100 return md5_safe(k)
100 return md5_safe(k)
101
101
102
102
103 class EncryptedTextValue(TypeDecorator):
103 class EncryptedTextValue(TypeDecorator):
104 """
104 """
105 Special column for encrypted long text data, use like::
105 Special column for encrypted long text data, use like::
106
106
107 value = Column("encrypted_value", EncryptedValue(), nullable=False)
107 value = Column("encrypted_value", EncryptedValue(), nullable=False)
108
108
109 This column is intelligent so if value is in unencrypted form it return
109 This column is intelligent so if value is in unencrypted form it return
110 unencrypted form, but on save it always encrypts
110 unencrypted form, but on save it always encrypts
111 """
111 """
112 impl = Text
112 impl = Text
113
113
114 def process_bind_param(self, value, dialect):
114 def process_bind_param(self, value, dialect):
115 if not value:
115 if not value:
116 return value
116 return value
117 if value.startswith('enc$aes$') or value.startswith('enc$aes_hmac$'):
117 if value.startswith('enc$aes$') or value.startswith('enc$aes_hmac$'):
118 # protect against double encrypting if someone manually starts
118 # protect against double encrypting if someone manually starts
119 # doing
119 # doing
120 raise ValueError('value needs to be in unencrypted format, ie. '
120 raise ValueError('value needs to be in unencrypted format, ie. '
121 'not starting with enc$aes')
121 'not starting with enc$aes')
122 return 'enc$aes_hmac$%s' % AESCipher(
122 return 'enc$aes_hmac$%s' % AESCipher(
123 ENCRYPTION_KEY, hmac=True).encrypt(value)
123 ENCRYPTION_KEY, hmac=True).encrypt(value)
124
124
125 def process_result_value(self, value, dialect):
125 def process_result_value(self, value, dialect):
126 import rhodecode
126 import rhodecode
127
127
128 if not value:
128 if not value:
129 return value
129 return value
130
130
131 parts = value.split('$', 3)
131 parts = value.split('$', 3)
132 if not len(parts) == 3:
132 if not len(parts) == 3:
133 # probably not encrypted values
133 # probably not encrypted values
134 return value
134 return value
135 else:
135 else:
136 if parts[0] != 'enc':
136 if parts[0] != 'enc':
137 # parts ok but without our header ?
137 # parts ok but without our header ?
138 return value
138 return value
139 enc_strict_mode = str2bool(rhodecode.CONFIG.get(
139 enc_strict_mode = str2bool(rhodecode.CONFIG.get(
140 'rhodecode.encrypted_values.strict') or True)
140 'rhodecode.encrypted_values.strict') or True)
141 # at that stage we know it's our encryption
141 # at that stage we know it's our encryption
142 if parts[1] == 'aes':
142 if parts[1] == 'aes':
143 decrypted_data = AESCipher(ENCRYPTION_KEY).decrypt(parts[2])
143 decrypted_data = AESCipher(ENCRYPTION_KEY).decrypt(parts[2])
144 elif parts[1] == 'aes_hmac':
144 elif parts[1] == 'aes_hmac':
145 decrypted_data = AESCipher(
145 decrypted_data = AESCipher(
146 ENCRYPTION_KEY, hmac=True,
146 ENCRYPTION_KEY, hmac=True,
147 strict_verification=enc_strict_mode).decrypt(parts[2])
147 strict_verification=enc_strict_mode).decrypt(parts[2])
148 else:
148 else:
149 raise ValueError(
149 raise ValueError(
150 'Encryption type part is wrong, must be `aes` '
150 'Encryption type part is wrong, must be `aes` '
151 'or `aes_hmac`, got `%s` instead' % (parts[1]))
151 'or `aes_hmac`, got `%s` instead' % (parts[1]))
152 return decrypted_data
152 return decrypted_data
153
153
154
154
155 class BaseModel(object):
155 class BaseModel(object):
156 """
156 """
157 Base Model for all classes
157 Base Model for all classes
158 """
158 """
159
159
160 @classmethod
160 @classmethod
161 def _get_keys(cls):
161 def _get_keys(cls):
162 """return column names for this model """
162 """return column names for this model """
163 return class_mapper(cls).c.keys()
163 return class_mapper(cls).c.keys()
164
164
165 def get_dict(self):
165 def get_dict(self):
166 """
166 """
167 return dict with keys and values corresponding
167 return dict with keys and values corresponding
168 to this model data """
168 to this model data """
169
169
170 d = {}
170 d = {}
171 for k in self._get_keys():
171 for k in self._get_keys():
172 d[k] = getattr(self, k)
172 d[k] = getattr(self, k)
173
173
174 # also use __json__() if present to get additional fields
174 # also use __json__() if present to get additional fields
175 _json_attr = getattr(self, '__json__', None)
175 _json_attr = getattr(self, '__json__', None)
176 if _json_attr:
176 if _json_attr:
177 # update with attributes from __json__
177 # update with attributes from __json__
178 if callable(_json_attr):
178 if callable(_json_attr):
179 _json_attr = _json_attr()
179 _json_attr = _json_attr()
180 for k, val in _json_attr.iteritems():
180 for k, val in _json_attr.iteritems():
181 d[k] = val
181 d[k] = val
182 return d
182 return d
183
183
184 def get_appstruct(self):
184 def get_appstruct(self):
185 """return list with keys and values tuples corresponding
185 """return list with keys and values tuples corresponding
186 to this model data """
186 to this model data """
187
187
188 l = []
188 l = []
189 for k in self._get_keys():
189 for k in self._get_keys():
190 l.append((k, getattr(self, k),))
190 l.append((k, getattr(self, k),))
191 return l
191 return l
192
192
193 def populate_obj(self, populate_dict):
193 def populate_obj(self, populate_dict):
194 """populate model with data from given populate_dict"""
194 """populate model with data from given populate_dict"""
195
195
196 for k in self._get_keys():
196 for k in self._get_keys():
197 if k in populate_dict:
197 if k in populate_dict:
198 setattr(self, k, populate_dict[k])
198 setattr(self, k, populate_dict[k])
199
199
200 @classmethod
200 @classmethod
201 def query(cls):
201 def query(cls):
202 return Session().query(cls)
202 return Session().query(cls)
203
203
204 @classmethod
204 @classmethod
205 def get(cls, id_):
205 def get(cls, id_):
206 if id_:
206 if id_:
207 return cls.query().get(id_)
207 return cls.query().get(id_)
208
208
209 @classmethod
209 @classmethod
210 def get_or_404(cls, id_):
210 def get_or_404(cls, id_):
211 from pyramid.httpexceptions import HTTPNotFound
211 from pyramid.httpexceptions import HTTPNotFound
212
212
213 try:
213 try:
214 id_ = int(id_)
214 id_ = int(id_)
215 except (TypeError, ValueError):
215 except (TypeError, ValueError):
216 raise HTTPNotFound()
216 raise HTTPNotFound()
217
217
218 res = cls.query().get(id_)
218 res = cls.query().get(id_)
219 if not res:
219 if not res:
220 raise HTTPNotFound()
220 raise HTTPNotFound()
221 return res
221 return res
222
222
223 @classmethod
223 @classmethod
224 def getAll(cls):
224 def getAll(cls):
225 # deprecated and left for backward compatibility
225 # deprecated and left for backward compatibility
226 return cls.get_all()
226 return cls.get_all()
227
227
228 @classmethod
228 @classmethod
229 def get_all(cls):
229 def get_all(cls):
230 return cls.query().all()
230 return cls.query().all()
231
231
232 @classmethod
232 @classmethod
233 def delete(cls, id_):
233 def delete(cls, id_):
234 obj = cls.query().get(id_)
234 obj = cls.query().get(id_)
235 Session().delete(obj)
235 Session().delete(obj)
236
236
237 @classmethod
237 @classmethod
238 def identity_cache(cls, session, attr_name, value):
238 def identity_cache(cls, session, attr_name, value):
239 exist_in_session = []
239 exist_in_session = []
240 for (item_cls, pkey), instance in session.identity_map.items():
240 for (item_cls, pkey), instance in session.identity_map.items():
241 if cls == item_cls and getattr(instance, attr_name) == value:
241 if cls == item_cls and getattr(instance, attr_name) == value:
242 exist_in_session.append(instance)
242 exist_in_session.append(instance)
243 if exist_in_session:
243 if exist_in_session:
244 if len(exist_in_session) == 1:
244 if len(exist_in_session) == 1:
245 return exist_in_session[0]
245 return exist_in_session[0]
246 log.exception(
246 log.exception(
247 'multiple objects with attr %s and '
247 'multiple objects with attr %s and '
248 'value %s found with same name: %r',
248 'value %s found with same name: %r',
249 attr_name, value, exist_in_session)
249 attr_name, value, exist_in_session)
250
250
251 def __repr__(self):
251 def __repr__(self):
252 if hasattr(self, '__unicode__'):
252 if hasattr(self, '__unicode__'):
253 # python repr needs to return str
253 # python repr needs to return str
254 try:
254 try:
255 return safe_str(self.__unicode__())
255 return safe_str(self.__unicode__())
256 except UnicodeDecodeError:
256 except UnicodeDecodeError:
257 pass
257 pass
258 return '<DB:%s>' % (self.__class__.__name__)
258 return '<DB:%s>' % (self.__class__.__name__)
259
259
260
260
261 class RhodeCodeSetting(Base, BaseModel):
261 class RhodeCodeSetting(Base, BaseModel):
262 __tablename__ = 'rhodecode_settings'
262 __tablename__ = 'rhodecode_settings'
263 __table_args__ = (
263 __table_args__ = (
264 UniqueConstraint('app_settings_name'),
264 UniqueConstraint('app_settings_name'),
265 {'extend_existing': True, 'mysql_engine': 'InnoDB',
265 {'extend_existing': True, 'mysql_engine': 'InnoDB',
266 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
266 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
267 )
267 )
268
268
269 SETTINGS_TYPES = {
269 SETTINGS_TYPES = {
270 'str': safe_str,
270 'str': safe_str,
271 'int': safe_int,
271 'int': safe_int,
272 'unicode': safe_unicode,
272 'unicode': safe_unicode,
273 'bool': str2bool,
273 'bool': str2bool,
274 'list': functools.partial(aslist, sep=',')
274 'list': functools.partial(aslist, sep=',')
275 }
275 }
276 DEFAULT_UPDATE_URL = 'https://rhodecode.com/api/v1/info/versions'
276 DEFAULT_UPDATE_URL = 'https://rhodecode.com/api/v1/info/versions'
277 GLOBAL_CONF_KEY = 'app_settings'
277 GLOBAL_CONF_KEY = 'app_settings'
278
278
279 app_settings_id = Column("app_settings_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
279 app_settings_id = Column("app_settings_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
280 app_settings_name = Column("app_settings_name", String(255), nullable=True, unique=None, default=None)
280 app_settings_name = Column("app_settings_name", String(255), nullable=True, unique=None, default=None)
281 _app_settings_value = Column("app_settings_value", String(4096), nullable=True, unique=None, default=None)
281 _app_settings_value = Column("app_settings_value", String(4096), nullable=True, unique=None, default=None)
282 _app_settings_type = Column("app_settings_type", String(255), nullable=True, unique=None, default=None)
282 _app_settings_type = Column("app_settings_type", String(255), nullable=True, unique=None, default=None)
283
283
284 def __init__(self, key='', val='', type='unicode'):
284 def __init__(self, key='', val='', type='unicode'):
285 self.app_settings_name = key
285 self.app_settings_name = key
286 self.app_settings_type = type
286 self.app_settings_type = type
287 self.app_settings_value = val
287 self.app_settings_value = val
288
288
289 @validates('_app_settings_value')
289 @validates('_app_settings_value')
290 def validate_settings_value(self, key, val):
290 def validate_settings_value(self, key, val):
291 assert type(val) == unicode
291 assert type(val) == unicode
292 return val
292 return val
293
293
294 @hybrid_property
294 @hybrid_property
295 def app_settings_value(self):
295 def app_settings_value(self):
296 v = self._app_settings_value
296 v = self._app_settings_value
297 _type = self.app_settings_type
297 _type = self.app_settings_type
298 if _type:
298 if _type:
299 _type = self.app_settings_type.split('.')[0]
299 _type = self.app_settings_type.split('.')[0]
300 # decode the encrypted value
300 # decode the encrypted value
301 if 'encrypted' in self.app_settings_type:
301 if 'encrypted' in self.app_settings_type:
302 cipher = EncryptedTextValue()
302 cipher = EncryptedTextValue()
303 v = safe_unicode(cipher.process_result_value(v, None))
303 v = safe_unicode(cipher.process_result_value(v, None))
304
304
305 converter = self.SETTINGS_TYPES.get(_type) or \
305 converter = self.SETTINGS_TYPES.get(_type) or \
306 self.SETTINGS_TYPES['unicode']
306 self.SETTINGS_TYPES['unicode']
307 return converter(v)
307 return converter(v)
308
308
309 @app_settings_value.setter
309 @app_settings_value.setter
310 def app_settings_value(self, val):
310 def app_settings_value(self, val):
311 """
311 """
312 Setter that will always make sure we use unicode in app_settings_value
312 Setter that will always make sure we use unicode in app_settings_value
313
313
314 :param val:
314 :param val:
315 """
315 """
316 val = safe_unicode(val)
316 val = safe_unicode(val)
317 # encode the encrypted value
317 # encode the encrypted value
318 if 'encrypted' in self.app_settings_type:
318 if 'encrypted' in self.app_settings_type:
319 cipher = EncryptedTextValue()
319 cipher = EncryptedTextValue()
320 val = safe_unicode(cipher.process_bind_param(val, None))
320 val = safe_unicode(cipher.process_bind_param(val, None))
321 self._app_settings_value = val
321 self._app_settings_value = val
322
322
323 @hybrid_property
323 @hybrid_property
324 def app_settings_type(self):
324 def app_settings_type(self):
325 return self._app_settings_type
325 return self._app_settings_type
326
326
327 @app_settings_type.setter
327 @app_settings_type.setter
328 def app_settings_type(self, val):
328 def app_settings_type(self, val):
329 if val.split('.')[0] not in self.SETTINGS_TYPES:
329 if val.split('.')[0] not in self.SETTINGS_TYPES:
330 raise Exception('type must be one of %s got %s'
330 raise Exception('type must be one of %s got %s'
331 % (self.SETTINGS_TYPES.keys(), val))
331 % (self.SETTINGS_TYPES.keys(), val))
332 self._app_settings_type = val
332 self._app_settings_type = val
333
333
334 def __unicode__(self):
334 def __unicode__(self):
335 return u"<%s('%s:%s[%s]')>" % (
335 return u"<%s('%s:%s[%s]')>" % (
336 self.__class__.__name__,
336 self.__class__.__name__,
337 self.app_settings_name, self.app_settings_value,
337 self.app_settings_name, self.app_settings_value,
338 self.app_settings_type
338 self.app_settings_type
339 )
339 )
340
340
341
341
342 class RhodeCodeUi(Base, BaseModel):
342 class RhodeCodeUi(Base, BaseModel):
343 __tablename__ = 'rhodecode_ui'
343 __tablename__ = 'rhodecode_ui'
344 __table_args__ = (
344 __table_args__ = (
345 UniqueConstraint('ui_key'),
345 UniqueConstraint('ui_key'),
346 {'extend_existing': True, 'mysql_engine': 'InnoDB',
346 {'extend_existing': True, 'mysql_engine': 'InnoDB',
347 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
347 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
348 )
348 )
349
349
350 HOOK_REPO_SIZE = 'changegroup.repo_size'
350 HOOK_REPO_SIZE = 'changegroup.repo_size'
351 # HG
351 # HG
352 HOOK_PRE_PULL = 'preoutgoing.pre_pull'
352 HOOK_PRE_PULL = 'preoutgoing.pre_pull'
353 HOOK_PULL = 'outgoing.pull_logger'
353 HOOK_PULL = 'outgoing.pull_logger'
354 HOOK_PRE_PUSH = 'prechangegroup.pre_push'
354 HOOK_PRE_PUSH = 'prechangegroup.pre_push'
355 HOOK_PRETX_PUSH = 'pretxnchangegroup.pre_push'
355 HOOK_PRETX_PUSH = 'pretxnchangegroup.pre_push'
356 HOOK_PUSH = 'changegroup.push_logger'
356 HOOK_PUSH = 'changegroup.push_logger'
357 HOOK_PUSH_KEY = 'pushkey.key_push'
357 HOOK_PUSH_KEY = 'pushkey.key_push'
358
358
359 # TODO: johbo: Unify way how hooks are configured for git and hg,
359 # TODO: johbo: Unify way how hooks are configured for git and hg,
360 # git part is currently hardcoded.
360 # git part is currently hardcoded.
361
361
362 # SVN PATTERNS
362 # SVN PATTERNS
363 SVN_BRANCH_ID = 'vcs_svn_branch'
363 SVN_BRANCH_ID = 'vcs_svn_branch'
364 SVN_TAG_ID = 'vcs_svn_tag'
364 SVN_TAG_ID = 'vcs_svn_tag'
365
365
366 ui_id = Column(
366 ui_id = Column(
367 "ui_id", Integer(), nullable=False, unique=True, default=None,
367 "ui_id", Integer(), nullable=False, unique=True, default=None,
368 primary_key=True)
368 primary_key=True)
369 ui_section = Column(
369 ui_section = Column(
370 "ui_section", String(255), nullable=True, unique=None, default=None)
370 "ui_section", String(255), nullable=True, unique=None, default=None)
371 ui_key = Column(
371 ui_key = Column(
372 "ui_key", String(255), nullable=True, unique=None, default=None)
372 "ui_key", String(255), nullable=True, unique=None, default=None)
373 ui_value = Column(
373 ui_value = Column(
374 "ui_value", String(255), nullable=True, unique=None, default=None)
374 "ui_value", String(255), nullable=True, unique=None, default=None)
375 ui_active = Column(
375 ui_active = Column(
376 "ui_active", Boolean(), nullable=True, unique=None, default=True)
376 "ui_active", Boolean(), nullable=True, unique=None, default=True)
377
377
378 def __repr__(self):
378 def __repr__(self):
379 return '<%s[%s]%s=>%s]>' % (self.__class__.__name__, self.ui_section,
379 return '<%s[%s]%s=>%s]>' % (self.__class__.__name__, self.ui_section,
380 self.ui_key, self.ui_value)
380 self.ui_key, self.ui_value)
381
381
382
382
383 class RepoRhodeCodeSetting(Base, BaseModel):
383 class RepoRhodeCodeSetting(Base, BaseModel):
384 __tablename__ = 'repo_rhodecode_settings'
384 __tablename__ = 'repo_rhodecode_settings'
385 __table_args__ = (
385 __table_args__ = (
386 UniqueConstraint(
386 UniqueConstraint(
387 'app_settings_name', 'repository_id',
387 'app_settings_name', 'repository_id',
388 name='uq_repo_rhodecode_setting_name_repo_id'),
388 name='uq_repo_rhodecode_setting_name_repo_id'),
389 {'extend_existing': True, 'mysql_engine': 'InnoDB',
389 {'extend_existing': True, 'mysql_engine': 'InnoDB',
390 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
390 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
391 )
391 )
392
392
393 repository_id = Column(
393 repository_id = Column(
394 "repository_id", Integer(), ForeignKey('repositories.repo_id'),
394 "repository_id", Integer(), ForeignKey('repositories.repo_id'),
395 nullable=False)
395 nullable=False)
396 app_settings_id = Column(
396 app_settings_id = Column(
397 "app_settings_id", Integer(), nullable=False, unique=True,
397 "app_settings_id", Integer(), nullable=False, unique=True,
398 default=None, primary_key=True)
398 default=None, primary_key=True)
399 app_settings_name = Column(
399 app_settings_name = Column(
400 "app_settings_name", String(255), nullable=True, unique=None,
400 "app_settings_name", String(255), nullable=True, unique=None,
401 default=None)
401 default=None)
402 _app_settings_value = Column(
402 _app_settings_value = Column(
403 "app_settings_value", String(4096), nullable=True, unique=None,
403 "app_settings_value", String(4096), nullable=True, unique=None,
404 default=None)
404 default=None)
405 _app_settings_type = Column(
405 _app_settings_type = Column(
406 "app_settings_type", String(255), nullable=True, unique=None,
406 "app_settings_type", String(255), nullable=True, unique=None,
407 default=None)
407 default=None)
408
408
409 repository = relationship('Repository')
409 repository = relationship('Repository')
410
410
411 def __init__(self, repository_id, key='', val='', type='unicode'):
411 def __init__(self, repository_id, key='', val='', type='unicode'):
412 self.repository_id = repository_id
412 self.repository_id = repository_id
413 self.app_settings_name = key
413 self.app_settings_name = key
414 self.app_settings_type = type
414 self.app_settings_type = type
415 self.app_settings_value = val
415 self.app_settings_value = val
416
416
417 @validates('_app_settings_value')
417 @validates('_app_settings_value')
418 def validate_settings_value(self, key, val):
418 def validate_settings_value(self, key, val):
419 assert type(val) == unicode
419 assert type(val) == unicode
420 return val
420 return val
421
421
422 @hybrid_property
422 @hybrid_property
423 def app_settings_value(self):
423 def app_settings_value(self):
424 v = self._app_settings_value
424 v = self._app_settings_value
425 type_ = self.app_settings_type
425 type_ = self.app_settings_type
426 SETTINGS_TYPES = RhodeCodeSetting.SETTINGS_TYPES
426 SETTINGS_TYPES = RhodeCodeSetting.SETTINGS_TYPES
427 converter = SETTINGS_TYPES.get(type_) or SETTINGS_TYPES['unicode']
427 converter = SETTINGS_TYPES.get(type_) or SETTINGS_TYPES['unicode']
428 return converter(v)
428 return converter(v)
429
429
430 @app_settings_value.setter
430 @app_settings_value.setter
431 def app_settings_value(self, val):
431 def app_settings_value(self, val):
432 """
432 """
433 Setter that will always make sure we use unicode in app_settings_value
433 Setter that will always make sure we use unicode in app_settings_value
434
434
435 :param val:
435 :param val:
436 """
436 """
437 self._app_settings_value = safe_unicode(val)
437 self._app_settings_value = safe_unicode(val)
438
438
439 @hybrid_property
439 @hybrid_property
440 def app_settings_type(self):
440 def app_settings_type(self):
441 return self._app_settings_type
441 return self._app_settings_type
442
442
443 @app_settings_type.setter
443 @app_settings_type.setter
444 def app_settings_type(self, val):
444 def app_settings_type(self, val):
445 SETTINGS_TYPES = RhodeCodeSetting.SETTINGS_TYPES
445 SETTINGS_TYPES = RhodeCodeSetting.SETTINGS_TYPES
446 if val not in SETTINGS_TYPES:
446 if val not in SETTINGS_TYPES:
447 raise Exception('type must be one of %s got %s'
447 raise Exception('type must be one of %s got %s'
448 % (SETTINGS_TYPES.keys(), val))
448 % (SETTINGS_TYPES.keys(), val))
449 self._app_settings_type = val
449 self._app_settings_type = val
450
450
451 def __unicode__(self):
451 def __unicode__(self):
452 return u"<%s('%s:%s:%s[%s]')>" % (
452 return u"<%s('%s:%s:%s[%s]')>" % (
453 self.__class__.__name__, self.repository.repo_name,
453 self.__class__.__name__, self.repository.repo_name,
454 self.app_settings_name, self.app_settings_value,
454 self.app_settings_name, self.app_settings_value,
455 self.app_settings_type
455 self.app_settings_type
456 )
456 )
457
457
458
458
459 class RepoRhodeCodeUi(Base, BaseModel):
459 class RepoRhodeCodeUi(Base, BaseModel):
460 __tablename__ = 'repo_rhodecode_ui'
460 __tablename__ = 'repo_rhodecode_ui'
461 __table_args__ = (
461 __table_args__ = (
462 UniqueConstraint(
462 UniqueConstraint(
463 'repository_id', 'ui_section', 'ui_key',
463 'repository_id', 'ui_section', 'ui_key',
464 name='uq_repo_rhodecode_ui_repository_id_section_key'),
464 name='uq_repo_rhodecode_ui_repository_id_section_key'),
465 {'extend_existing': True, 'mysql_engine': 'InnoDB',
465 {'extend_existing': True, 'mysql_engine': 'InnoDB',
466 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
466 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
467 )
467 )
468
468
469 repository_id = Column(
469 repository_id = Column(
470 "repository_id", Integer(), ForeignKey('repositories.repo_id'),
470 "repository_id", Integer(), ForeignKey('repositories.repo_id'),
471 nullable=False)
471 nullable=False)
472 ui_id = Column(
472 ui_id = Column(
473 "ui_id", Integer(), nullable=False, unique=True, default=None,
473 "ui_id", Integer(), nullable=False, unique=True, default=None,
474 primary_key=True)
474 primary_key=True)
475 ui_section = Column(
475 ui_section = Column(
476 "ui_section", String(255), nullable=True, unique=None, default=None)
476 "ui_section", String(255), nullable=True, unique=None, default=None)
477 ui_key = Column(
477 ui_key = Column(
478 "ui_key", String(255), nullable=True, unique=None, default=None)
478 "ui_key", String(255), nullable=True, unique=None, default=None)
479 ui_value = Column(
479 ui_value = Column(
480 "ui_value", String(255), nullable=True, unique=None, default=None)
480 "ui_value", String(255), nullable=True, unique=None, default=None)
481 ui_active = Column(
481 ui_active = Column(
482 "ui_active", Boolean(), nullable=True, unique=None, default=True)
482 "ui_active", Boolean(), nullable=True, unique=None, default=True)
483
483
484 repository = relationship('Repository')
484 repository = relationship('Repository')
485
485
486 def __repr__(self):
486 def __repr__(self):
487 return '<%s[%s:%s]%s=>%s]>' % (
487 return '<%s[%s:%s]%s=>%s]>' % (
488 self.__class__.__name__, self.repository.repo_name,
488 self.__class__.__name__, self.repository.repo_name,
489 self.ui_section, self.ui_key, self.ui_value)
489 self.ui_section, self.ui_key, self.ui_value)
490
490
491
491
492 class User(Base, BaseModel):
492 class User(Base, BaseModel):
493 __tablename__ = 'users'
493 __tablename__ = 'users'
494 __table_args__ = (
494 __table_args__ = (
495 UniqueConstraint('username'), UniqueConstraint('email'),
495 UniqueConstraint('username'), UniqueConstraint('email'),
496 Index('u_username_idx', 'username'),
496 Index('u_username_idx', 'username'),
497 Index('u_email_idx', 'email'),
497 Index('u_email_idx', 'email'),
498 {'extend_existing': True, 'mysql_engine': 'InnoDB',
498 {'extend_existing': True, 'mysql_engine': 'InnoDB',
499 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
499 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
500 )
500 )
501 DEFAULT_USER = 'default'
501 DEFAULT_USER = 'default'
502 DEFAULT_USER_EMAIL = 'anonymous@rhodecode.org'
502 DEFAULT_USER_EMAIL = 'anonymous@rhodecode.org'
503 DEFAULT_GRAVATAR_URL = 'https://secure.gravatar.com/avatar/{md5email}?d=identicon&s={size}'
503 DEFAULT_GRAVATAR_URL = 'https://secure.gravatar.com/avatar/{md5email}?d=identicon&s={size}'
504
504
505 user_id = Column("user_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
505 user_id = Column("user_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
506 username = Column("username", String(255), nullable=True, unique=None, default=None)
506 username = Column("username", String(255), nullable=True, unique=None, default=None)
507 password = Column("password", String(255), nullable=True, unique=None, default=None)
507 password = Column("password", String(255), nullable=True, unique=None, default=None)
508 active = Column("active", Boolean(), nullable=True, unique=None, default=True)
508 active = Column("active", Boolean(), nullable=True, unique=None, default=True)
509 admin = Column("admin", Boolean(), nullable=True, unique=None, default=False)
509 admin = Column("admin", Boolean(), nullable=True, unique=None, default=False)
510 name = Column("firstname", String(255), nullable=True, unique=None, default=None)
510 name = Column("firstname", String(255), nullable=True, unique=None, default=None)
511 lastname = Column("lastname", String(255), nullable=True, unique=None, default=None)
511 lastname = Column("lastname", String(255), nullable=True, unique=None, default=None)
512 _email = Column("email", String(255), nullable=True, unique=None, default=None)
512 _email = Column("email", String(255), nullable=True, unique=None, default=None)
513 last_login = Column("last_login", DateTime(timezone=False), nullable=True, unique=None, default=None)
513 last_login = Column("last_login", DateTime(timezone=False), nullable=True, unique=None, default=None)
514 last_activity = Column('last_activity', DateTime(timezone=False), nullable=True, unique=None, default=None)
514 last_activity = Column('last_activity', DateTime(timezone=False), nullable=True, unique=None, default=None)
515
515
516 extern_type = Column("extern_type", String(255), nullable=True, unique=None, default=None)
516 extern_type = Column("extern_type", String(255), nullable=True, unique=None, default=None)
517 extern_name = Column("extern_name", String(255), nullable=True, unique=None, default=None)
517 extern_name = Column("extern_name", String(255), nullable=True, unique=None, default=None)
518 _api_key = Column("api_key", String(255), nullable=True, unique=None, default=None)
518 _api_key = Column("api_key", String(255), nullable=True, unique=None, default=None)
519 inherit_default_permissions = Column("inherit_default_permissions", Boolean(), nullable=False, unique=None, default=True)
519 inherit_default_permissions = Column("inherit_default_permissions", Boolean(), nullable=False, unique=None, default=True)
520 created_on = Column('created_on', DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
520 created_on = Column('created_on', DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
521 _user_data = Column("user_data", LargeBinary(), nullable=True) # JSON data
521 _user_data = Column("user_data", LargeBinary(), nullable=True) # JSON data
522
522
523 user_log = relationship('UserLog')
523 user_log = relationship('UserLog')
524 user_perms = relationship('UserToPerm', primaryjoin="User.user_id==UserToPerm.user_id", cascade='all')
524 user_perms = relationship('UserToPerm', primaryjoin="User.user_id==UserToPerm.user_id", cascade='all')
525
525
526 repositories = relationship('Repository')
526 repositories = relationship('Repository')
527 repository_groups = relationship('RepoGroup')
527 repository_groups = relationship('RepoGroup')
528 user_groups = relationship('UserGroup')
528 user_groups = relationship('UserGroup')
529
529
530 user_followers = relationship('UserFollowing', primaryjoin='UserFollowing.follows_user_id==User.user_id', cascade='all')
530 user_followers = relationship('UserFollowing', primaryjoin='UserFollowing.follows_user_id==User.user_id', cascade='all')
531 followings = relationship('UserFollowing', primaryjoin='UserFollowing.user_id==User.user_id', cascade='all')
531 followings = relationship('UserFollowing', primaryjoin='UserFollowing.user_id==User.user_id', cascade='all')
532
532
533 repo_to_perm = relationship('UserRepoToPerm', primaryjoin='UserRepoToPerm.user_id==User.user_id', cascade='all')
533 repo_to_perm = relationship('UserRepoToPerm', primaryjoin='UserRepoToPerm.user_id==User.user_id', cascade='all')
534 repo_group_to_perm = relationship('UserRepoGroupToPerm', primaryjoin='UserRepoGroupToPerm.user_id==User.user_id', cascade='all')
534 repo_group_to_perm = relationship('UserRepoGroupToPerm', primaryjoin='UserRepoGroupToPerm.user_id==User.user_id', cascade='all')
535 user_group_to_perm = relationship('UserUserGroupToPerm', primaryjoin='UserUserGroupToPerm.user_id==User.user_id', cascade='all')
535 user_group_to_perm = relationship('UserUserGroupToPerm', primaryjoin='UserUserGroupToPerm.user_id==User.user_id', cascade='all')
536
536
537 group_member = relationship('UserGroupMember', cascade='all')
537 group_member = relationship('UserGroupMember', cascade='all')
538
538
539 notifications = relationship('UserNotification', cascade='all')
539 notifications = relationship('UserNotification', cascade='all')
540 # notifications assigned to this user
540 # notifications assigned to this user
541 user_created_notifications = relationship('Notification', cascade='all')
541 user_created_notifications = relationship('Notification', cascade='all')
542 # comments created by this user
542 # comments created by this user
543 user_comments = relationship('ChangesetComment', cascade='all')
543 user_comments = relationship('ChangesetComment', cascade='all')
544 # user profile extra info
544 # user profile extra info
545 user_emails = relationship('UserEmailMap', cascade='all')
545 user_emails = relationship('UserEmailMap', cascade='all')
546 user_ip_map = relationship('UserIpMap', cascade='all')
546 user_ip_map = relationship('UserIpMap', cascade='all')
547 user_auth_tokens = relationship('UserApiKeys', cascade='all')
547 user_auth_tokens = relationship('UserApiKeys', cascade='all')
548 user_ssh_keys = relationship('UserSshKeys', cascade='all')
549
548 # gists
550 # gists
549 user_gists = relationship('Gist', cascade='all')
551 user_gists = relationship('Gist', cascade='all')
550 # user pull requests
552 # user pull requests
551 user_pull_requests = relationship('PullRequest', cascade='all')
553 user_pull_requests = relationship('PullRequest', cascade='all')
552 # external identities
554 # external identities
553 extenal_identities = relationship(
555 extenal_identities = relationship(
554 'ExternalIdentity',
556 'ExternalIdentity',
555 primaryjoin="User.user_id==ExternalIdentity.local_user_id",
557 primaryjoin="User.user_id==ExternalIdentity.local_user_id",
556 cascade='all')
558 cascade='all')
557
559
558 def __unicode__(self):
560 def __unicode__(self):
559 return u"<%s('id:%s:%s')>" % (self.__class__.__name__,
561 return u"<%s('id:%s:%s')>" % (self.__class__.__name__,
560 self.user_id, self.username)
562 self.user_id, self.username)
561
563
562 @hybrid_property
564 @hybrid_property
563 def email(self):
565 def email(self):
564 return self._email
566 return self._email
565
567
566 @email.setter
568 @email.setter
567 def email(self, val):
569 def email(self, val):
568 self._email = val.lower() if val else None
570 self._email = val.lower() if val else None
569
571
570 @hybrid_property
572 @hybrid_property
571 def first_name(self):
573 def first_name(self):
572 from rhodecode.lib import helpers as h
574 from rhodecode.lib import helpers as h
573 if self.name:
575 if self.name:
574 return h.escape(self.name)
576 return h.escape(self.name)
575 return self.name
577 return self.name
576
578
577 @hybrid_property
579 @hybrid_property
578 def last_name(self):
580 def last_name(self):
579 from rhodecode.lib import helpers as h
581 from rhodecode.lib import helpers as h
580 if self.lastname:
582 if self.lastname:
581 return h.escape(self.lastname)
583 return h.escape(self.lastname)
582 return self.lastname
584 return self.lastname
583
585
584 @hybrid_property
586 @hybrid_property
585 def api_key(self):
587 def api_key(self):
586 """
588 """
587 Fetch if exist an auth-token with role ALL connected to this user
589 Fetch if exist an auth-token with role ALL connected to this user
588 """
590 """
589 user_auth_token = UserApiKeys.query()\
591 user_auth_token = UserApiKeys.query()\
590 .filter(UserApiKeys.user_id == self.user_id)\
592 .filter(UserApiKeys.user_id == self.user_id)\
591 .filter(or_(UserApiKeys.expires == -1,
593 .filter(or_(UserApiKeys.expires == -1,
592 UserApiKeys.expires >= time.time()))\
594 UserApiKeys.expires >= time.time()))\
593 .filter(UserApiKeys.role == UserApiKeys.ROLE_ALL).first()
595 .filter(UserApiKeys.role == UserApiKeys.ROLE_ALL).first()
594 if user_auth_token:
596 if user_auth_token:
595 user_auth_token = user_auth_token.api_key
597 user_auth_token = user_auth_token.api_key
596
598
597 return user_auth_token
599 return user_auth_token
598
600
599 @api_key.setter
601 @api_key.setter
600 def api_key(self, val):
602 def api_key(self, val):
601 # don't allow to set API key this is deprecated for now
603 # don't allow to set API key this is deprecated for now
602 self._api_key = None
604 self._api_key = None
603
605
604 @property
606 @property
605 def reviewer_pull_requests(self):
607 def reviewer_pull_requests(self):
606 return PullRequestReviewers.query() \
608 return PullRequestReviewers.query() \
607 .options(joinedload(PullRequestReviewers.pull_request)) \
609 .options(joinedload(PullRequestReviewers.pull_request)) \
608 .filter(PullRequestReviewers.user_id == self.user_id) \
610 .filter(PullRequestReviewers.user_id == self.user_id) \
609 .all()
611 .all()
610
612
611 @property
613 @property
612 def firstname(self):
614 def firstname(self):
613 # alias for future
615 # alias for future
614 return self.name
616 return self.name
615
617
616 @property
618 @property
617 def emails(self):
619 def emails(self):
618 other = UserEmailMap.query()\
620 other = UserEmailMap.query()\
619 .filter(UserEmailMap.user == self) \
621 .filter(UserEmailMap.user == self) \
620 .order_by(UserEmailMap.email_id.asc()) \
622 .order_by(UserEmailMap.email_id.asc()) \
621 .all()
623 .all()
622 return [self.email] + [x.email for x in other]
624 return [self.email] + [x.email for x in other]
623
625
624 @property
626 @property
625 def auth_tokens(self):
627 def auth_tokens(self):
626 auth_tokens = self.get_auth_tokens()
628 auth_tokens = self.get_auth_tokens()
627 return [x.api_key for x in auth_tokens]
629 return [x.api_key for x in auth_tokens]
628
630
629 def get_auth_tokens(self):
631 def get_auth_tokens(self):
630 return UserApiKeys.query()\
632 return UserApiKeys.query()\
631 .filter(UserApiKeys.user == self)\
633 .filter(UserApiKeys.user == self)\
632 .order_by(UserApiKeys.user_api_key_id.asc())\
634 .order_by(UserApiKeys.user_api_key_id.asc())\
633 .all()
635 .all()
634
636
635 @property
637 @property
636 def feed_token(self):
638 def feed_token(self):
637 return self.get_feed_token()
639 return self.get_feed_token()
638
640
639 def get_feed_token(self):
641 def get_feed_token(self):
640 feed_tokens = UserApiKeys.query()\
642 feed_tokens = UserApiKeys.query()\
641 .filter(UserApiKeys.user == self)\
643 .filter(UserApiKeys.user == self)\
642 .filter(UserApiKeys.role == UserApiKeys.ROLE_FEED)\
644 .filter(UserApiKeys.role == UserApiKeys.ROLE_FEED)\
643 .all()
645 .all()
644 if feed_tokens:
646 if feed_tokens:
645 return feed_tokens[0].api_key
647 return feed_tokens[0].api_key
646 return 'NO_FEED_TOKEN_AVAILABLE'
648 return 'NO_FEED_TOKEN_AVAILABLE'
647
649
648 @classmethod
650 @classmethod
649 def extra_valid_auth_tokens(cls, user, role=None):
651 def extra_valid_auth_tokens(cls, user, role=None):
650 tokens = UserApiKeys.query().filter(UserApiKeys.user == user)\
652 tokens = UserApiKeys.query().filter(UserApiKeys.user == user)\
651 .filter(or_(UserApiKeys.expires == -1,
653 .filter(or_(UserApiKeys.expires == -1,
652 UserApiKeys.expires >= time.time()))
654 UserApiKeys.expires >= time.time()))
653 if role:
655 if role:
654 tokens = tokens.filter(or_(UserApiKeys.role == role,
656 tokens = tokens.filter(or_(UserApiKeys.role == role,
655 UserApiKeys.role == UserApiKeys.ROLE_ALL))
657 UserApiKeys.role == UserApiKeys.ROLE_ALL))
656 return tokens.all()
658 return tokens.all()
657
659
658 def authenticate_by_token(self, auth_token, roles=None, scope_repo_id=None):
660 def authenticate_by_token(self, auth_token, roles=None, scope_repo_id=None):
659 from rhodecode.lib import auth
661 from rhodecode.lib import auth
660
662
661 log.debug('Trying to authenticate user: %s via auth-token, '
663 log.debug('Trying to authenticate user: %s via auth-token, '
662 'and roles: %s', self, roles)
664 'and roles: %s', self, roles)
663
665
664 if not auth_token:
666 if not auth_token:
665 return False
667 return False
666
668
667 crypto_backend = auth.crypto_backend()
669 crypto_backend = auth.crypto_backend()
668
670
669 roles = (roles or []) + [UserApiKeys.ROLE_ALL]
671 roles = (roles or []) + [UserApiKeys.ROLE_ALL]
670 tokens_q = UserApiKeys.query()\
672 tokens_q = UserApiKeys.query()\
671 .filter(UserApiKeys.user_id == self.user_id)\
673 .filter(UserApiKeys.user_id == self.user_id)\
672 .filter(or_(UserApiKeys.expires == -1,
674 .filter(or_(UserApiKeys.expires == -1,
673 UserApiKeys.expires >= time.time()))
675 UserApiKeys.expires >= time.time()))
674
676
675 tokens_q = tokens_q.filter(UserApiKeys.role.in_(roles))
677 tokens_q = tokens_q.filter(UserApiKeys.role.in_(roles))
676
678
677 plain_tokens = []
679 plain_tokens = []
678 hash_tokens = []
680 hash_tokens = []
679
681
680 for token in tokens_q.all():
682 for token in tokens_q.all():
681 # verify scope first
683 # verify scope first
682 if token.repo_id:
684 if token.repo_id:
683 # token has a scope, we need to verify it
685 # token has a scope, we need to verify it
684 if scope_repo_id != token.repo_id:
686 if scope_repo_id != token.repo_id:
685 log.debug(
687 log.debug(
686 'Scope mismatch: token has a set repo scope: %s, '
688 'Scope mismatch: token has a set repo scope: %s, '
687 'and calling scope is:%s, skipping further checks',
689 'and calling scope is:%s, skipping further checks',
688 token.repo, scope_repo_id)
690 token.repo, scope_repo_id)
689 # token has a scope, and it doesn't match, skip token
691 # token has a scope, and it doesn't match, skip token
690 continue
692 continue
691
693
692 if token.api_key.startswith(crypto_backend.ENC_PREF):
694 if token.api_key.startswith(crypto_backend.ENC_PREF):
693 hash_tokens.append(token.api_key)
695 hash_tokens.append(token.api_key)
694 else:
696 else:
695 plain_tokens.append(token.api_key)
697 plain_tokens.append(token.api_key)
696
698
697 is_plain_match = auth_token in plain_tokens
699 is_plain_match = auth_token in plain_tokens
698 if is_plain_match:
700 if is_plain_match:
699 return True
701 return True
700
702
701 for hashed in hash_tokens:
703 for hashed in hash_tokens:
702 # TODO(marcink): this is expensive to calculate, but most secure
704 # TODO(marcink): this is expensive to calculate, but most secure
703 match = crypto_backend.hash_check(auth_token, hashed)
705 match = crypto_backend.hash_check(auth_token, hashed)
704 if match:
706 if match:
705 return True
707 return True
706
708
707 return False
709 return False
708
710
709 @property
711 @property
710 def ip_addresses(self):
712 def ip_addresses(self):
711 ret = UserIpMap.query().filter(UserIpMap.user == self).all()
713 ret = UserIpMap.query().filter(UserIpMap.user == self).all()
712 return [x.ip_addr for x in ret]
714 return [x.ip_addr for x in ret]
713
715
714 @property
716 @property
715 def username_and_name(self):
717 def username_and_name(self):
716 return '%s (%s %s)' % (self.username, self.first_name, self.last_name)
718 return '%s (%s %s)' % (self.username, self.first_name, self.last_name)
717
719
718 @property
720 @property
719 def username_or_name_or_email(self):
721 def username_or_name_or_email(self):
720 full_name = self.full_name if self.full_name is not ' ' else None
722 full_name = self.full_name if self.full_name is not ' ' else None
721 return self.username or full_name or self.email
723 return self.username or full_name or self.email
722
724
723 @property
725 @property
724 def full_name(self):
726 def full_name(self):
725 return '%s %s' % (self.first_name, self.last_name)
727 return '%s %s' % (self.first_name, self.last_name)
726
728
727 @property
729 @property
728 def full_name_or_username(self):
730 def full_name_or_username(self):
729 return ('%s %s' % (self.first_name, self.last_name)
731 return ('%s %s' % (self.first_name, self.last_name)
730 if (self.first_name and self.last_name) else self.username)
732 if (self.first_name and self.last_name) else self.username)
731
733
732 @property
734 @property
733 def full_contact(self):
735 def full_contact(self):
734 return '%s %s <%s>' % (self.first_name, self.last_name, self.email)
736 return '%s %s <%s>' % (self.first_name, self.last_name, self.email)
735
737
736 @property
738 @property
737 def short_contact(self):
739 def short_contact(self):
738 return '%s %s' % (self.first_name, self.last_name)
740 return '%s %s' % (self.first_name, self.last_name)
739
741
740 @property
742 @property
741 def is_admin(self):
743 def is_admin(self):
742 return self.admin
744 return self.admin
743
745
744 @property
746 @property
745 def AuthUser(self):
747 def AuthUser(self):
746 """
748 """
747 Returns instance of AuthUser for this user
749 Returns instance of AuthUser for this user
748 """
750 """
749 from rhodecode.lib.auth import AuthUser
751 from rhodecode.lib.auth import AuthUser
750 return AuthUser(user_id=self.user_id, username=self.username)
752 return AuthUser(user_id=self.user_id, username=self.username)
751
753
752 @hybrid_property
754 @hybrid_property
753 def user_data(self):
755 def user_data(self):
754 if not self._user_data:
756 if not self._user_data:
755 return {}
757 return {}
756
758
757 try:
759 try:
758 return json.loads(self._user_data)
760 return json.loads(self._user_data)
759 except TypeError:
761 except TypeError:
760 return {}
762 return {}
761
763
762 @user_data.setter
764 @user_data.setter
763 def user_data(self, val):
765 def user_data(self, val):
764 if not isinstance(val, dict):
766 if not isinstance(val, dict):
765 raise Exception('user_data must be dict, got %s' % type(val))
767 raise Exception('user_data must be dict, got %s' % type(val))
766 try:
768 try:
767 self._user_data = json.dumps(val)
769 self._user_data = json.dumps(val)
768 except Exception:
770 except Exception:
769 log.error(traceback.format_exc())
771 log.error(traceback.format_exc())
770
772
771 @classmethod
773 @classmethod
772 def get_by_username(cls, username, case_insensitive=False,
774 def get_by_username(cls, username, case_insensitive=False,
773 cache=False, identity_cache=False):
775 cache=False, identity_cache=False):
774 session = Session()
776 session = Session()
775
777
776 if case_insensitive:
778 if case_insensitive:
777 q = cls.query().filter(
779 q = cls.query().filter(
778 func.lower(cls.username) == func.lower(username))
780 func.lower(cls.username) == func.lower(username))
779 else:
781 else:
780 q = cls.query().filter(cls.username == username)
782 q = cls.query().filter(cls.username == username)
781
783
782 if cache:
784 if cache:
783 if identity_cache:
785 if identity_cache:
784 val = cls.identity_cache(session, 'username', username)
786 val = cls.identity_cache(session, 'username', username)
785 if val:
787 if val:
786 return val
788 return val
787 else:
789 else:
788 cache_key = "get_user_by_name_%s" % _hash_key(username)
790 cache_key = "get_user_by_name_%s" % _hash_key(username)
789 q = q.options(
791 q = q.options(
790 FromCache("sql_cache_short", cache_key))
792 FromCache("sql_cache_short", cache_key))
791
793
792 return q.scalar()
794 return q.scalar()
793
795
794 @classmethod
796 @classmethod
795 def get_by_auth_token(cls, auth_token, cache=False):
797 def get_by_auth_token(cls, auth_token, cache=False):
796 q = UserApiKeys.query()\
798 q = UserApiKeys.query()\
797 .filter(UserApiKeys.api_key == auth_token)\
799 .filter(UserApiKeys.api_key == auth_token)\
798 .filter(or_(UserApiKeys.expires == -1,
800 .filter(or_(UserApiKeys.expires == -1,
799 UserApiKeys.expires >= time.time()))
801 UserApiKeys.expires >= time.time()))
800 if cache:
802 if cache:
801 q = q.options(
803 q = q.options(
802 FromCache("sql_cache_short", "get_auth_token_%s" % auth_token))
804 FromCache("sql_cache_short", "get_auth_token_%s" % auth_token))
803
805
804 match = q.first()
806 match = q.first()
805 if match:
807 if match:
806 return match.user
808 return match.user
807
809
808 @classmethod
810 @classmethod
809 def get_by_email(cls, email, case_insensitive=False, cache=False):
811 def get_by_email(cls, email, case_insensitive=False, cache=False):
810
812
811 if case_insensitive:
813 if case_insensitive:
812 q = cls.query().filter(func.lower(cls.email) == func.lower(email))
814 q = cls.query().filter(func.lower(cls.email) == func.lower(email))
813
815
814 else:
816 else:
815 q = cls.query().filter(cls.email == email)
817 q = cls.query().filter(cls.email == email)
816
818
817 email_key = _hash_key(email)
819 email_key = _hash_key(email)
818 if cache:
820 if cache:
819 q = q.options(
821 q = q.options(
820 FromCache("sql_cache_short", "get_email_key_%s" % email_key))
822 FromCache("sql_cache_short", "get_email_key_%s" % email_key))
821
823
822 ret = q.scalar()
824 ret = q.scalar()
823 if ret is None:
825 if ret is None:
824 q = UserEmailMap.query()
826 q = UserEmailMap.query()
825 # try fetching in alternate email map
827 # try fetching in alternate email map
826 if case_insensitive:
828 if case_insensitive:
827 q = q.filter(func.lower(UserEmailMap.email) == func.lower(email))
829 q = q.filter(func.lower(UserEmailMap.email) == func.lower(email))
828 else:
830 else:
829 q = q.filter(UserEmailMap.email == email)
831 q = q.filter(UserEmailMap.email == email)
830 q = q.options(joinedload(UserEmailMap.user))
832 q = q.options(joinedload(UserEmailMap.user))
831 if cache:
833 if cache:
832 q = q.options(
834 q = q.options(
833 FromCache("sql_cache_short", "get_email_map_key_%s" % email_key))
835 FromCache("sql_cache_short", "get_email_map_key_%s" % email_key))
834 ret = getattr(q.scalar(), 'user', None)
836 ret = getattr(q.scalar(), 'user', None)
835
837
836 return ret
838 return ret
837
839
838 @classmethod
840 @classmethod
839 def get_from_cs_author(cls, author):
841 def get_from_cs_author(cls, author):
840 """
842 """
841 Tries to get User objects out of commit author string
843 Tries to get User objects out of commit author string
842
844
843 :param author:
845 :param author:
844 """
846 """
845 from rhodecode.lib.helpers import email, author_name
847 from rhodecode.lib.helpers import email, author_name
846 # Valid email in the attribute passed, see if they're in the system
848 # Valid email in the attribute passed, see if they're in the system
847 _email = email(author)
849 _email = email(author)
848 if _email:
850 if _email:
849 user = cls.get_by_email(_email, case_insensitive=True)
851 user = cls.get_by_email(_email, case_insensitive=True)
850 if user:
852 if user:
851 return user
853 return user
852 # Maybe we can match by username?
854 # Maybe we can match by username?
853 _author = author_name(author)
855 _author = author_name(author)
854 user = cls.get_by_username(_author, case_insensitive=True)
856 user = cls.get_by_username(_author, case_insensitive=True)
855 if user:
857 if user:
856 return user
858 return user
857
859
858 def update_userdata(self, **kwargs):
860 def update_userdata(self, **kwargs):
859 usr = self
861 usr = self
860 old = usr.user_data
862 old = usr.user_data
861 old.update(**kwargs)
863 old.update(**kwargs)
862 usr.user_data = old
864 usr.user_data = old
863 Session().add(usr)
865 Session().add(usr)
864 log.debug('updated userdata with ', kwargs)
866 log.debug('updated userdata with ', kwargs)
865
867
866 def update_lastlogin(self):
868 def update_lastlogin(self):
867 """Update user lastlogin"""
869 """Update user lastlogin"""
868 self.last_login = datetime.datetime.now()
870 self.last_login = datetime.datetime.now()
869 Session().add(self)
871 Session().add(self)
870 log.debug('updated user %s lastlogin', self.username)
872 log.debug('updated user %s lastlogin', self.username)
871
873
872 def update_lastactivity(self):
874 def update_lastactivity(self):
873 """Update user lastactivity"""
875 """Update user lastactivity"""
874 self.last_activity = datetime.datetime.now()
876 self.last_activity = datetime.datetime.now()
875 Session().add(self)
877 Session().add(self)
876 log.debug('updated user %s lastactivity', self.username)
878 log.debug('updated user %s lastactivity', self.username)
877
879
878 def update_password(self, new_password):
880 def update_password(self, new_password):
879 from rhodecode.lib.auth import get_crypt_password
881 from rhodecode.lib.auth import get_crypt_password
880
882
881 self.password = get_crypt_password(new_password)
883 self.password = get_crypt_password(new_password)
882 Session().add(self)
884 Session().add(self)
883
885
884 @classmethod
886 @classmethod
885 def get_first_super_admin(cls):
887 def get_first_super_admin(cls):
886 user = User.query().filter(User.admin == true()).first()
888 user = User.query().filter(User.admin == true()).first()
887 if user is None:
889 if user is None:
888 raise Exception('FATAL: Missing administrative account!')
890 raise Exception('FATAL: Missing administrative account!')
889 return user
891 return user
890
892
891 @classmethod
893 @classmethod
892 def get_all_super_admins(cls):
894 def get_all_super_admins(cls):
893 """
895 """
894 Returns all admin accounts sorted by username
896 Returns all admin accounts sorted by username
895 """
897 """
896 return User.query().filter(User.admin == true())\
898 return User.query().filter(User.admin == true())\
897 .order_by(User.username.asc()).all()
899 .order_by(User.username.asc()).all()
898
900
899 @classmethod
901 @classmethod
900 def get_default_user(cls, cache=False, refresh=False):
902 def get_default_user(cls, cache=False, refresh=False):
901 user = User.get_by_username(User.DEFAULT_USER, cache=cache)
903 user = User.get_by_username(User.DEFAULT_USER, cache=cache)
902 if user is None:
904 if user is None:
903 raise Exception('FATAL: Missing default account!')
905 raise Exception('FATAL: Missing default account!')
904 if refresh:
906 if refresh:
905 # The default user might be based on outdated state which
907 # The default user might be based on outdated state which
906 # has been loaded from the cache.
908 # has been loaded from the cache.
907 # A call to refresh() ensures that the
909 # A call to refresh() ensures that the
908 # latest state from the database is used.
910 # latest state from the database is used.
909 Session().refresh(user)
911 Session().refresh(user)
910 return user
912 return user
911
913
912 def _get_default_perms(self, user, suffix=''):
914 def _get_default_perms(self, user, suffix=''):
913 from rhodecode.model.permission import PermissionModel
915 from rhodecode.model.permission import PermissionModel
914 return PermissionModel().get_default_perms(user.user_perms, suffix)
916 return PermissionModel().get_default_perms(user.user_perms, suffix)
915
917
916 def get_default_perms(self, suffix=''):
918 def get_default_perms(self, suffix=''):
917 return self._get_default_perms(self, suffix)
919 return self._get_default_perms(self, suffix)
918
920
919 def get_api_data(self, include_secrets=False, details='full'):
921 def get_api_data(self, include_secrets=False, details='full'):
920 """
922 """
921 Common function for generating user related data for API
923 Common function for generating user related data for API
922
924
923 :param include_secrets: By default secrets in the API data will be replaced
925 :param include_secrets: By default secrets in the API data will be replaced
924 by a placeholder value to prevent exposing this data by accident. In case
926 by a placeholder value to prevent exposing this data by accident. In case
925 this data shall be exposed, set this flag to ``True``.
927 this data shall be exposed, set this flag to ``True``.
926
928
927 :param details: details can be 'basic|full' basic gives only a subset of
929 :param details: details can be 'basic|full' basic gives only a subset of
928 the available user information that includes user_id, name and emails.
930 the available user information that includes user_id, name and emails.
929 """
931 """
930 user = self
932 user = self
931 user_data = self.user_data
933 user_data = self.user_data
932 data = {
934 data = {
933 'user_id': user.user_id,
935 'user_id': user.user_id,
934 'username': user.username,
936 'username': user.username,
935 'firstname': user.name,
937 'firstname': user.name,
936 'lastname': user.lastname,
938 'lastname': user.lastname,
937 'email': user.email,
939 'email': user.email,
938 'emails': user.emails,
940 'emails': user.emails,
939 }
941 }
940 if details == 'basic':
942 if details == 'basic':
941 return data
943 return data
942
944
943 auth_token_length = 40
945 auth_token_length = 40
944 auth_token_replacement = '*' * auth_token_length
946 auth_token_replacement = '*' * auth_token_length
945
947
946 extras = {
948 extras = {
947 'auth_tokens': [auth_token_replacement],
949 'auth_tokens': [auth_token_replacement],
948 'active': user.active,
950 'active': user.active,
949 'admin': user.admin,
951 'admin': user.admin,
950 'extern_type': user.extern_type,
952 'extern_type': user.extern_type,
951 'extern_name': user.extern_name,
953 'extern_name': user.extern_name,
952 'last_login': user.last_login,
954 'last_login': user.last_login,
953 'last_activity': user.last_activity,
955 'last_activity': user.last_activity,
954 'ip_addresses': user.ip_addresses,
956 'ip_addresses': user.ip_addresses,
955 'language': user_data.get('language')
957 'language': user_data.get('language')
956 }
958 }
957 data.update(extras)
959 data.update(extras)
958
960
959 if include_secrets:
961 if include_secrets:
960 data['auth_tokens'] = user.auth_tokens
962 data['auth_tokens'] = user.auth_tokens
961 return data
963 return data
962
964
963 def __json__(self):
965 def __json__(self):
964 data = {
966 data = {
965 'full_name': self.full_name,
967 'full_name': self.full_name,
966 'full_name_or_username': self.full_name_or_username,
968 'full_name_or_username': self.full_name_or_username,
967 'short_contact': self.short_contact,
969 'short_contact': self.short_contact,
968 'full_contact': self.full_contact,
970 'full_contact': self.full_contact,
969 }
971 }
970 data.update(self.get_api_data())
972 data.update(self.get_api_data())
971 return data
973 return data
972
974
973
975
974 class UserApiKeys(Base, BaseModel):
976 class UserApiKeys(Base, BaseModel):
975 __tablename__ = 'user_api_keys'
977 __tablename__ = 'user_api_keys'
976 __table_args__ = (
978 __table_args__ = (
977 Index('uak_api_key_idx', 'api_key', unique=True),
979 Index('uak_api_key_idx', 'api_key', unique=True),
978 Index('uak_api_key_expires_idx', 'api_key', 'expires'),
980 Index('uak_api_key_expires_idx', 'api_key', 'expires'),
979 {'extend_existing': True, 'mysql_engine': 'InnoDB',
981 {'extend_existing': True, 'mysql_engine': 'InnoDB',
980 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
982 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
981 )
983 )
982 __mapper_args__ = {}
984 __mapper_args__ = {}
983
985
984 # ApiKey role
986 # ApiKey role
985 ROLE_ALL = 'token_role_all'
987 ROLE_ALL = 'token_role_all'
986 ROLE_HTTP = 'token_role_http'
988 ROLE_HTTP = 'token_role_http'
987 ROLE_VCS = 'token_role_vcs'
989 ROLE_VCS = 'token_role_vcs'
988 ROLE_API = 'token_role_api'
990 ROLE_API = 'token_role_api'
989 ROLE_FEED = 'token_role_feed'
991 ROLE_FEED = 'token_role_feed'
990 ROLE_PASSWORD_RESET = 'token_password_reset'
992 ROLE_PASSWORD_RESET = 'token_password_reset'
991
993
992 ROLES = [ROLE_ALL, ROLE_HTTP, ROLE_VCS, ROLE_API, ROLE_FEED]
994 ROLES = [ROLE_ALL, ROLE_HTTP, ROLE_VCS, ROLE_API, ROLE_FEED]
993
995
994 user_api_key_id = Column("user_api_key_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
996 user_api_key_id = Column("user_api_key_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
995 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=True, unique=None, default=None)
997 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=True, unique=None, default=None)
996 api_key = Column("api_key", String(255), nullable=False, unique=True)
998 api_key = Column("api_key", String(255), nullable=False, unique=True)
997 description = Column('description', UnicodeText().with_variant(UnicodeText(1024), 'mysql'))
999 description = Column('description', UnicodeText().with_variant(UnicodeText(1024), 'mysql'))
998 expires = Column('expires', Float(53), nullable=False)
1000 expires = Column('expires', Float(53), nullable=False)
999 role = Column('role', String(255), nullable=True)
1001 role = Column('role', String(255), nullable=True)
1000 created_on = Column('created_on', DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
1002 created_on = Column('created_on', DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
1001
1003
1002 # scope columns
1004 # scope columns
1003 repo_id = Column(
1005 repo_id = Column(
1004 'repo_id', Integer(), ForeignKey('repositories.repo_id'),
1006 'repo_id', Integer(), ForeignKey('repositories.repo_id'),
1005 nullable=True, unique=None, default=None)
1007 nullable=True, unique=None, default=None)
1006 repo = relationship('Repository', lazy='joined')
1008 repo = relationship('Repository', lazy='joined')
1007
1009
1008 repo_group_id = Column(
1010 repo_group_id = Column(
1009 'repo_group_id', Integer(), ForeignKey('groups.group_id'),
1011 'repo_group_id', Integer(), ForeignKey('groups.group_id'),
1010 nullable=True, unique=None, default=None)
1012 nullable=True, unique=None, default=None)
1011 repo_group = relationship('RepoGroup', lazy='joined')
1013 repo_group = relationship('RepoGroup', lazy='joined')
1012
1014
1013 user = relationship('User', lazy='joined')
1015 user = relationship('User', lazy='joined')
1014
1016
1015 def __unicode__(self):
1017 def __unicode__(self):
1016 return u"<%s('%s')>" % (self.__class__.__name__, self.role)
1018 return u"<%s('%s')>" % (self.__class__.__name__, self.role)
1017
1019
1018 def __json__(self):
1020 def __json__(self):
1019 data = {
1021 data = {
1020 'auth_token': self.api_key,
1022 'auth_token': self.api_key,
1021 'role': self.role,
1023 'role': self.role,
1022 'scope': self.scope_humanized,
1024 'scope': self.scope_humanized,
1023 'expired': self.expired
1025 'expired': self.expired
1024 }
1026 }
1025 return data
1027 return data
1026
1028
1027 def get_api_data(self, include_secrets=False):
1029 def get_api_data(self, include_secrets=False):
1028 data = self.__json__()
1030 data = self.__json__()
1029 if include_secrets:
1031 if include_secrets:
1030 return data
1032 return data
1031 else:
1033 else:
1032 data['auth_token'] = self.token_obfuscated
1034 data['auth_token'] = self.token_obfuscated
1033 return data
1035 return data
1034
1036
1035 @hybrid_property
1037 @hybrid_property
1036 def description_safe(self):
1038 def description_safe(self):
1037 from rhodecode.lib import helpers as h
1039 from rhodecode.lib import helpers as h
1038 return h.escape(self.description)
1040 return h.escape(self.description)
1039
1041
1040 @property
1042 @property
1041 def expired(self):
1043 def expired(self):
1042 if self.expires == -1:
1044 if self.expires == -1:
1043 return False
1045 return False
1044 return time.time() > self.expires
1046 return time.time() > self.expires
1045
1047
1046 @classmethod
1048 @classmethod
1047 def _get_role_name(cls, role):
1049 def _get_role_name(cls, role):
1048 return {
1050 return {
1049 cls.ROLE_ALL: _('all'),
1051 cls.ROLE_ALL: _('all'),
1050 cls.ROLE_HTTP: _('http/web interface'),
1052 cls.ROLE_HTTP: _('http/web interface'),
1051 cls.ROLE_VCS: _('vcs (git/hg/svn protocol)'),
1053 cls.ROLE_VCS: _('vcs (git/hg/svn protocol)'),
1052 cls.ROLE_API: _('api calls'),
1054 cls.ROLE_API: _('api calls'),
1053 cls.ROLE_FEED: _('feed access'),
1055 cls.ROLE_FEED: _('feed access'),
1054 }.get(role, role)
1056 }.get(role, role)
1055
1057
1056 @property
1058 @property
1057 def role_humanized(self):
1059 def role_humanized(self):
1058 return self._get_role_name(self.role)
1060 return self._get_role_name(self.role)
1059
1061
1060 def _get_scope(self):
1062 def _get_scope(self):
1061 if self.repo:
1063 if self.repo:
1062 return repr(self.repo)
1064 return repr(self.repo)
1063 if self.repo_group:
1065 if self.repo_group:
1064 return repr(self.repo_group) + ' (recursive)'
1066 return repr(self.repo_group) + ' (recursive)'
1065 return 'global'
1067 return 'global'
1066
1068
1067 @property
1069 @property
1068 def scope_humanized(self):
1070 def scope_humanized(self):
1069 return self._get_scope()
1071 return self._get_scope()
1070
1072
1071 @property
1073 @property
1072 def token_obfuscated(self):
1074 def token_obfuscated(self):
1073 if self.api_key:
1075 if self.api_key:
1074 return self.api_key[:4] + "****"
1076 return self.api_key[:4] + "****"
1075
1077
1076
1078
1077 class UserEmailMap(Base, BaseModel):
1079 class UserEmailMap(Base, BaseModel):
1078 __tablename__ = 'user_email_map'
1080 __tablename__ = 'user_email_map'
1079 __table_args__ = (
1081 __table_args__ = (
1080 Index('uem_email_idx', 'email'),
1082 Index('uem_email_idx', 'email'),
1081 UniqueConstraint('email'),
1083 UniqueConstraint('email'),
1082 {'extend_existing': True, 'mysql_engine': 'InnoDB',
1084 {'extend_existing': True, 'mysql_engine': 'InnoDB',
1083 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
1085 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
1084 )
1086 )
1085 __mapper_args__ = {}
1087 __mapper_args__ = {}
1086
1088
1087 email_id = Column("email_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
1089 email_id = Column("email_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
1088 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=True, unique=None, default=None)
1090 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=True, unique=None, default=None)
1089 _email = Column("email", String(255), nullable=True, unique=False, default=None)
1091 _email = Column("email", String(255), nullable=True, unique=False, default=None)
1090 user = relationship('User', lazy='joined')
1092 user = relationship('User', lazy='joined')
1091
1093
1092 @validates('_email')
1094 @validates('_email')
1093 def validate_email(self, key, email):
1095 def validate_email(self, key, email):
1094 # check if this email is not main one
1096 # check if this email is not main one
1095 main_email = Session().query(User).filter(User.email == email).scalar()
1097 main_email = Session().query(User).filter(User.email == email).scalar()
1096 if main_email is not None:
1098 if main_email is not None:
1097 raise AttributeError('email %s is present is user table' % email)
1099 raise AttributeError('email %s is present is user table' % email)
1098 return email
1100 return email
1099
1101
1100 @hybrid_property
1102 @hybrid_property
1101 def email(self):
1103 def email(self):
1102 return self._email
1104 return self._email
1103
1105
1104 @email.setter
1106 @email.setter
1105 def email(self, val):
1107 def email(self, val):
1106 self._email = val.lower() if val else None
1108 self._email = val.lower() if val else None
1107
1109
1108
1110
1109 class UserIpMap(Base, BaseModel):
1111 class UserIpMap(Base, BaseModel):
1110 __tablename__ = 'user_ip_map'
1112 __tablename__ = 'user_ip_map'
1111 __table_args__ = (
1113 __table_args__ = (
1112 UniqueConstraint('user_id', 'ip_addr'),
1114 UniqueConstraint('user_id', 'ip_addr'),
1113 {'extend_existing': True, 'mysql_engine': 'InnoDB',
1115 {'extend_existing': True, 'mysql_engine': 'InnoDB',
1114 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
1116 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
1115 )
1117 )
1116 __mapper_args__ = {}
1118 __mapper_args__ = {}
1117
1119
1118 ip_id = Column("ip_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
1120 ip_id = Column("ip_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
1119 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=True, unique=None, default=None)
1121 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=True, unique=None, default=None)
1120 ip_addr = Column("ip_addr", String(255), nullable=True, unique=False, default=None)
1122 ip_addr = Column("ip_addr", String(255), nullable=True, unique=False, default=None)
1121 active = Column("active", Boolean(), nullable=True, unique=None, default=True)
1123 active = Column("active", Boolean(), nullable=True, unique=None, default=True)
1122 description = Column("description", String(10000), nullable=True, unique=None, default=None)
1124 description = Column("description", String(10000), nullable=True, unique=None, default=None)
1123 user = relationship('User', lazy='joined')
1125 user = relationship('User', lazy='joined')
1124
1126
1125 @hybrid_property
1127 @hybrid_property
1126 def description_safe(self):
1128 def description_safe(self):
1127 from rhodecode.lib import helpers as h
1129 from rhodecode.lib import helpers as h
1128 return h.escape(self.description)
1130 return h.escape(self.description)
1129
1131
1130 @classmethod
1132 @classmethod
1131 def _get_ip_range(cls, ip_addr):
1133 def _get_ip_range(cls, ip_addr):
1132 net = ipaddress.ip_network(safe_unicode(ip_addr), strict=False)
1134 net = ipaddress.ip_network(safe_unicode(ip_addr), strict=False)
1133 return [str(net.network_address), str(net.broadcast_address)]
1135 return [str(net.network_address), str(net.broadcast_address)]
1134
1136
1135 def __json__(self):
1137 def __json__(self):
1136 return {
1138 return {
1137 'ip_addr': self.ip_addr,
1139 'ip_addr': self.ip_addr,
1138 'ip_range': self._get_ip_range(self.ip_addr),
1140 'ip_range': self._get_ip_range(self.ip_addr),
1139 }
1141 }
1140
1142
1141 def __unicode__(self):
1143 def __unicode__(self):
1142 return u"<%s('user_id:%s=>%s')>" % (self.__class__.__name__,
1144 return u"<%s('user_id:%s=>%s')>" % (self.__class__.__name__,
1143 self.user_id, self.ip_addr)
1145 self.user_id, self.ip_addr)
1144
1146
1145
1147
1148 class UserSshKeys(Base, BaseModel):
1149 __tablename__ = 'user_ssh_keys'
1150 __table_args__ = (
1151 Index('usk_ssh_key_fingerprint_idx', 'ssh_key_fingerprint'),
1152
1153 UniqueConstraint('ssh_key_fingerprint'),
1154
1155 {'extend_existing': True, 'mysql_engine': 'InnoDB',
1156 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
1157 )
1158 __mapper_args__ = {}
1159
1160 ssh_key_id = Column('ssh_key_id', Integer(), nullable=False, unique=True, default=None, primary_key=True)
1161 ssh_key_data = Column('ssh_key_data', String(10240), nullable=False, unique=None, default=None)
1162 ssh_key_fingerprint = Column('ssh_key_fingerprint', String(1024), nullable=False, unique=None, default=None)
1163
1164 description = Column('description', UnicodeText().with_variant(UnicodeText(1024), 'mysql'))
1165
1166 created_on = Column('created_on', DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
1167 accessed_on = Column('accessed_on', DateTime(timezone=False), nullable=True, default=None)
1168 user_id = Column('user_id', Integer(), ForeignKey('users.user_id'), nullable=True, unique=None, default=None)
1169
1170 user = relationship('User', lazy='joined')
1171
1172 def __json__(self):
1173 data = {
1174 'ssh_fingerprint': self.ssh_key_fingerprint,
1175 'description': self.description,
1176 'created_on': self.created_on
1177 }
1178 return data
1179
1180 def get_api_data(self):
1181 data = self.__json__()
1182 return data
1183
1184
1146 class UserLog(Base, BaseModel):
1185 class UserLog(Base, BaseModel):
1147 __tablename__ = 'user_logs'
1186 __tablename__ = 'user_logs'
1148 __table_args__ = (
1187 __table_args__ = (
1149 {'extend_existing': True, 'mysql_engine': 'InnoDB',
1188 {'extend_existing': True, 'mysql_engine': 'InnoDB',
1150 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
1189 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
1151 )
1190 )
1152 VERSION_1 = 'v1'
1191 VERSION_1 = 'v1'
1153 VERSION_2 = 'v2'
1192 VERSION_2 = 'v2'
1154 VERSIONS = [VERSION_1, VERSION_2]
1193 VERSIONS = [VERSION_1, VERSION_2]
1155
1194
1156 user_log_id = Column("user_log_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
1195 user_log_id = Column("user_log_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
1157 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=True, unique=None, default=None)
1196 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=True, unique=None, default=None)
1158 username = Column("username", String(255), nullable=True, unique=None, default=None)
1197 username = Column("username", String(255), nullable=True, unique=None, default=None)
1159 repository_id = Column("repository_id", Integer(), ForeignKey('repositories.repo_id'), nullable=True)
1198 repository_id = Column("repository_id", Integer(), ForeignKey('repositories.repo_id'), nullable=True)
1160 repository_name = Column("repository_name", String(255), nullable=True, unique=None, default=None)
1199 repository_name = Column("repository_name", String(255), nullable=True, unique=None, default=None)
1161 user_ip = Column("user_ip", String(255), nullable=True, unique=None, default=None)
1200 user_ip = Column("user_ip", String(255), nullable=True, unique=None, default=None)
1162 action = Column("action", Text().with_variant(Text(1200000), 'mysql'), nullable=True, unique=None, default=None)
1201 action = Column("action", Text().with_variant(Text(1200000), 'mysql'), nullable=True, unique=None, default=None)
1163 action_date = Column("action_date", DateTime(timezone=False), nullable=True, unique=None, default=None)
1202 action_date = Column("action_date", DateTime(timezone=False), nullable=True, unique=None, default=None)
1164
1203
1165 version = Column("version", String(255), nullable=True, default=VERSION_1)
1204 version = Column("version", String(255), nullable=True, default=VERSION_1)
1166 user_data = Column('user_data_json', MutationObj.as_mutable(JsonType(dialect_map=dict(mysql=UnicodeText(16384)))))
1205 user_data = Column('user_data_json', MutationObj.as_mutable(JsonType(dialect_map=dict(mysql=UnicodeText(16384)))))
1167 action_data = Column('action_data_json', MutationObj.as_mutable(JsonType(dialect_map=dict(mysql=UnicodeText(16384)))))
1206 action_data = Column('action_data_json', MutationObj.as_mutable(JsonType(dialect_map=dict(mysql=UnicodeText(16384)))))
1168
1207
1169 def __unicode__(self):
1208 def __unicode__(self):
1170 return u"<%s('id:%s:%s')>" % (
1209 return u"<%s('id:%s:%s')>" % (
1171 self.__class__.__name__, self.repository_name, self.action)
1210 self.__class__.__name__, self.repository_name, self.action)
1172
1211
1173 def __json__(self):
1212 def __json__(self):
1174 return {
1213 return {
1175 'user_id': self.user_id,
1214 'user_id': self.user_id,
1176 'username': self.username,
1215 'username': self.username,
1177 'repository_id': self.repository_id,
1216 'repository_id': self.repository_id,
1178 'repository_name': self.repository_name,
1217 'repository_name': self.repository_name,
1179 'user_ip': self.user_ip,
1218 'user_ip': self.user_ip,
1180 'action_date': self.action_date,
1219 'action_date': self.action_date,
1181 'action': self.action,
1220 'action': self.action,
1182 }
1221 }
1183
1222
1184 @property
1223 @property
1185 def action_as_day(self):
1224 def action_as_day(self):
1186 return datetime.date(*self.action_date.timetuple()[:3])
1225 return datetime.date(*self.action_date.timetuple()[:3])
1187
1226
1188 user = relationship('User')
1227 user = relationship('User')
1189 repository = relationship('Repository', cascade='')
1228 repository = relationship('Repository', cascade='')
1190
1229
1191
1230
1192 class UserGroup(Base, BaseModel):
1231 class UserGroup(Base, BaseModel):
1193 __tablename__ = 'users_groups'
1232 __tablename__ = 'users_groups'
1194 __table_args__ = (
1233 __table_args__ = (
1195 {'extend_existing': True, 'mysql_engine': 'InnoDB',
1234 {'extend_existing': True, 'mysql_engine': 'InnoDB',
1196 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
1235 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
1197 )
1236 )
1198
1237
1199 users_group_id = Column("users_group_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
1238 users_group_id = Column("users_group_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
1200 users_group_name = Column("users_group_name", String(255), nullable=False, unique=True, default=None)
1239 users_group_name = Column("users_group_name", String(255), nullable=False, unique=True, default=None)
1201 user_group_description = Column("user_group_description", String(10000), nullable=True, unique=None, default=None)
1240 user_group_description = Column("user_group_description", String(10000), nullable=True, unique=None, default=None)
1202 users_group_active = Column("users_group_active", Boolean(), nullable=True, unique=None, default=None)
1241 users_group_active = Column("users_group_active", Boolean(), nullable=True, unique=None, default=None)
1203 inherit_default_permissions = Column("users_group_inherit_default_permissions", Boolean(), nullable=False, unique=None, default=True)
1242 inherit_default_permissions = Column("users_group_inherit_default_permissions", Boolean(), nullable=False, unique=None, default=True)
1204 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=False, default=None)
1243 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=False, default=None)
1205 created_on = Column('created_on', DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
1244 created_on = Column('created_on', DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
1206 _group_data = Column("group_data", LargeBinary(), nullable=True) # JSON data
1245 _group_data = Column("group_data", LargeBinary(), nullable=True) # JSON data
1207
1246
1208 members = relationship('UserGroupMember', cascade="all, delete, delete-orphan", lazy="joined")
1247 members = relationship('UserGroupMember', cascade="all, delete, delete-orphan", lazy="joined")
1209 users_group_to_perm = relationship('UserGroupToPerm', cascade='all')
1248 users_group_to_perm = relationship('UserGroupToPerm', cascade='all')
1210 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1249 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1211 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
1250 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
1212 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
1251 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
1213 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm ', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
1252 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm ', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
1214
1253
1215 user = relationship('User', primaryjoin="User.user_id==UserGroup.user_id")
1254 user = relationship('User', primaryjoin="User.user_id==UserGroup.user_id")
1216
1255
1217 @classmethod
1256 @classmethod
1218 def _load_group_data(cls, column):
1257 def _load_group_data(cls, column):
1219 if not column:
1258 if not column:
1220 return {}
1259 return {}
1221
1260
1222 try:
1261 try:
1223 return json.loads(column) or {}
1262 return json.loads(column) or {}
1224 except TypeError:
1263 except TypeError:
1225 return {}
1264 return {}
1226
1265
1227 @hybrid_property
1266 @hybrid_property
1228 def description_safe(self):
1267 def description_safe(self):
1229 from rhodecode.lib import helpers as h
1268 from rhodecode.lib import helpers as h
1230 return h.escape(self.description)
1269 return h.escape(self.description)
1231
1270
1232 @hybrid_property
1271 @hybrid_property
1233 def group_data(self):
1272 def group_data(self):
1234 return self._load_group_data(self._group_data)
1273 return self._load_group_data(self._group_data)
1235
1274
1236 @group_data.expression
1275 @group_data.expression
1237 def group_data(self, **kwargs):
1276 def group_data(self, **kwargs):
1238 return self._group_data
1277 return self._group_data
1239
1278
1240 @group_data.setter
1279 @group_data.setter
1241 def group_data(self, val):
1280 def group_data(self, val):
1242 try:
1281 try:
1243 self._group_data = json.dumps(val)
1282 self._group_data = json.dumps(val)
1244 except Exception:
1283 except Exception:
1245 log.error(traceback.format_exc())
1284 log.error(traceback.format_exc())
1246
1285
1247 def __unicode__(self):
1286 def __unicode__(self):
1248 return u"<%s('id:%s:%s')>" % (self.__class__.__name__,
1287 return u"<%s('id:%s:%s')>" % (self.__class__.__name__,
1249 self.users_group_id,
1288 self.users_group_id,
1250 self.users_group_name)
1289 self.users_group_name)
1251
1290
1252 @classmethod
1291 @classmethod
1253 def get_by_group_name(cls, group_name, cache=False,
1292 def get_by_group_name(cls, group_name, cache=False,
1254 case_insensitive=False):
1293 case_insensitive=False):
1255 if case_insensitive:
1294 if case_insensitive:
1256 q = cls.query().filter(func.lower(cls.users_group_name) ==
1295 q = cls.query().filter(func.lower(cls.users_group_name) ==
1257 func.lower(group_name))
1296 func.lower(group_name))
1258
1297
1259 else:
1298 else:
1260 q = cls.query().filter(cls.users_group_name == group_name)
1299 q = cls.query().filter(cls.users_group_name == group_name)
1261 if cache:
1300 if cache:
1262 q = q.options(
1301 q = q.options(
1263 FromCache("sql_cache_short", "get_group_%s" % _hash_key(group_name)))
1302 FromCache("sql_cache_short", "get_group_%s" % _hash_key(group_name)))
1264 return q.scalar()
1303 return q.scalar()
1265
1304
1266 @classmethod
1305 @classmethod
1267 def get(cls, user_group_id, cache=False):
1306 def get(cls, user_group_id, cache=False):
1268 user_group = cls.query()
1307 user_group = cls.query()
1269 if cache:
1308 if cache:
1270 user_group = user_group.options(
1309 user_group = user_group.options(
1271 FromCache("sql_cache_short", "get_users_group_%s" % user_group_id))
1310 FromCache("sql_cache_short", "get_users_group_%s" % user_group_id))
1272 return user_group.get(user_group_id)
1311 return user_group.get(user_group_id)
1273
1312
1274 def permissions(self, with_admins=True, with_owner=True):
1313 def permissions(self, with_admins=True, with_owner=True):
1275 q = UserUserGroupToPerm.query().filter(UserUserGroupToPerm.user_group == self)
1314 q = UserUserGroupToPerm.query().filter(UserUserGroupToPerm.user_group == self)
1276 q = q.options(joinedload(UserUserGroupToPerm.user_group),
1315 q = q.options(joinedload(UserUserGroupToPerm.user_group),
1277 joinedload(UserUserGroupToPerm.user),
1316 joinedload(UserUserGroupToPerm.user),
1278 joinedload(UserUserGroupToPerm.permission),)
1317 joinedload(UserUserGroupToPerm.permission),)
1279
1318
1280 # get owners and admins and permissions. We do a trick of re-writing
1319 # get owners and admins and permissions. We do a trick of re-writing
1281 # objects from sqlalchemy to named-tuples due to sqlalchemy session
1320 # objects from sqlalchemy to named-tuples due to sqlalchemy session
1282 # has a global reference and changing one object propagates to all
1321 # has a global reference and changing one object propagates to all
1283 # others. This means if admin is also an owner admin_row that change
1322 # others. This means if admin is also an owner admin_row that change
1284 # would propagate to both objects
1323 # would propagate to both objects
1285 perm_rows = []
1324 perm_rows = []
1286 for _usr in q.all():
1325 for _usr in q.all():
1287 usr = AttributeDict(_usr.user.get_dict())
1326 usr = AttributeDict(_usr.user.get_dict())
1288 usr.permission = _usr.permission.permission_name
1327 usr.permission = _usr.permission.permission_name
1289 perm_rows.append(usr)
1328 perm_rows.append(usr)
1290
1329
1291 # filter the perm rows by 'default' first and then sort them by
1330 # filter the perm rows by 'default' first and then sort them by
1292 # admin,write,read,none permissions sorted again alphabetically in
1331 # admin,write,read,none permissions sorted again alphabetically in
1293 # each group
1332 # each group
1294 perm_rows = sorted(perm_rows, key=display_sort)
1333 perm_rows = sorted(perm_rows, key=display_sort)
1295
1334
1296 _admin_perm = 'usergroup.admin'
1335 _admin_perm = 'usergroup.admin'
1297 owner_row = []
1336 owner_row = []
1298 if with_owner:
1337 if with_owner:
1299 usr = AttributeDict(self.user.get_dict())
1338 usr = AttributeDict(self.user.get_dict())
1300 usr.owner_row = True
1339 usr.owner_row = True
1301 usr.permission = _admin_perm
1340 usr.permission = _admin_perm
1302 owner_row.append(usr)
1341 owner_row.append(usr)
1303
1342
1304 super_admin_rows = []
1343 super_admin_rows = []
1305 if with_admins:
1344 if with_admins:
1306 for usr in User.get_all_super_admins():
1345 for usr in User.get_all_super_admins():
1307 # if this admin is also owner, don't double the record
1346 # if this admin is also owner, don't double the record
1308 if usr.user_id == owner_row[0].user_id:
1347 if usr.user_id == owner_row[0].user_id:
1309 owner_row[0].admin_row = True
1348 owner_row[0].admin_row = True
1310 else:
1349 else:
1311 usr = AttributeDict(usr.get_dict())
1350 usr = AttributeDict(usr.get_dict())
1312 usr.admin_row = True
1351 usr.admin_row = True
1313 usr.permission = _admin_perm
1352 usr.permission = _admin_perm
1314 super_admin_rows.append(usr)
1353 super_admin_rows.append(usr)
1315
1354
1316 return super_admin_rows + owner_row + perm_rows
1355 return super_admin_rows + owner_row + perm_rows
1317
1356
1318 def permission_user_groups(self):
1357 def permission_user_groups(self):
1319 q = UserGroupUserGroupToPerm.query().filter(UserGroupUserGroupToPerm.target_user_group == self)
1358 q = UserGroupUserGroupToPerm.query().filter(UserGroupUserGroupToPerm.target_user_group == self)
1320 q = q.options(joinedload(UserGroupUserGroupToPerm.user_group),
1359 q = q.options(joinedload(UserGroupUserGroupToPerm.user_group),
1321 joinedload(UserGroupUserGroupToPerm.target_user_group),
1360 joinedload(UserGroupUserGroupToPerm.target_user_group),
1322 joinedload(UserGroupUserGroupToPerm.permission),)
1361 joinedload(UserGroupUserGroupToPerm.permission),)
1323
1362
1324 perm_rows = []
1363 perm_rows = []
1325 for _user_group in q.all():
1364 for _user_group in q.all():
1326 usr = AttributeDict(_user_group.user_group.get_dict())
1365 usr = AttributeDict(_user_group.user_group.get_dict())
1327 usr.permission = _user_group.permission.permission_name
1366 usr.permission = _user_group.permission.permission_name
1328 perm_rows.append(usr)
1367 perm_rows.append(usr)
1329
1368
1330 return perm_rows
1369 return perm_rows
1331
1370
1332 def _get_default_perms(self, user_group, suffix=''):
1371 def _get_default_perms(self, user_group, suffix=''):
1333 from rhodecode.model.permission import PermissionModel
1372 from rhodecode.model.permission import PermissionModel
1334 return PermissionModel().get_default_perms(user_group.users_group_to_perm, suffix)
1373 return PermissionModel().get_default_perms(user_group.users_group_to_perm, suffix)
1335
1374
1336 def get_default_perms(self, suffix=''):
1375 def get_default_perms(self, suffix=''):
1337 return self._get_default_perms(self, suffix)
1376 return self._get_default_perms(self, suffix)
1338
1377
1339 def get_api_data(self, with_group_members=True, include_secrets=False):
1378 def get_api_data(self, with_group_members=True, include_secrets=False):
1340 """
1379 """
1341 :param include_secrets: See :meth:`User.get_api_data`, this parameter is
1380 :param include_secrets: See :meth:`User.get_api_data`, this parameter is
1342 basically forwarded.
1381 basically forwarded.
1343
1382
1344 """
1383 """
1345 user_group = self
1384 user_group = self
1346 data = {
1385 data = {
1347 'users_group_id': user_group.users_group_id,
1386 'users_group_id': user_group.users_group_id,
1348 'group_name': user_group.users_group_name,
1387 'group_name': user_group.users_group_name,
1349 'group_description': user_group.user_group_description,
1388 'group_description': user_group.user_group_description,
1350 'active': user_group.users_group_active,
1389 'active': user_group.users_group_active,
1351 'owner': user_group.user.username,
1390 'owner': user_group.user.username,
1352 'owner_email': user_group.user.email,
1391 'owner_email': user_group.user.email,
1353 }
1392 }
1354
1393
1355 if with_group_members:
1394 if with_group_members:
1356 users = []
1395 users = []
1357 for user in user_group.members:
1396 for user in user_group.members:
1358 user = user.user
1397 user = user.user
1359 users.append(user.get_api_data(include_secrets=include_secrets))
1398 users.append(user.get_api_data(include_secrets=include_secrets))
1360 data['users'] = users
1399 data['users'] = users
1361
1400
1362 return data
1401 return data
1363
1402
1364
1403
1365 class UserGroupMember(Base, BaseModel):
1404 class UserGroupMember(Base, BaseModel):
1366 __tablename__ = 'users_groups_members'
1405 __tablename__ = 'users_groups_members'
1367 __table_args__ = (
1406 __table_args__ = (
1368 {'extend_existing': True, 'mysql_engine': 'InnoDB',
1407 {'extend_existing': True, 'mysql_engine': 'InnoDB',
1369 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
1408 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
1370 )
1409 )
1371
1410
1372 users_group_member_id = Column("users_group_member_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
1411 users_group_member_id = Column("users_group_member_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
1373 users_group_id = Column("users_group_id", Integer(), ForeignKey('users_groups.users_group_id'), nullable=False, unique=None, default=None)
1412 users_group_id = Column("users_group_id", Integer(), ForeignKey('users_groups.users_group_id'), nullable=False, unique=None, default=None)
1374 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=None, default=None)
1413 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=None, default=None)
1375
1414
1376 user = relationship('User', lazy='joined')
1415 user = relationship('User', lazy='joined')
1377 users_group = relationship('UserGroup')
1416 users_group = relationship('UserGroup')
1378
1417
1379 def __init__(self, gr_id='', u_id=''):
1418 def __init__(self, gr_id='', u_id=''):
1380 self.users_group_id = gr_id
1419 self.users_group_id = gr_id
1381 self.user_id = u_id
1420 self.user_id = u_id
1382
1421
1383
1422
1384 class RepositoryField(Base, BaseModel):
1423 class RepositoryField(Base, BaseModel):
1385 __tablename__ = 'repositories_fields'
1424 __tablename__ = 'repositories_fields'
1386 __table_args__ = (
1425 __table_args__ = (
1387 UniqueConstraint('repository_id', 'field_key'), # no-multi field
1426 UniqueConstraint('repository_id', 'field_key'), # no-multi field
1388 {'extend_existing': True, 'mysql_engine': 'InnoDB',
1427 {'extend_existing': True, 'mysql_engine': 'InnoDB',
1389 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
1428 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
1390 )
1429 )
1391 PREFIX = 'ex_' # prefix used in form to not conflict with already existing fields
1430 PREFIX = 'ex_' # prefix used in form to not conflict with already existing fields
1392
1431
1393 repo_field_id = Column("repo_field_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
1432 repo_field_id = Column("repo_field_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
1394 repository_id = Column("repository_id", Integer(), ForeignKey('repositories.repo_id'), nullable=False, unique=None, default=None)
1433 repository_id = Column("repository_id", Integer(), ForeignKey('repositories.repo_id'), nullable=False, unique=None, default=None)
1395 field_key = Column("field_key", String(250))
1434 field_key = Column("field_key", String(250))
1396 field_label = Column("field_label", String(1024), nullable=False)
1435 field_label = Column("field_label", String(1024), nullable=False)
1397 field_value = Column("field_value", String(10000), nullable=False)
1436 field_value = Column("field_value", String(10000), nullable=False)
1398 field_desc = Column("field_desc", String(1024), nullable=False)
1437 field_desc = Column("field_desc", String(1024), nullable=False)
1399 field_type = Column("field_type", String(255), nullable=False, unique=None)
1438 field_type = Column("field_type", String(255), nullable=False, unique=None)
1400 created_on = Column('created_on', DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
1439 created_on = Column('created_on', DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
1401
1440
1402 repository = relationship('Repository')
1441 repository = relationship('Repository')
1403
1442
1404 @property
1443 @property
1405 def field_key_prefixed(self):
1444 def field_key_prefixed(self):
1406 return 'ex_%s' % self.field_key
1445 return 'ex_%s' % self.field_key
1407
1446
1408 @classmethod
1447 @classmethod
1409 def un_prefix_key(cls, key):
1448 def un_prefix_key(cls, key):
1410 if key.startswith(cls.PREFIX):
1449 if key.startswith(cls.PREFIX):
1411 return key[len(cls.PREFIX):]
1450 return key[len(cls.PREFIX):]
1412 return key
1451 return key
1413
1452
1414 @classmethod
1453 @classmethod
1415 def get_by_key_name(cls, key, repo):
1454 def get_by_key_name(cls, key, repo):
1416 row = cls.query()\
1455 row = cls.query()\
1417 .filter(cls.repository == repo)\
1456 .filter(cls.repository == repo)\
1418 .filter(cls.field_key == key).scalar()
1457 .filter(cls.field_key == key).scalar()
1419 return row
1458 return row
1420
1459
1421
1460
1422 class Repository(Base, BaseModel):
1461 class Repository(Base, BaseModel):
1423 __tablename__ = 'repositories'
1462 __tablename__ = 'repositories'
1424 __table_args__ = (
1463 __table_args__ = (
1425 Index('r_repo_name_idx', 'repo_name', mysql_length=255),
1464 Index('r_repo_name_idx', 'repo_name', mysql_length=255),
1426 {'extend_existing': True, 'mysql_engine': 'InnoDB',
1465 {'extend_existing': True, 'mysql_engine': 'InnoDB',
1427 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
1466 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
1428 )
1467 )
1429 DEFAULT_CLONE_URI = '{scheme}://{user}@{netloc}/{repo}'
1468 DEFAULT_CLONE_URI = '{scheme}://{user}@{netloc}/{repo}'
1430 DEFAULT_CLONE_URI_ID = '{scheme}://{user}@{netloc}/_{repoid}'
1469 DEFAULT_CLONE_URI_ID = '{scheme}://{user}@{netloc}/_{repoid}'
1431
1470
1432 STATE_CREATED = 'repo_state_created'
1471 STATE_CREATED = 'repo_state_created'
1433 STATE_PENDING = 'repo_state_pending'
1472 STATE_PENDING = 'repo_state_pending'
1434 STATE_ERROR = 'repo_state_error'
1473 STATE_ERROR = 'repo_state_error'
1435
1474
1436 LOCK_AUTOMATIC = 'lock_auto'
1475 LOCK_AUTOMATIC = 'lock_auto'
1437 LOCK_API = 'lock_api'
1476 LOCK_API = 'lock_api'
1438 LOCK_WEB = 'lock_web'
1477 LOCK_WEB = 'lock_web'
1439 LOCK_PULL = 'lock_pull'
1478 LOCK_PULL = 'lock_pull'
1440
1479
1441 NAME_SEP = URL_SEP
1480 NAME_SEP = URL_SEP
1442
1481
1443 repo_id = Column(
1482 repo_id = Column(
1444 "repo_id", Integer(), nullable=False, unique=True, default=None,
1483 "repo_id", Integer(), nullable=False, unique=True, default=None,
1445 primary_key=True)
1484 primary_key=True)
1446 _repo_name = Column(
1485 _repo_name = Column(
1447 "repo_name", Text(), nullable=False, default=None)
1486 "repo_name", Text(), nullable=False, default=None)
1448 _repo_name_hash = Column(
1487 _repo_name_hash = Column(
1449 "repo_name_hash", String(255), nullable=False, unique=True)
1488 "repo_name_hash", String(255), nullable=False, unique=True)
1450 repo_state = Column("repo_state", String(255), nullable=True)
1489 repo_state = Column("repo_state", String(255), nullable=True)
1451
1490
1452 clone_uri = Column(
1491 clone_uri = Column(
1453 "clone_uri", EncryptedTextValue(), nullable=True, unique=False,
1492 "clone_uri", EncryptedTextValue(), nullable=True, unique=False,
1454 default=None)
1493 default=None)
1455 repo_type = Column(
1494 repo_type = Column(
1456 "repo_type", String(255), nullable=False, unique=False, default=None)
1495 "repo_type", String(255), nullable=False, unique=False, default=None)
1457 user_id = Column(
1496 user_id = Column(
1458 "user_id", Integer(), ForeignKey('users.user_id'), nullable=False,
1497 "user_id", Integer(), ForeignKey('users.user_id'), nullable=False,
1459 unique=False, default=None)
1498 unique=False, default=None)
1460 private = Column(
1499 private = Column(
1461 "private", Boolean(), nullable=True, unique=None, default=None)
1500 "private", Boolean(), nullable=True, unique=None, default=None)
1462 enable_statistics = Column(
1501 enable_statistics = Column(
1463 "statistics", Boolean(), nullable=True, unique=None, default=True)
1502 "statistics", Boolean(), nullable=True, unique=None, default=True)
1464 enable_downloads = Column(
1503 enable_downloads = Column(
1465 "downloads", Boolean(), nullable=True, unique=None, default=True)
1504 "downloads", Boolean(), nullable=True, unique=None, default=True)
1466 description = Column(
1505 description = Column(
1467 "description", String(10000), nullable=True, unique=None, default=None)
1506 "description", String(10000), nullable=True, unique=None, default=None)
1468 created_on = Column(
1507 created_on = Column(
1469 'created_on', DateTime(timezone=False), nullable=True, unique=None,
1508 'created_on', DateTime(timezone=False), nullable=True, unique=None,
1470 default=datetime.datetime.now)
1509 default=datetime.datetime.now)
1471 updated_on = Column(
1510 updated_on = Column(
1472 'updated_on', DateTime(timezone=False), nullable=True, unique=None,
1511 'updated_on', DateTime(timezone=False), nullable=True, unique=None,
1473 default=datetime.datetime.now)
1512 default=datetime.datetime.now)
1474 _landing_revision = Column(
1513 _landing_revision = Column(
1475 "landing_revision", String(255), nullable=False, unique=False,
1514 "landing_revision", String(255), nullable=False, unique=False,
1476 default=None)
1515 default=None)
1477 enable_locking = Column(
1516 enable_locking = Column(
1478 "enable_locking", Boolean(), nullable=False, unique=None,
1517 "enable_locking", Boolean(), nullable=False, unique=None,
1479 default=False)
1518 default=False)
1480 _locked = Column(
1519 _locked = Column(
1481 "locked", String(255), nullable=True, unique=False, default=None)
1520 "locked", String(255), nullable=True, unique=False, default=None)
1482 _changeset_cache = Column(
1521 _changeset_cache = Column(
1483 "changeset_cache", LargeBinary(), nullable=True) # JSON data
1522 "changeset_cache", LargeBinary(), nullable=True) # JSON data
1484
1523
1485 fork_id = Column(
1524 fork_id = Column(
1486 "fork_id", Integer(), ForeignKey('repositories.repo_id'),
1525 "fork_id", Integer(), ForeignKey('repositories.repo_id'),
1487 nullable=True, unique=False, default=None)
1526 nullable=True, unique=False, default=None)
1488 group_id = Column(
1527 group_id = Column(
1489 "group_id", Integer(), ForeignKey('groups.group_id'), nullable=True,
1528 "group_id", Integer(), ForeignKey('groups.group_id'), nullable=True,
1490 unique=False, default=None)
1529 unique=False, default=None)
1491
1530
1492 user = relationship('User', lazy='joined')
1531 user = relationship('User', lazy='joined')
1493 fork = relationship('Repository', remote_side=repo_id, lazy='joined')
1532 fork = relationship('Repository', remote_side=repo_id, lazy='joined')
1494 group = relationship('RepoGroup', lazy='joined')
1533 group = relationship('RepoGroup', lazy='joined')
1495 repo_to_perm = relationship(
1534 repo_to_perm = relationship(
1496 'UserRepoToPerm', cascade='all',
1535 'UserRepoToPerm', cascade='all',
1497 order_by='UserRepoToPerm.repo_to_perm_id')
1536 order_by='UserRepoToPerm.repo_to_perm_id')
1498 users_group_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1537 users_group_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1499 stats = relationship('Statistics', cascade='all', uselist=False)
1538 stats = relationship('Statistics', cascade='all', uselist=False)
1500
1539
1501 followers = relationship(
1540 followers = relationship(
1502 'UserFollowing',
1541 'UserFollowing',
1503 primaryjoin='UserFollowing.follows_repo_id==Repository.repo_id',
1542 primaryjoin='UserFollowing.follows_repo_id==Repository.repo_id',
1504 cascade='all')
1543 cascade='all')
1505 extra_fields = relationship(
1544 extra_fields = relationship(
1506 'RepositoryField', cascade="all, delete, delete-orphan")
1545 'RepositoryField', cascade="all, delete, delete-orphan")
1507 logs = relationship('UserLog')
1546 logs = relationship('UserLog')
1508 comments = relationship(
1547 comments = relationship(
1509 'ChangesetComment', cascade="all, delete, delete-orphan")
1548 'ChangesetComment', cascade="all, delete, delete-orphan")
1510 pull_requests_source = relationship(
1549 pull_requests_source = relationship(
1511 'PullRequest',
1550 'PullRequest',
1512 primaryjoin='PullRequest.source_repo_id==Repository.repo_id',
1551 primaryjoin='PullRequest.source_repo_id==Repository.repo_id',
1513 cascade="all, delete, delete-orphan")
1552 cascade="all, delete, delete-orphan")
1514 pull_requests_target = relationship(
1553 pull_requests_target = relationship(
1515 'PullRequest',
1554 'PullRequest',
1516 primaryjoin='PullRequest.target_repo_id==Repository.repo_id',
1555 primaryjoin='PullRequest.target_repo_id==Repository.repo_id',
1517 cascade="all, delete, delete-orphan")
1556 cascade="all, delete, delete-orphan")
1518 ui = relationship('RepoRhodeCodeUi', cascade="all")
1557 ui = relationship('RepoRhodeCodeUi', cascade="all")
1519 settings = relationship('RepoRhodeCodeSetting', cascade="all")
1558 settings = relationship('RepoRhodeCodeSetting', cascade="all")
1520 integrations = relationship('Integration',
1559 integrations = relationship('Integration',
1521 cascade="all, delete, delete-orphan")
1560 cascade="all, delete, delete-orphan")
1522
1561
1523 def __unicode__(self):
1562 def __unicode__(self):
1524 return u"<%s('%s:%s')>" % (self.__class__.__name__, self.repo_id,
1563 return u"<%s('%s:%s')>" % (self.__class__.__name__, self.repo_id,
1525 safe_unicode(self.repo_name))
1564 safe_unicode(self.repo_name))
1526
1565
1527 @hybrid_property
1566 @hybrid_property
1528 def description_safe(self):
1567 def description_safe(self):
1529 from rhodecode.lib import helpers as h
1568 from rhodecode.lib import helpers as h
1530 return h.escape(self.description)
1569 return h.escape(self.description)
1531
1570
1532 @hybrid_property
1571 @hybrid_property
1533 def landing_rev(self):
1572 def landing_rev(self):
1534 # always should return [rev_type, rev]
1573 # always should return [rev_type, rev]
1535 if self._landing_revision:
1574 if self._landing_revision:
1536 _rev_info = self._landing_revision.split(':')
1575 _rev_info = self._landing_revision.split(':')
1537 if len(_rev_info) < 2:
1576 if len(_rev_info) < 2:
1538 _rev_info.insert(0, 'rev')
1577 _rev_info.insert(0, 'rev')
1539 return [_rev_info[0], _rev_info[1]]
1578 return [_rev_info[0], _rev_info[1]]
1540 return [None, None]
1579 return [None, None]
1541
1580
1542 @landing_rev.setter
1581 @landing_rev.setter
1543 def landing_rev(self, val):
1582 def landing_rev(self, val):
1544 if ':' not in val:
1583 if ':' not in val:
1545 raise ValueError('value must be delimited with `:` and consist '
1584 raise ValueError('value must be delimited with `:` and consist '
1546 'of <rev_type>:<rev>, got %s instead' % val)
1585 'of <rev_type>:<rev>, got %s instead' % val)
1547 self._landing_revision = val
1586 self._landing_revision = val
1548
1587
1549 @hybrid_property
1588 @hybrid_property
1550 def locked(self):
1589 def locked(self):
1551 if self._locked:
1590 if self._locked:
1552 user_id, timelocked, reason = self._locked.split(':')
1591 user_id, timelocked, reason = self._locked.split(':')
1553 lock_values = int(user_id), timelocked, reason
1592 lock_values = int(user_id), timelocked, reason
1554 else:
1593 else:
1555 lock_values = [None, None, None]
1594 lock_values = [None, None, None]
1556 return lock_values
1595 return lock_values
1557
1596
1558 @locked.setter
1597 @locked.setter
1559 def locked(self, val):
1598 def locked(self, val):
1560 if val and isinstance(val, (list, tuple)):
1599 if val and isinstance(val, (list, tuple)):
1561 self._locked = ':'.join(map(str, val))
1600 self._locked = ':'.join(map(str, val))
1562 else:
1601 else:
1563 self._locked = None
1602 self._locked = None
1564
1603
1565 @hybrid_property
1604 @hybrid_property
1566 def changeset_cache(self):
1605 def changeset_cache(self):
1567 from rhodecode.lib.vcs.backends.base import EmptyCommit
1606 from rhodecode.lib.vcs.backends.base import EmptyCommit
1568 dummy = EmptyCommit().__json__()
1607 dummy = EmptyCommit().__json__()
1569 if not self._changeset_cache:
1608 if not self._changeset_cache:
1570 return dummy
1609 return dummy
1571 try:
1610 try:
1572 return json.loads(self._changeset_cache)
1611 return json.loads(self._changeset_cache)
1573 except TypeError:
1612 except TypeError:
1574 return dummy
1613 return dummy
1575 except Exception:
1614 except Exception:
1576 log.error(traceback.format_exc())
1615 log.error(traceback.format_exc())
1577 return dummy
1616 return dummy
1578
1617
1579 @changeset_cache.setter
1618 @changeset_cache.setter
1580 def changeset_cache(self, val):
1619 def changeset_cache(self, val):
1581 try:
1620 try:
1582 self._changeset_cache = json.dumps(val)
1621 self._changeset_cache = json.dumps(val)
1583 except Exception:
1622 except Exception:
1584 log.error(traceback.format_exc())
1623 log.error(traceback.format_exc())
1585
1624
1586 @hybrid_property
1625 @hybrid_property
1587 def repo_name(self):
1626 def repo_name(self):
1588 return self._repo_name
1627 return self._repo_name
1589
1628
1590 @repo_name.setter
1629 @repo_name.setter
1591 def repo_name(self, value):
1630 def repo_name(self, value):
1592 self._repo_name = value
1631 self._repo_name = value
1593 self._repo_name_hash = hashlib.sha1(safe_str(value)).hexdigest()
1632 self._repo_name_hash = hashlib.sha1(safe_str(value)).hexdigest()
1594
1633
1595 @classmethod
1634 @classmethod
1596 def normalize_repo_name(cls, repo_name):
1635 def normalize_repo_name(cls, repo_name):
1597 """
1636 """
1598 Normalizes os specific repo_name to the format internally stored inside
1637 Normalizes os specific repo_name to the format internally stored inside
1599 database using URL_SEP
1638 database using URL_SEP
1600
1639
1601 :param cls:
1640 :param cls:
1602 :param repo_name:
1641 :param repo_name:
1603 """
1642 """
1604 return cls.NAME_SEP.join(repo_name.split(os.sep))
1643 return cls.NAME_SEP.join(repo_name.split(os.sep))
1605
1644
1606 @classmethod
1645 @classmethod
1607 def get_by_repo_name(cls, repo_name, cache=False, identity_cache=False):
1646 def get_by_repo_name(cls, repo_name, cache=False, identity_cache=False):
1608 session = Session()
1647 session = Session()
1609 q = session.query(cls).filter(cls.repo_name == repo_name)
1648 q = session.query(cls).filter(cls.repo_name == repo_name)
1610
1649
1611 if cache:
1650 if cache:
1612 if identity_cache:
1651 if identity_cache:
1613 val = cls.identity_cache(session, 'repo_name', repo_name)
1652 val = cls.identity_cache(session, 'repo_name', repo_name)
1614 if val:
1653 if val:
1615 return val
1654 return val
1616 else:
1655 else:
1617 cache_key = "get_repo_by_name_%s" % _hash_key(repo_name)
1656 cache_key = "get_repo_by_name_%s" % _hash_key(repo_name)
1618 q = q.options(
1657 q = q.options(
1619 FromCache("sql_cache_short", cache_key))
1658 FromCache("sql_cache_short", cache_key))
1620
1659
1621 return q.scalar()
1660 return q.scalar()
1622
1661
1623 @classmethod
1662 @classmethod
1624 def get_by_full_path(cls, repo_full_path):
1663 def get_by_full_path(cls, repo_full_path):
1625 repo_name = repo_full_path.split(cls.base_path(), 1)[-1]
1664 repo_name = repo_full_path.split(cls.base_path(), 1)[-1]
1626 repo_name = cls.normalize_repo_name(repo_name)
1665 repo_name = cls.normalize_repo_name(repo_name)
1627 return cls.get_by_repo_name(repo_name.strip(URL_SEP))
1666 return cls.get_by_repo_name(repo_name.strip(URL_SEP))
1628
1667
1629 @classmethod
1668 @classmethod
1630 def get_repo_forks(cls, repo_id):
1669 def get_repo_forks(cls, repo_id):
1631 return cls.query().filter(Repository.fork_id == repo_id)
1670 return cls.query().filter(Repository.fork_id == repo_id)
1632
1671
1633 @classmethod
1672 @classmethod
1634 def base_path(cls):
1673 def base_path(cls):
1635 """
1674 """
1636 Returns base path when all repos are stored
1675 Returns base path when all repos are stored
1637
1676
1638 :param cls:
1677 :param cls:
1639 """
1678 """
1640 q = Session().query(RhodeCodeUi)\
1679 q = Session().query(RhodeCodeUi)\
1641 .filter(RhodeCodeUi.ui_key == cls.NAME_SEP)
1680 .filter(RhodeCodeUi.ui_key == cls.NAME_SEP)
1642 q = q.options(FromCache("sql_cache_short", "repository_repo_path"))
1681 q = q.options(FromCache("sql_cache_short", "repository_repo_path"))
1643 return q.one().ui_value
1682 return q.one().ui_value
1644
1683
1645 @classmethod
1684 @classmethod
1646 def is_valid(cls, repo_name):
1685 def is_valid(cls, repo_name):
1647 """
1686 """
1648 returns True if given repo name is a valid filesystem repository
1687 returns True if given repo name is a valid filesystem repository
1649
1688
1650 :param cls:
1689 :param cls:
1651 :param repo_name:
1690 :param repo_name:
1652 """
1691 """
1653 from rhodecode.lib.utils import is_valid_repo
1692 from rhodecode.lib.utils import is_valid_repo
1654
1693
1655 return is_valid_repo(repo_name, cls.base_path())
1694 return is_valid_repo(repo_name, cls.base_path())
1656
1695
1657 @classmethod
1696 @classmethod
1658 def get_all_repos(cls, user_id=Optional(None), group_id=Optional(None),
1697 def get_all_repos(cls, user_id=Optional(None), group_id=Optional(None),
1659 case_insensitive=True):
1698 case_insensitive=True):
1660 q = Repository.query()
1699 q = Repository.query()
1661
1700
1662 if not isinstance(user_id, Optional):
1701 if not isinstance(user_id, Optional):
1663 q = q.filter(Repository.user_id == user_id)
1702 q = q.filter(Repository.user_id == user_id)
1664
1703
1665 if not isinstance(group_id, Optional):
1704 if not isinstance(group_id, Optional):
1666 q = q.filter(Repository.group_id == group_id)
1705 q = q.filter(Repository.group_id == group_id)
1667
1706
1668 if case_insensitive:
1707 if case_insensitive:
1669 q = q.order_by(func.lower(Repository.repo_name))
1708 q = q.order_by(func.lower(Repository.repo_name))
1670 else:
1709 else:
1671 q = q.order_by(Repository.repo_name)
1710 q = q.order_by(Repository.repo_name)
1672 return q.all()
1711 return q.all()
1673
1712
1674 @property
1713 @property
1675 def forks(self):
1714 def forks(self):
1676 """
1715 """
1677 Return forks of this repo
1716 Return forks of this repo
1678 """
1717 """
1679 return Repository.get_repo_forks(self.repo_id)
1718 return Repository.get_repo_forks(self.repo_id)
1680
1719
1681 @property
1720 @property
1682 def parent(self):
1721 def parent(self):
1683 """
1722 """
1684 Returns fork parent
1723 Returns fork parent
1685 """
1724 """
1686 return self.fork
1725 return self.fork
1687
1726
1688 @property
1727 @property
1689 def just_name(self):
1728 def just_name(self):
1690 return self.repo_name.split(self.NAME_SEP)[-1]
1729 return self.repo_name.split(self.NAME_SEP)[-1]
1691
1730
1692 @property
1731 @property
1693 def groups_with_parents(self):
1732 def groups_with_parents(self):
1694 groups = []
1733 groups = []
1695 if self.group is None:
1734 if self.group is None:
1696 return groups
1735 return groups
1697
1736
1698 cur_gr = self.group
1737 cur_gr = self.group
1699 groups.insert(0, cur_gr)
1738 groups.insert(0, cur_gr)
1700 while 1:
1739 while 1:
1701 gr = getattr(cur_gr, 'parent_group', None)
1740 gr = getattr(cur_gr, 'parent_group', None)
1702 cur_gr = cur_gr.parent_group
1741 cur_gr = cur_gr.parent_group
1703 if gr is None:
1742 if gr is None:
1704 break
1743 break
1705 groups.insert(0, gr)
1744 groups.insert(0, gr)
1706
1745
1707 return groups
1746 return groups
1708
1747
1709 @property
1748 @property
1710 def groups_and_repo(self):
1749 def groups_and_repo(self):
1711 return self.groups_with_parents, self
1750 return self.groups_with_parents, self
1712
1751
1713 @LazyProperty
1752 @LazyProperty
1714 def repo_path(self):
1753 def repo_path(self):
1715 """
1754 """
1716 Returns base full path for that repository means where it actually
1755 Returns base full path for that repository means where it actually
1717 exists on a filesystem
1756 exists on a filesystem
1718 """
1757 """
1719 q = Session().query(RhodeCodeUi).filter(
1758 q = Session().query(RhodeCodeUi).filter(
1720 RhodeCodeUi.ui_key == self.NAME_SEP)
1759 RhodeCodeUi.ui_key == self.NAME_SEP)
1721 q = q.options(FromCache("sql_cache_short", "repository_repo_path"))
1760 q = q.options(FromCache("sql_cache_short", "repository_repo_path"))
1722 return q.one().ui_value
1761 return q.one().ui_value
1723
1762
1724 @property
1763 @property
1725 def repo_full_path(self):
1764 def repo_full_path(self):
1726 p = [self.repo_path]
1765 p = [self.repo_path]
1727 # we need to split the name by / since this is how we store the
1766 # we need to split the name by / since this is how we store the
1728 # names in the database, but that eventually needs to be converted
1767 # names in the database, but that eventually needs to be converted
1729 # into a valid system path
1768 # into a valid system path
1730 p += self.repo_name.split(self.NAME_SEP)
1769 p += self.repo_name.split(self.NAME_SEP)
1731 return os.path.join(*map(safe_unicode, p))
1770 return os.path.join(*map(safe_unicode, p))
1732
1771
1733 @property
1772 @property
1734 def cache_keys(self):
1773 def cache_keys(self):
1735 """
1774 """
1736 Returns associated cache keys for that repo
1775 Returns associated cache keys for that repo
1737 """
1776 """
1738 return CacheKey.query()\
1777 return CacheKey.query()\
1739 .filter(CacheKey.cache_args == self.repo_name)\
1778 .filter(CacheKey.cache_args == self.repo_name)\
1740 .order_by(CacheKey.cache_key)\
1779 .order_by(CacheKey.cache_key)\
1741 .all()
1780 .all()
1742
1781
1743 def get_new_name(self, repo_name):
1782 def get_new_name(self, repo_name):
1744 """
1783 """
1745 returns new full repository name based on assigned group and new new
1784 returns new full repository name based on assigned group and new new
1746
1785
1747 :param group_name:
1786 :param group_name:
1748 """
1787 """
1749 path_prefix = self.group.full_path_splitted if self.group else []
1788 path_prefix = self.group.full_path_splitted if self.group else []
1750 return self.NAME_SEP.join(path_prefix + [repo_name])
1789 return self.NAME_SEP.join(path_prefix + [repo_name])
1751
1790
1752 @property
1791 @property
1753 def _config(self):
1792 def _config(self):
1754 """
1793 """
1755 Returns db based config object.
1794 Returns db based config object.
1756 """
1795 """
1757 from rhodecode.lib.utils import make_db_config
1796 from rhodecode.lib.utils import make_db_config
1758 return make_db_config(clear_session=False, repo=self)
1797 return make_db_config(clear_session=False, repo=self)
1759
1798
1760 def permissions(self, with_admins=True, with_owner=True):
1799 def permissions(self, with_admins=True, with_owner=True):
1761 q = UserRepoToPerm.query().filter(UserRepoToPerm.repository == self)
1800 q = UserRepoToPerm.query().filter(UserRepoToPerm.repository == self)
1762 q = q.options(joinedload(UserRepoToPerm.repository),
1801 q = q.options(joinedload(UserRepoToPerm.repository),
1763 joinedload(UserRepoToPerm.user),
1802 joinedload(UserRepoToPerm.user),
1764 joinedload(UserRepoToPerm.permission),)
1803 joinedload(UserRepoToPerm.permission),)
1765
1804
1766 # get owners and admins and permissions. We do a trick of re-writing
1805 # get owners and admins and permissions. We do a trick of re-writing
1767 # objects from sqlalchemy to named-tuples due to sqlalchemy session
1806 # objects from sqlalchemy to named-tuples due to sqlalchemy session
1768 # has a global reference and changing one object propagates to all
1807 # has a global reference and changing one object propagates to all
1769 # others. This means if admin is also an owner admin_row that change
1808 # others. This means if admin is also an owner admin_row that change
1770 # would propagate to both objects
1809 # would propagate to both objects
1771 perm_rows = []
1810 perm_rows = []
1772 for _usr in q.all():
1811 for _usr in q.all():
1773 usr = AttributeDict(_usr.user.get_dict())
1812 usr = AttributeDict(_usr.user.get_dict())
1774 usr.permission = _usr.permission.permission_name
1813 usr.permission = _usr.permission.permission_name
1775 perm_rows.append(usr)
1814 perm_rows.append(usr)
1776
1815
1777 # filter the perm rows by 'default' first and then sort them by
1816 # filter the perm rows by 'default' first and then sort them by
1778 # admin,write,read,none permissions sorted again alphabetically in
1817 # admin,write,read,none permissions sorted again alphabetically in
1779 # each group
1818 # each group
1780 perm_rows = sorted(perm_rows, key=display_sort)
1819 perm_rows = sorted(perm_rows, key=display_sort)
1781
1820
1782 _admin_perm = 'repository.admin'
1821 _admin_perm = 'repository.admin'
1783 owner_row = []
1822 owner_row = []
1784 if with_owner:
1823 if with_owner:
1785 usr = AttributeDict(self.user.get_dict())
1824 usr = AttributeDict(self.user.get_dict())
1786 usr.owner_row = True
1825 usr.owner_row = True
1787 usr.permission = _admin_perm
1826 usr.permission = _admin_perm
1788 owner_row.append(usr)
1827 owner_row.append(usr)
1789
1828
1790 super_admin_rows = []
1829 super_admin_rows = []
1791 if with_admins:
1830 if with_admins:
1792 for usr in User.get_all_super_admins():
1831 for usr in User.get_all_super_admins():
1793 # if this admin is also owner, don't double the record
1832 # if this admin is also owner, don't double the record
1794 if usr.user_id == owner_row[0].user_id:
1833 if usr.user_id == owner_row[0].user_id:
1795 owner_row[0].admin_row = True
1834 owner_row[0].admin_row = True
1796 else:
1835 else:
1797 usr = AttributeDict(usr.get_dict())
1836 usr = AttributeDict(usr.get_dict())
1798 usr.admin_row = True
1837 usr.admin_row = True
1799 usr.permission = _admin_perm
1838 usr.permission = _admin_perm
1800 super_admin_rows.append(usr)
1839 super_admin_rows.append(usr)
1801
1840
1802 return super_admin_rows + owner_row + perm_rows
1841 return super_admin_rows + owner_row + perm_rows
1803
1842
1804 def permission_user_groups(self):
1843 def permission_user_groups(self):
1805 q = UserGroupRepoToPerm.query().filter(
1844 q = UserGroupRepoToPerm.query().filter(
1806 UserGroupRepoToPerm.repository == self)
1845 UserGroupRepoToPerm.repository == self)
1807 q = q.options(joinedload(UserGroupRepoToPerm.repository),
1846 q = q.options(joinedload(UserGroupRepoToPerm.repository),
1808 joinedload(UserGroupRepoToPerm.users_group),
1847 joinedload(UserGroupRepoToPerm.users_group),
1809 joinedload(UserGroupRepoToPerm.permission),)
1848 joinedload(UserGroupRepoToPerm.permission),)
1810
1849
1811 perm_rows = []
1850 perm_rows = []
1812 for _user_group in q.all():
1851 for _user_group in q.all():
1813 usr = AttributeDict(_user_group.users_group.get_dict())
1852 usr = AttributeDict(_user_group.users_group.get_dict())
1814 usr.permission = _user_group.permission.permission_name
1853 usr.permission = _user_group.permission.permission_name
1815 perm_rows.append(usr)
1854 perm_rows.append(usr)
1816
1855
1817 return perm_rows
1856 return perm_rows
1818
1857
1819 def get_api_data(self, include_secrets=False):
1858 def get_api_data(self, include_secrets=False):
1820 """
1859 """
1821 Common function for generating repo api data
1860 Common function for generating repo api data
1822
1861
1823 :param include_secrets: See :meth:`User.get_api_data`.
1862 :param include_secrets: See :meth:`User.get_api_data`.
1824
1863
1825 """
1864 """
1826 # TODO: mikhail: Here there is an anti-pattern, we probably need to
1865 # TODO: mikhail: Here there is an anti-pattern, we probably need to
1827 # move this methods on models level.
1866 # move this methods on models level.
1828 from rhodecode.model.settings import SettingsModel
1867 from rhodecode.model.settings import SettingsModel
1829 from rhodecode.model.repo import RepoModel
1868 from rhodecode.model.repo import RepoModel
1830
1869
1831 repo = self
1870 repo = self
1832 _user_id, _time, _reason = self.locked
1871 _user_id, _time, _reason = self.locked
1833
1872
1834 data = {
1873 data = {
1835 'repo_id': repo.repo_id,
1874 'repo_id': repo.repo_id,
1836 'repo_name': repo.repo_name,
1875 'repo_name': repo.repo_name,
1837 'repo_type': repo.repo_type,
1876 'repo_type': repo.repo_type,
1838 'clone_uri': repo.clone_uri or '',
1877 'clone_uri': repo.clone_uri or '',
1839 'url': RepoModel().get_url(self),
1878 'url': RepoModel().get_url(self),
1840 'private': repo.private,
1879 'private': repo.private,
1841 'created_on': repo.created_on,
1880 'created_on': repo.created_on,
1842 'description': repo.description_safe,
1881 'description': repo.description_safe,
1843 'landing_rev': repo.landing_rev,
1882 'landing_rev': repo.landing_rev,
1844 'owner': repo.user.username,
1883 'owner': repo.user.username,
1845 'fork_of': repo.fork.repo_name if repo.fork else None,
1884 'fork_of': repo.fork.repo_name if repo.fork else None,
1846 'fork_of_id': repo.fork.repo_id if repo.fork else None,
1885 'fork_of_id': repo.fork.repo_id if repo.fork else None,
1847 'enable_statistics': repo.enable_statistics,
1886 'enable_statistics': repo.enable_statistics,
1848 'enable_locking': repo.enable_locking,
1887 'enable_locking': repo.enable_locking,
1849 'enable_downloads': repo.enable_downloads,
1888 'enable_downloads': repo.enable_downloads,
1850 'last_changeset': repo.changeset_cache,
1889 'last_changeset': repo.changeset_cache,
1851 'locked_by': User.get(_user_id).get_api_data(
1890 'locked_by': User.get(_user_id).get_api_data(
1852 include_secrets=include_secrets) if _user_id else None,
1891 include_secrets=include_secrets) if _user_id else None,
1853 'locked_date': time_to_datetime(_time) if _time else None,
1892 'locked_date': time_to_datetime(_time) if _time else None,
1854 'lock_reason': _reason if _reason else None,
1893 'lock_reason': _reason if _reason else None,
1855 }
1894 }
1856
1895
1857 # TODO: mikhail: should be per-repo settings here
1896 # TODO: mikhail: should be per-repo settings here
1858 rc_config = SettingsModel().get_all_settings()
1897 rc_config = SettingsModel().get_all_settings()
1859 repository_fields = str2bool(
1898 repository_fields = str2bool(
1860 rc_config.get('rhodecode_repository_fields'))
1899 rc_config.get('rhodecode_repository_fields'))
1861 if repository_fields:
1900 if repository_fields:
1862 for f in self.extra_fields:
1901 for f in self.extra_fields:
1863 data[f.field_key_prefixed] = f.field_value
1902 data[f.field_key_prefixed] = f.field_value
1864
1903
1865 return data
1904 return data
1866
1905
1867 @classmethod
1906 @classmethod
1868 def lock(cls, repo, user_id, lock_time=None, lock_reason=None):
1907 def lock(cls, repo, user_id, lock_time=None, lock_reason=None):
1869 if not lock_time:
1908 if not lock_time:
1870 lock_time = time.time()
1909 lock_time = time.time()
1871 if not lock_reason:
1910 if not lock_reason:
1872 lock_reason = cls.LOCK_AUTOMATIC
1911 lock_reason = cls.LOCK_AUTOMATIC
1873 repo.locked = [user_id, lock_time, lock_reason]
1912 repo.locked = [user_id, lock_time, lock_reason]
1874 Session().add(repo)
1913 Session().add(repo)
1875 Session().commit()
1914 Session().commit()
1876
1915
1877 @classmethod
1916 @classmethod
1878 def unlock(cls, repo):
1917 def unlock(cls, repo):
1879 repo.locked = None
1918 repo.locked = None
1880 Session().add(repo)
1919 Session().add(repo)
1881 Session().commit()
1920 Session().commit()
1882
1921
1883 @classmethod
1922 @classmethod
1884 def getlock(cls, repo):
1923 def getlock(cls, repo):
1885 return repo.locked
1924 return repo.locked
1886
1925
1887 def is_user_lock(self, user_id):
1926 def is_user_lock(self, user_id):
1888 if self.lock[0]:
1927 if self.lock[0]:
1889 lock_user_id = safe_int(self.lock[0])
1928 lock_user_id = safe_int(self.lock[0])
1890 user_id = safe_int(user_id)
1929 user_id = safe_int(user_id)
1891 # both are ints, and they are equal
1930 # both are ints, and they are equal
1892 return all([lock_user_id, user_id]) and lock_user_id == user_id
1931 return all([lock_user_id, user_id]) and lock_user_id == user_id
1893
1932
1894 return False
1933 return False
1895
1934
1896 def get_locking_state(self, action, user_id, only_when_enabled=True):
1935 def get_locking_state(self, action, user_id, only_when_enabled=True):
1897 """
1936 """
1898 Checks locking on this repository, if locking is enabled and lock is
1937 Checks locking on this repository, if locking is enabled and lock is
1899 present returns a tuple of make_lock, locked, locked_by.
1938 present returns a tuple of make_lock, locked, locked_by.
1900 make_lock can have 3 states None (do nothing) True, make lock
1939 make_lock can have 3 states None (do nothing) True, make lock
1901 False release lock, This value is later propagated to hooks, which
1940 False release lock, This value is later propagated to hooks, which
1902 do the locking. Think about this as signals passed to hooks what to do.
1941 do the locking. Think about this as signals passed to hooks what to do.
1903
1942
1904 """
1943 """
1905 # TODO: johbo: This is part of the business logic and should be moved
1944 # TODO: johbo: This is part of the business logic and should be moved
1906 # into the RepositoryModel.
1945 # into the RepositoryModel.
1907
1946
1908 if action not in ('push', 'pull'):
1947 if action not in ('push', 'pull'):
1909 raise ValueError("Invalid action value: %s" % repr(action))
1948 raise ValueError("Invalid action value: %s" % repr(action))
1910
1949
1911 # defines if locked error should be thrown to user
1950 # defines if locked error should be thrown to user
1912 currently_locked = False
1951 currently_locked = False
1913 # defines if new lock should be made, tri-state
1952 # defines if new lock should be made, tri-state
1914 make_lock = None
1953 make_lock = None
1915 repo = self
1954 repo = self
1916 user = User.get(user_id)
1955 user = User.get(user_id)
1917
1956
1918 lock_info = repo.locked
1957 lock_info = repo.locked
1919
1958
1920 if repo and (repo.enable_locking or not only_when_enabled):
1959 if repo and (repo.enable_locking or not only_when_enabled):
1921 if action == 'push':
1960 if action == 'push':
1922 # check if it's already locked !, if it is compare users
1961 # check if it's already locked !, if it is compare users
1923 locked_by_user_id = lock_info[0]
1962 locked_by_user_id = lock_info[0]
1924 if user.user_id == locked_by_user_id:
1963 if user.user_id == locked_by_user_id:
1925 log.debug(
1964 log.debug(
1926 'Got `push` action from user %s, now unlocking', user)
1965 'Got `push` action from user %s, now unlocking', user)
1927 # unlock if we have push from user who locked
1966 # unlock if we have push from user who locked
1928 make_lock = False
1967 make_lock = False
1929 else:
1968 else:
1930 # we're not the same user who locked, ban with
1969 # we're not the same user who locked, ban with
1931 # code defined in settings (default is 423 HTTP Locked) !
1970 # code defined in settings (default is 423 HTTP Locked) !
1932 log.debug('Repo %s is currently locked by %s', repo, user)
1971 log.debug('Repo %s is currently locked by %s', repo, user)
1933 currently_locked = True
1972 currently_locked = True
1934 elif action == 'pull':
1973 elif action == 'pull':
1935 # [0] user [1] date
1974 # [0] user [1] date
1936 if lock_info[0] and lock_info[1]:
1975 if lock_info[0] and lock_info[1]:
1937 log.debug('Repo %s is currently locked by %s', repo, user)
1976 log.debug('Repo %s is currently locked by %s', repo, user)
1938 currently_locked = True
1977 currently_locked = True
1939 else:
1978 else:
1940 log.debug('Setting lock on repo %s by %s', repo, user)
1979 log.debug('Setting lock on repo %s by %s', repo, user)
1941 make_lock = True
1980 make_lock = True
1942
1981
1943 else:
1982 else:
1944 log.debug('Repository %s do not have locking enabled', repo)
1983 log.debug('Repository %s do not have locking enabled', repo)
1945
1984
1946 log.debug('FINAL locking values make_lock:%s,locked:%s,locked_by:%s',
1985 log.debug('FINAL locking values make_lock:%s,locked:%s,locked_by:%s',
1947 make_lock, currently_locked, lock_info)
1986 make_lock, currently_locked, lock_info)
1948
1987
1949 from rhodecode.lib.auth import HasRepoPermissionAny
1988 from rhodecode.lib.auth import HasRepoPermissionAny
1950 perm_check = HasRepoPermissionAny('repository.write', 'repository.admin')
1989 perm_check = HasRepoPermissionAny('repository.write', 'repository.admin')
1951 if make_lock and not perm_check(repo_name=repo.repo_name, user=user):
1990 if make_lock and not perm_check(repo_name=repo.repo_name, user=user):
1952 # if we don't have at least write permission we cannot make a lock
1991 # if we don't have at least write permission we cannot make a lock
1953 log.debug('lock state reset back to FALSE due to lack '
1992 log.debug('lock state reset back to FALSE due to lack '
1954 'of at least read permission')
1993 'of at least read permission')
1955 make_lock = False
1994 make_lock = False
1956
1995
1957 return make_lock, currently_locked, lock_info
1996 return make_lock, currently_locked, lock_info
1958
1997
1959 @property
1998 @property
1960 def last_db_change(self):
1999 def last_db_change(self):
1961 return self.updated_on
2000 return self.updated_on
1962
2001
1963 @property
2002 @property
1964 def clone_uri_hidden(self):
2003 def clone_uri_hidden(self):
1965 clone_uri = self.clone_uri
2004 clone_uri = self.clone_uri
1966 if clone_uri:
2005 if clone_uri:
1967 import urlobject
2006 import urlobject
1968 url_obj = urlobject.URLObject(cleaned_uri(clone_uri))
2007 url_obj = urlobject.URLObject(cleaned_uri(clone_uri))
1969 if url_obj.password:
2008 if url_obj.password:
1970 clone_uri = url_obj.with_password('*****')
2009 clone_uri = url_obj.with_password('*****')
1971 return clone_uri
2010 return clone_uri
1972
2011
1973 def clone_url(self, **override):
2012 def clone_url(self, **override):
1974 from rhodecode.model.settings import SettingsModel
2013 from rhodecode.model.settings import SettingsModel
1975
2014
1976 uri_tmpl = None
2015 uri_tmpl = None
1977 if 'with_id' in override:
2016 if 'with_id' in override:
1978 uri_tmpl = self.DEFAULT_CLONE_URI_ID
2017 uri_tmpl = self.DEFAULT_CLONE_URI_ID
1979 del override['with_id']
2018 del override['with_id']
1980
2019
1981 if 'uri_tmpl' in override:
2020 if 'uri_tmpl' in override:
1982 uri_tmpl = override['uri_tmpl']
2021 uri_tmpl = override['uri_tmpl']
1983 del override['uri_tmpl']
2022 del override['uri_tmpl']
1984
2023
1985 # we didn't override our tmpl from **overrides
2024 # we didn't override our tmpl from **overrides
1986 if not uri_tmpl:
2025 if not uri_tmpl:
1987 rc_config = SettingsModel().get_all_settings(cache=True)
2026 rc_config = SettingsModel().get_all_settings(cache=True)
1988 uri_tmpl = rc_config.get(
2027 uri_tmpl = rc_config.get(
1989 'rhodecode_clone_uri_tmpl') or self.DEFAULT_CLONE_URI
2028 'rhodecode_clone_uri_tmpl') or self.DEFAULT_CLONE_URI
1990
2029
1991 request = get_current_request()
2030 request = get_current_request()
1992 return get_clone_url(request=request,
2031 return get_clone_url(request=request,
1993 uri_tmpl=uri_tmpl,
2032 uri_tmpl=uri_tmpl,
1994 repo_name=self.repo_name,
2033 repo_name=self.repo_name,
1995 repo_id=self.repo_id, **override)
2034 repo_id=self.repo_id, **override)
1996
2035
1997 def set_state(self, state):
2036 def set_state(self, state):
1998 self.repo_state = state
2037 self.repo_state = state
1999 Session().add(self)
2038 Session().add(self)
2000 #==========================================================================
2039 #==========================================================================
2001 # SCM PROPERTIES
2040 # SCM PROPERTIES
2002 #==========================================================================
2041 #==========================================================================
2003
2042
2004 def get_commit(self, commit_id=None, commit_idx=None, pre_load=None):
2043 def get_commit(self, commit_id=None, commit_idx=None, pre_load=None):
2005 return get_commit_safe(
2044 return get_commit_safe(
2006 self.scm_instance(), commit_id, commit_idx, pre_load=pre_load)
2045 self.scm_instance(), commit_id, commit_idx, pre_load=pre_load)
2007
2046
2008 def get_changeset(self, rev=None, pre_load=None):
2047 def get_changeset(self, rev=None, pre_load=None):
2009 warnings.warn("Use get_commit", DeprecationWarning)
2048 warnings.warn("Use get_commit", DeprecationWarning)
2010 commit_id = None
2049 commit_id = None
2011 commit_idx = None
2050 commit_idx = None
2012 if isinstance(rev, basestring):
2051 if isinstance(rev, basestring):
2013 commit_id = rev
2052 commit_id = rev
2014 else:
2053 else:
2015 commit_idx = rev
2054 commit_idx = rev
2016 return self.get_commit(commit_id=commit_id, commit_idx=commit_idx,
2055 return self.get_commit(commit_id=commit_id, commit_idx=commit_idx,
2017 pre_load=pre_load)
2056 pre_load=pre_load)
2018
2057
2019 def get_landing_commit(self):
2058 def get_landing_commit(self):
2020 """
2059 """
2021 Returns landing commit, or if that doesn't exist returns the tip
2060 Returns landing commit, or if that doesn't exist returns the tip
2022 """
2061 """
2023 _rev_type, _rev = self.landing_rev
2062 _rev_type, _rev = self.landing_rev
2024 commit = self.get_commit(_rev)
2063 commit = self.get_commit(_rev)
2025 if isinstance(commit, EmptyCommit):
2064 if isinstance(commit, EmptyCommit):
2026 return self.get_commit()
2065 return self.get_commit()
2027 return commit
2066 return commit
2028
2067
2029 def update_commit_cache(self, cs_cache=None, config=None):
2068 def update_commit_cache(self, cs_cache=None, config=None):
2030 """
2069 """
2031 Update cache of last changeset for repository, keys should be::
2070 Update cache of last changeset for repository, keys should be::
2032
2071
2033 short_id
2072 short_id
2034 raw_id
2073 raw_id
2035 revision
2074 revision
2036 parents
2075 parents
2037 message
2076 message
2038 date
2077 date
2039 author
2078 author
2040
2079
2041 :param cs_cache:
2080 :param cs_cache:
2042 """
2081 """
2043 from rhodecode.lib.vcs.backends.base import BaseChangeset
2082 from rhodecode.lib.vcs.backends.base import BaseChangeset
2044 if cs_cache is None:
2083 if cs_cache is None:
2045 # use no-cache version here
2084 # use no-cache version here
2046 scm_repo = self.scm_instance(cache=False, config=config)
2085 scm_repo = self.scm_instance(cache=False, config=config)
2047 if scm_repo:
2086 if scm_repo:
2048 cs_cache = scm_repo.get_commit(
2087 cs_cache = scm_repo.get_commit(
2049 pre_load=["author", "date", "message", "parents"])
2088 pre_load=["author", "date", "message", "parents"])
2050 else:
2089 else:
2051 cs_cache = EmptyCommit()
2090 cs_cache = EmptyCommit()
2052
2091
2053 if isinstance(cs_cache, BaseChangeset):
2092 if isinstance(cs_cache, BaseChangeset):
2054 cs_cache = cs_cache.__json__()
2093 cs_cache = cs_cache.__json__()
2055
2094
2056 def is_outdated(new_cs_cache):
2095 def is_outdated(new_cs_cache):
2057 if (new_cs_cache['raw_id'] != self.changeset_cache['raw_id'] or
2096 if (new_cs_cache['raw_id'] != self.changeset_cache['raw_id'] or
2058 new_cs_cache['revision'] != self.changeset_cache['revision']):
2097 new_cs_cache['revision'] != self.changeset_cache['revision']):
2059 return True
2098 return True
2060 return False
2099 return False
2061
2100
2062 # check if we have maybe already latest cached revision
2101 # check if we have maybe already latest cached revision
2063 if is_outdated(cs_cache) or not self.changeset_cache:
2102 if is_outdated(cs_cache) or not self.changeset_cache:
2064 _default = datetime.datetime.fromtimestamp(0)
2103 _default = datetime.datetime.fromtimestamp(0)
2065 last_change = cs_cache.get('date') or _default
2104 last_change = cs_cache.get('date') or _default
2066 log.debug('updated repo %s with new cs cache %s',
2105 log.debug('updated repo %s with new cs cache %s',
2067 self.repo_name, cs_cache)
2106 self.repo_name, cs_cache)
2068 self.updated_on = last_change
2107 self.updated_on = last_change
2069 self.changeset_cache = cs_cache
2108 self.changeset_cache = cs_cache
2070 Session().add(self)
2109 Session().add(self)
2071 Session().commit()
2110 Session().commit()
2072 else:
2111 else:
2073 log.debug('Skipping update_commit_cache for repo:`%s` '
2112 log.debug('Skipping update_commit_cache for repo:`%s` '
2074 'commit already with latest changes', self.repo_name)
2113 'commit already with latest changes', self.repo_name)
2075
2114
2076 @property
2115 @property
2077 def tip(self):
2116 def tip(self):
2078 return self.get_commit('tip')
2117 return self.get_commit('tip')
2079
2118
2080 @property
2119 @property
2081 def author(self):
2120 def author(self):
2082 return self.tip.author
2121 return self.tip.author
2083
2122
2084 @property
2123 @property
2085 def last_change(self):
2124 def last_change(self):
2086 return self.scm_instance().last_change
2125 return self.scm_instance().last_change
2087
2126
2088 def get_comments(self, revisions=None):
2127 def get_comments(self, revisions=None):
2089 """
2128 """
2090 Returns comments for this repository grouped by revisions
2129 Returns comments for this repository grouped by revisions
2091
2130
2092 :param revisions: filter query by revisions only
2131 :param revisions: filter query by revisions only
2093 """
2132 """
2094 cmts = ChangesetComment.query()\
2133 cmts = ChangesetComment.query()\
2095 .filter(ChangesetComment.repo == self)
2134 .filter(ChangesetComment.repo == self)
2096 if revisions:
2135 if revisions:
2097 cmts = cmts.filter(ChangesetComment.revision.in_(revisions))
2136 cmts = cmts.filter(ChangesetComment.revision.in_(revisions))
2098 grouped = collections.defaultdict(list)
2137 grouped = collections.defaultdict(list)
2099 for cmt in cmts.all():
2138 for cmt in cmts.all():
2100 grouped[cmt.revision].append(cmt)
2139 grouped[cmt.revision].append(cmt)
2101 return grouped
2140 return grouped
2102
2141
2103 def statuses(self, revisions=None):
2142 def statuses(self, revisions=None):
2104 """
2143 """
2105 Returns statuses for this repository
2144 Returns statuses for this repository
2106
2145
2107 :param revisions: list of revisions to get statuses for
2146 :param revisions: list of revisions to get statuses for
2108 """
2147 """
2109 statuses = ChangesetStatus.query()\
2148 statuses = ChangesetStatus.query()\
2110 .filter(ChangesetStatus.repo == self)\
2149 .filter(ChangesetStatus.repo == self)\
2111 .filter(ChangesetStatus.version == 0)
2150 .filter(ChangesetStatus.version == 0)
2112
2151
2113 if revisions:
2152 if revisions:
2114 # Try doing the filtering in chunks to avoid hitting limits
2153 # Try doing the filtering in chunks to avoid hitting limits
2115 size = 500
2154 size = 500
2116 status_results = []
2155 status_results = []
2117 for chunk in xrange(0, len(revisions), size):
2156 for chunk in xrange(0, len(revisions), size):
2118 status_results += statuses.filter(
2157 status_results += statuses.filter(
2119 ChangesetStatus.revision.in_(
2158 ChangesetStatus.revision.in_(
2120 revisions[chunk: chunk+size])
2159 revisions[chunk: chunk+size])
2121 ).all()
2160 ).all()
2122 else:
2161 else:
2123 status_results = statuses.all()
2162 status_results = statuses.all()
2124
2163
2125 grouped = {}
2164 grouped = {}
2126
2165
2127 # maybe we have open new pullrequest without a status?
2166 # maybe we have open new pullrequest without a status?
2128 stat = ChangesetStatus.STATUS_UNDER_REVIEW
2167 stat = ChangesetStatus.STATUS_UNDER_REVIEW
2129 status_lbl = ChangesetStatus.get_status_lbl(stat)
2168 status_lbl = ChangesetStatus.get_status_lbl(stat)
2130 for pr in PullRequest.query().filter(PullRequest.source_repo == self).all():
2169 for pr in PullRequest.query().filter(PullRequest.source_repo == self).all():
2131 for rev in pr.revisions:
2170 for rev in pr.revisions:
2132 pr_id = pr.pull_request_id
2171 pr_id = pr.pull_request_id
2133 pr_repo = pr.target_repo.repo_name
2172 pr_repo = pr.target_repo.repo_name
2134 grouped[rev] = [stat, status_lbl, pr_id, pr_repo]
2173 grouped[rev] = [stat, status_lbl, pr_id, pr_repo]
2135
2174
2136 for stat in status_results:
2175 for stat in status_results:
2137 pr_id = pr_repo = None
2176 pr_id = pr_repo = None
2138 if stat.pull_request:
2177 if stat.pull_request:
2139 pr_id = stat.pull_request.pull_request_id
2178 pr_id = stat.pull_request.pull_request_id
2140 pr_repo = stat.pull_request.target_repo.repo_name
2179 pr_repo = stat.pull_request.target_repo.repo_name
2141 grouped[stat.revision] = [str(stat.status), stat.status_lbl,
2180 grouped[stat.revision] = [str(stat.status), stat.status_lbl,
2142 pr_id, pr_repo]
2181 pr_id, pr_repo]
2143 return grouped
2182 return grouped
2144
2183
2145 # ==========================================================================
2184 # ==========================================================================
2146 # SCM CACHE INSTANCE
2185 # SCM CACHE INSTANCE
2147 # ==========================================================================
2186 # ==========================================================================
2148
2187
2149 def scm_instance(self, **kwargs):
2188 def scm_instance(self, **kwargs):
2150 import rhodecode
2189 import rhodecode
2151
2190
2152 # Passing a config will not hit the cache currently only used
2191 # Passing a config will not hit the cache currently only used
2153 # for repo2dbmapper
2192 # for repo2dbmapper
2154 config = kwargs.pop('config', None)
2193 config = kwargs.pop('config', None)
2155 cache = kwargs.pop('cache', None)
2194 cache = kwargs.pop('cache', None)
2156 full_cache = str2bool(rhodecode.CONFIG.get('vcs_full_cache'))
2195 full_cache = str2bool(rhodecode.CONFIG.get('vcs_full_cache'))
2157 # if cache is NOT defined use default global, else we have a full
2196 # if cache is NOT defined use default global, else we have a full
2158 # control over cache behaviour
2197 # control over cache behaviour
2159 if cache is None and full_cache and not config:
2198 if cache is None and full_cache and not config:
2160 return self._get_instance_cached()
2199 return self._get_instance_cached()
2161 return self._get_instance(cache=bool(cache), config=config)
2200 return self._get_instance(cache=bool(cache), config=config)
2162
2201
2163 def _get_instance_cached(self):
2202 def _get_instance_cached(self):
2164 @cache_region('long_term')
2203 @cache_region('long_term')
2165 def _get_repo(cache_key):
2204 def _get_repo(cache_key):
2166 return self._get_instance()
2205 return self._get_instance()
2167
2206
2168 invalidator_context = CacheKey.repo_context_cache(
2207 invalidator_context = CacheKey.repo_context_cache(
2169 _get_repo, self.repo_name, None, thread_scoped=True)
2208 _get_repo, self.repo_name, None, thread_scoped=True)
2170
2209
2171 with invalidator_context as context:
2210 with invalidator_context as context:
2172 context.invalidate()
2211 context.invalidate()
2173 repo = context.compute()
2212 repo = context.compute()
2174
2213
2175 return repo
2214 return repo
2176
2215
2177 def _get_instance(self, cache=True, config=None):
2216 def _get_instance(self, cache=True, config=None):
2178 config = config or self._config
2217 config = config or self._config
2179 custom_wire = {
2218 custom_wire = {
2180 'cache': cache # controls the vcs.remote cache
2219 'cache': cache # controls the vcs.remote cache
2181 }
2220 }
2182 repo = get_vcs_instance(
2221 repo = get_vcs_instance(
2183 repo_path=safe_str(self.repo_full_path),
2222 repo_path=safe_str(self.repo_full_path),
2184 config=config,
2223 config=config,
2185 with_wire=custom_wire,
2224 with_wire=custom_wire,
2186 create=False,
2225 create=False,
2187 _vcs_alias=self.repo_type)
2226 _vcs_alias=self.repo_type)
2188
2227
2189 return repo
2228 return repo
2190
2229
2191 def __json__(self):
2230 def __json__(self):
2192 return {'landing_rev': self.landing_rev}
2231 return {'landing_rev': self.landing_rev}
2193
2232
2194 def get_dict(self):
2233 def get_dict(self):
2195
2234
2196 # Since we transformed `repo_name` to a hybrid property, we need to
2235 # Since we transformed `repo_name` to a hybrid property, we need to
2197 # keep compatibility with the code which uses `repo_name` field.
2236 # keep compatibility with the code which uses `repo_name` field.
2198
2237
2199 result = super(Repository, self).get_dict()
2238 result = super(Repository, self).get_dict()
2200 result['repo_name'] = result.pop('_repo_name', None)
2239 result['repo_name'] = result.pop('_repo_name', None)
2201 return result
2240 return result
2202
2241
2203
2242
2204 class RepoGroup(Base, BaseModel):
2243 class RepoGroup(Base, BaseModel):
2205 __tablename__ = 'groups'
2244 __tablename__ = 'groups'
2206 __table_args__ = (
2245 __table_args__ = (
2207 UniqueConstraint('group_name', 'group_parent_id'),
2246 UniqueConstraint('group_name', 'group_parent_id'),
2208 CheckConstraint('group_id != group_parent_id'),
2247 CheckConstraint('group_id != group_parent_id'),
2209 {'extend_existing': True, 'mysql_engine': 'InnoDB',
2248 {'extend_existing': True, 'mysql_engine': 'InnoDB',
2210 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
2249 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
2211 )
2250 )
2212 __mapper_args__ = {'order_by': 'group_name'}
2251 __mapper_args__ = {'order_by': 'group_name'}
2213
2252
2214 CHOICES_SEPARATOR = '/' # used to generate select2 choices for nested groups
2253 CHOICES_SEPARATOR = '/' # used to generate select2 choices for nested groups
2215
2254
2216 group_id = Column("group_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
2255 group_id = Column("group_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
2217 group_name = Column("group_name", String(255), nullable=False, unique=True, default=None)
2256 group_name = Column("group_name", String(255), nullable=False, unique=True, default=None)
2218 group_parent_id = Column("group_parent_id", Integer(), ForeignKey('groups.group_id'), nullable=True, unique=None, default=None)
2257 group_parent_id = Column("group_parent_id", Integer(), ForeignKey('groups.group_id'), nullable=True, unique=None, default=None)
2219 group_description = Column("group_description", String(10000), nullable=True, unique=None, default=None)
2258 group_description = Column("group_description", String(10000), nullable=True, unique=None, default=None)
2220 enable_locking = Column("enable_locking", Boolean(), nullable=False, unique=None, default=False)
2259 enable_locking = Column("enable_locking", Boolean(), nullable=False, unique=None, default=False)
2221 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=False, default=None)
2260 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=False, default=None)
2222 created_on = Column('created_on', DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
2261 created_on = Column('created_on', DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
2223 updated_on = Column('updated_on', DateTime(timezone=False), nullable=True, unique=None, default=datetime.datetime.now)
2262 updated_on = Column('updated_on', DateTime(timezone=False), nullable=True, unique=None, default=datetime.datetime.now)
2224 personal = Column('personal', Boolean(), nullable=True, unique=None, default=None)
2263 personal = Column('personal', Boolean(), nullable=True, unique=None, default=None)
2225
2264
2226 repo_group_to_perm = relationship('UserRepoGroupToPerm', cascade='all', order_by='UserRepoGroupToPerm.group_to_perm_id')
2265 repo_group_to_perm = relationship('UserRepoGroupToPerm', cascade='all', order_by='UserRepoGroupToPerm.group_to_perm_id')
2227 users_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
2266 users_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
2228 parent_group = relationship('RepoGroup', remote_side=group_id)
2267 parent_group = relationship('RepoGroup', remote_side=group_id)
2229 user = relationship('User')
2268 user = relationship('User')
2230 integrations = relationship('Integration',
2269 integrations = relationship('Integration',
2231 cascade="all, delete, delete-orphan")
2270 cascade="all, delete, delete-orphan")
2232
2271
2233 def __init__(self, group_name='', parent_group=None):
2272 def __init__(self, group_name='', parent_group=None):
2234 self.group_name = group_name
2273 self.group_name = group_name
2235 self.parent_group = parent_group
2274 self.parent_group = parent_group
2236
2275
2237 def __unicode__(self):
2276 def __unicode__(self):
2238 return u"<%s('id:%s:%s')>" % (
2277 return u"<%s('id:%s:%s')>" % (
2239 self.__class__.__name__, self.group_id, self.group_name)
2278 self.__class__.__name__, self.group_id, self.group_name)
2240
2279
2241 @hybrid_property
2280 @hybrid_property
2242 def description_safe(self):
2281 def description_safe(self):
2243 from rhodecode.lib import helpers as h
2282 from rhodecode.lib import helpers as h
2244 return h.escape(self.group_description)
2283 return h.escape(self.group_description)
2245
2284
2246 @classmethod
2285 @classmethod
2247 def _generate_choice(cls, repo_group):
2286 def _generate_choice(cls, repo_group):
2248 from webhelpers.html import literal as _literal
2287 from webhelpers.html import literal as _literal
2249 _name = lambda k: _literal(cls.CHOICES_SEPARATOR.join(k))
2288 _name = lambda k: _literal(cls.CHOICES_SEPARATOR.join(k))
2250 return repo_group.group_id, _name(repo_group.full_path_splitted)
2289 return repo_group.group_id, _name(repo_group.full_path_splitted)
2251
2290
2252 @classmethod
2291 @classmethod
2253 def groups_choices(cls, groups=None, show_empty_group=True):
2292 def groups_choices(cls, groups=None, show_empty_group=True):
2254 if not groups:
2293 if not groups:
2255 groups = cls.query().all()
2294 groups = cls.query().all()
2256
2295
2257 repo_groups = []
2296 repo_groups = []
2258 if show_empty_group:
2297 if show_empty_group:
2259 repo_groups = [(-1, u'-- %s --' % _('No parent'))]
2298 repo_groups = [(-1, u'-- %s --' % _('No parent'))]
2260
2299
2261 repo_groups.extend([cls._generate_choice(x) for x in groups])
2300 repo_groups.extend([cls._generate_choice(x) for x in groups])
2262
2301
2263 repo_groups = sorted(
2302 repo_groups = sorted(
2264 repo_groups, key=lambda t: t[1].split(cls.CHOICES_SEPARATOR)[0])
2303 repo_groups, key=lambda t: t[1].split(cls.CHOICES_SEPARATOR)[0])
2265 return repo_groups
2304 return repo_groups
2266
2305
2267 @classmethod
2306 @classmethod
2268 def url_sep(cls):
2307 def url_sep(cls):
2269 return URL_SEP
2308 return URL_SEP
2270
2309
2271 @classmethod
2310 @classmethod
2272 def get_by_group_name(cls, group_name, cache=False, case_insensitive=False):
2311 def get_by_group_name(cls, group_name, cache=False, case_insensitive=False):
2273 if case_insensitive:
2312 if case_insensitive:
2274 gr = cls.query().filter(func.lower(cls.group_name)
2313 gr = cls.query().filter(func.lower(cls.group_name)
2275 == func.lower(group_name))
2314 == func.lower(group_name))
2276 else:
2315 else:
2277 gr = cls.query().filter(cls.group_name == group_name)
2316 gr = cls.query().filter(cls.group_name == group_name)
2278 if cache:
2317 if cache:
2279 name_key = _hash_key(group_name)
2318 name_key = _hash_key(group_name)
2280 gr = gr.options(
2319 gr = gr.options(
2281 FromCache("sql_cache_short", "get_group_%s" % name_key))
2320 FromCache("sql_cache_short", "get_group_%s" % name_key))
2282 return gr.scalar()
2321 return gr.scalar()
2283
2322
2284 @classmethod
2323 @classmethod
2285 def get_user_personal_repo_group(cls, user_id):
2324 def get_user_personal_repo_group(cls, user_id):
2286 user = User.get(user_id)
2325 user = User.get(user_id)
2287 if user.username == User.DEFAULT_USER:
2326 if user.username == User.DEFAULT_USER:
2288 return None
2327 return None
2289
2328
2290 return cls.query()\
2329 return cls.query()\
2291 .filter(cls.personal == true()) \
2330 .filter(cls.personal == true()) \
2292 .filter(cls.user == user).scalar()
2331 .filter(cls.user == user).scalar()
2293
2332
2294 @classmethod
2333 @classmethod
2295 def get_all_repo_groups(cls, user_id=Optional(None), group_id=Optional(None),
2334 def get_all_repo_groups(cls, user_id=Optional(None), group_id=Optional(None),
2296 case_insensitive=True):
2335 case_insensitive=True):
2297 q = RepoGroup.query()
2336 q = RepoGroup.query()
2298
2337
2299 if not isinstance(user_id, Optional):
2338 if not isinstance(user_id, Optional):
2300 q = q.filter(RepoGroup.user_id == user_id)
2339 q = q.filter(RepoGroup.user_id == user_id)
2301
2340
2302 if not isinstance(group_id, Optional):
2341 if not isinstance(group_id, Optional):
2303 q = q.filter(RepoGroup.group_parent_id == group_id)
2342 q = q.filter(RepoGroup.group_parent_id == group_id)
2304
2343
2305 if case_insensitive:
2344 if case_insensitive:
2306 q = q.order_by(func.lower(RepoGroup.group_name))
2345 q = q.order_by(func.lower(RepoGroup.group_name))
2307 else:
2346 else:
2308 q = q.order_by(RepoGroup.group_name)
2347 q = q.order_by(RepoGroup.group_name)
2309 return q.all()
2348 return q.all()
2310
2349
2311 @property
2350 @property
2312 def parents(self):
2351 def parents(self):
2313 parents_recursion_limit = 10
2352 parents_recursion_limit = 10
2314 groups = []
2353 groups = []
2315 if self.parent_group is None:
2354 if self.parent_group is None:
2316 return groups
2355 return groups
2317 cur_gr = self.parent_group
2356 cur_gr = self.parent_group
2318 groups.insert(0, cur_gr)
2357 groups.insert(0, cur_gr)
2319 cnt = 0
2358 cnt = 0
2320 while 1:
2359 while 1:
2321 cnt += 1
2360 cnt += 1
2322 gr = getattr(cur_gr, 'parent_group', None)
2361 gr = getattr(cur_gr, 'parent_group', None)
2323 cur_gr = cur_gr.parent_group
2362 cur_gr = cur_gr.parent_group
2324 if gr is None:
2363 if gr is None:
2325 break
2364 break
2326 if cnt == parents_recursion_limit:
2365 if cnt == parents_recursion_limit:
2327 # this will prevent accidental infinit loops
2366 # this will prevent accidental infinit loops
2328 log.error(('more than %s parents found for group %s, stopping '
2367 log.error(('more than %s parents found for group %s, stopping '
2329 'recursive parent fetching' % (parents_recursion_limit, self)))
2368 'recursive parent fetching' % (parents_recursion_limit, self)))
2330 break
2369 break
2331
2370
2332 groups.insert(0, gr)
2371 groups.insert(0, gr)
2333 return groups
2372 return groups
2334
2373
2335 @property
2374 @property
2336 def last_db_change(self):
2375 def last_db_change(self):
2337 return self.updated_on
2376 return self.updated_on
2338
2377
2339 @property
2378 @property
2340 def children(self):
2379 def children(self):
2341 return RepoGroup.query().filter(RepoGroup.parent_group == self)
2380 return RepoGroup.query().filter(RepoGroup.parent_group == self)
2342
2381
2343 @property
2382 @property
2344 def name(self):
2383 def name(self):
2345 return self.group_name.split(RepoGroup.url_sep())[-1]
2384 return self.group_name.split(RepoGroup.url_sep())[-1]
2346
2385
2347 @property
2386 @property
2348 def full_path(self):
2387 def full_path(self):
2349 return self.group_name
2388 return self.group_name
2350
2389
2351 @property
2390 @property
2352 def full_path_splitted(self):
2391 def full_path_splitted(self):
2353 return self.group_name.split(RepoGroup.url_sep())
2392 return self.group_name.split(RepoGroup.url_sep())
2354
2393
2355 @property
2394 @property
2356 def repositories(self):
2395 def repositories(self):
2357 return Repository.query()\
2396 return Repository.query()\
2358 .filter(Repository.group == self)\
2397 .filter(Repository.group == self)\
2359 .order_by(Repository.repo_name)
2398 .order_by(Repository.repo_name)
2360
2399
2361 @property
2400 @property
2362 def repositories_recursive_count(self):
2401 def repositories_recursive_count(self):
2363 cnt = self.repositories.count()
2402 cnt = self.repositories.count()
2364
2403
2365 def children_count(group):
2404 def children_count(group):
2366 cnt = 0
2405 cnt = 0
2367 for child in group.children:
2406 for child in group.children:
2368 cnt += child.repositories.count()
2407 cnt += child.repositories.count()
2369 cnt += children_count(child)
2408 cnt += children_count(child)
2370 return cnt
2409 return cnt
2371
2410
2372 return cnt + children_count(self)
2411 return cnt + children_count(self)
2373
2412
2374 def _recursive_objects(self, include_repos=True):
2413 def _recursive_objects(self, include_repos=True):
2375 all_ = []
2414 all_ = []
2376
2415
2377 def _get_members(root_gr):
2416 def _get_members(root_gr):
2378 if include_repos:
2417 if include_repos:
2379 for r in root_gr.repositories:
2418 for r in root_gr.repositories:
2380 all_.append(r)
2419 all_.append(r)
2381 childs = root_gr.children.all()
2420 childs = root_gr.children.all()
2382 if childs:
2421 if childs:
2383 for gr in childs:
2422 for gr in childs:
2384 all_.append(gr)
2423 all_.append(gr)
2385 _get_members(gr)
2424 _get_members(gr)
2386
2425
2387 _get_members(self)
2426 _get_members(self)
2388 return [self] + all_
2427 return [self] + all_
2389
2428
2390 def recursive_groups_and_repos(self):
2429 def recursive_groups_and_repos(self):
2391 """
2430 """
2392 Recursive return all groups, with repositories in those groups
2431 Recursive return all groups, with repositories in those groups
2393 """
2432 """
2394 return self._recursive_objects()
2433 return self._recursive_objects()
2395
2434
2396 def recursive_groups(self):
2435 def recursive_groups(self):
2397 """
2436 """
2398 Returns all children groups for this group including children of children
2437 Returns all children groups for this group including children of children
2399 """
2438 """
2400 return self._recursive_objects(include_repos=False)
2439 return self._recursive_objects(include_repos=False)
2401
2440
2402 def get_new_name(self, group_name):
2441 def get_new_name(self, group_name):
2403 """
2442 """
2404 returns new full group name based on parent and new name
2443 returns new full group name based on parent and new name
2405
2444
2406 :param group_name:
2445 :param group_name:
2407 """
2446 """
2408 path_prefix = (self.parent_group.full_path_splitted if
2447 path_prefix = (self.parent_group.full_path_splitted if
2409 self.parent_group else [])
2448 self.parent_group else [])
2410 return RepoGroup.url_sep().join(path_prefix + [group_name])
2449 return RepoGroup.url_sep().join(path_prefix + [group_name])
2411
2450
2412 def permissions(self, with_admins=True, with_owner=True):
2451 def permissions(self, with_admins=True, with_owner=True):
2413 q = UserRepoGroupToPerm.query().filter(UserRepoGroupToPerm.group == self)
2452 q = UserRepoGroupToPerm.query().filter(UserRepoGroupToPerm.group == self)
2414 q = q.options(joinedload(UserRepoGroupToPerm.group),
2453 q = q.options(joinedload(UserRepoGroupToPerm.group),
2415 joinedload(UserRepoGroupToPerm.user),
2454 joinedload(UserRepoGroupToPerm.user),
2416 joinedload(UserRepoGroupToPerm.permission),)
2455 joinedload(UserRepoGroupToPerm.permission),)
2417
2456
2418 # get owners and admins and permissions. We do a trick of re-writing
2457 # get owners and admins and permissions. We do a trick of re-writing
2419 # objects from sqlalchemy to named-tuples due to sqlalchemy session
2458 # objects from sqlalchemy to named-tuples due to sqlalchemy session
2420 # has a global reference and changing one object propagates to all
2459 # has a global reference and changing one object propagates to all
2421 # others. This means if admin is also an owner admin_row that change
2460 # others. This means if admin is also an owner admin_row that change
2422 # would propagate to both objects
2461 # would propagate to both objects
2423 perm_rows = []
2462 perm_rows = []
2424 for _usr in q.all():
2463 for _usr in q.all():
2425 usr = AttributeDict(_usr.user.get_dict())
2464 usr = AttributeDict(_usr.user.get_dict())
2426 usr.permission = _usr.permission.permission_name
2465 usr.permission = _usr.permission.permission_name
2427 perm_rows.append(usr)
2466 perm_rows.append(usr)
2428
2467
2429 # filter the perm rows by 'default' first and then sort them by
2468 # filter the perm rows by 'default' first and then sort them by
2430 # admin,write,read,none permissions sorted again alphabetically in
2469 # admin,write,read,none permissions sorted again alphabetically in
2431 # each group
2470 # each group
2432 perm_rows = sorted(perm_rows, key=display_sort)
2471 perm_rows = sorted(perm_rows, key=display_sort)
2433
2472
2434 _admin_perm = 'group.admin'
2473 _admin_perm = 'group.admin'
2435 owner_row = []
2474 owner_row = []
2436 if with_owner:
2475 if with_owner:
2437 usr = AttributeDict(self.user.get_dict())
2476 usr = AttributeDict(self.user.get_dict())
2438 usr.owner_row = True
2477 usr.owner_row = True
2439 usr.permission = _admin_perm
2478 usr.permission = _admin_perm
2440 owner_row.append(usr)
2479 owner_row.append(usr)
2441
2480
2442 super_admin_rows = []
2481 super_admin_rows = []
2443 if with_admins:
2482 if with_admins:
2444 for usr in User.get_all_super_admins():
2483 for usr in User.get_all_super_admins():
2445 # if this admin is also owner, don't double the record
2484 # if this admin is also owner, don't double the record
2446 if usr.user_id == owner_row[0].user_id:
2485 if usr.user_id == owner_row[0].user_id:
2447 owner_row[0].admin_row = True
2486 owner_row[0].admin_row = True
2448 else:
2487 else:
2449 usr = AttributeDict(usr.get_dict())
2488 usr = AttributeDict(usr.get_dict())
2450 usr.admin_row = True
2489 usr.admin_row = True
2451 usr.permission = _admin_perm
2490 usr.permission = _admin_perm
2452 super_admin_rows.append(usr)
2491 super_admin_rows.append(usr)
2453
2492
2454 return super_admin_rows + owner_row + perm_rows
2493 return super_admin_rows + owner_row + perm_rows
2455
2494
2456 def permission_user_groups(self):
2495 def permission_user_groups(self):
2457 q = UserGroupRepoGroupToPerm.query().filter(UserGroupRepoGroupToPerm.group == self)
2496 q = UserGroupRepoGroupToPerm.query().filter(UserGroupRepoGroupToPerm.group == self)
2458 q = q.options(joinedload(UserGroupRepoGroupToPerm.group),
2497 q = q.options(joinedload(UserGroupRepoGroupToPerm.group),
2459 joinedload(UserGroupRepoGroupToPerm.users_group),
2498 joinedload(UserGroupRepoGroupToPerm.users_group),
2460 joinedload(UserGroupRepoGroupToPerm.permission),)
2499 joinedload(UserGroupRepoGroupToPerm.permission),)
2461
2500
2462 perm_rows = []
2501 perm_rows = []
2463 for _user_group in q.all():
2502 for _user_group in q.all():
2464 usr = AttributeDict(_user_group.users_group.get_dict())
2503 usr = AttributeDict(_user_group.users_group.get_dict())
2465 usr.permission = _user_group.permission.permission_name
2504 usr.permission = _user_group.permission.permission_name
2466 perm_rows.append(usr)
2505 perm_rows.append(usr)
2467
2506
2468 return perm_rows
2507 return perm_rows
2469
2508
2470 def get_api_data(self):
2509 def get_api_data(self):
2471 """
2510 """
2472 Common function for generating api data
2511 Common function for generating api data
2473
2512
2474 """
2513 """
2475 group = self
2514 group = self
2476 data = {
2515 data = {
2477 'group_id': group.group_id,
2516 'group_id': group.group_id,
2478 'group_name': group.group_name,
2517 'group_name': group.group_name,
2479 'group_description': group.description_safe,
2518 'group_description': group.description_safe,
2480 'parent_group': group.parent_group.group_name if group.parent_group else None,
2519 'parent_group': group.parent_group.group_name if group.parent_group else None,
2481 'repositories': [x.repo_name for x in group.repositories],
2520 'repositories': [x.repo_name for x in group.repositories],
2482 'owner': group.user.username,
2521 'owner': group.user.username,
2483 }
2522 }
2484 return data
2523 return data
2485
2524
2486
2525
2487 class Permission(Base, BaseModel):
2526 class Permission(Base, BaseModel):
2488 __tablename__ = 'permissions'
2527 __tablename__ = 'permissions'
2489 __table_args__ = (
2528 __table_args__ = (
2490 Index('p_perm_name_idx', 'permission_name'),
2529 Index('p_perm_name_idx', 'permission_name'),
2491 {'extend_existing': True, 'mysql_engine': 'InnoDB',
2530 {'extend_existing': True, 'mysql_engine': 'InnoDB',
2492 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
2531 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
2493 )
2532 )
2494 PERMS = [
2533 PERMS = [
2495 ('hg.admin', _('RhodeCode Super Administrator')),
2534 ('hg.admin', _('RhodeCode Super Administrator')),
2496
2535
2497 ('repository.none', _('Repository no access')),
2536 ('repository.none', _('Repository no access')),
2498 ('repository.read', _('Repository read access')),
2537 ('repository.read', _('Repository read access')),
2499 ('repository.write', _('Repository write access')),
2538 ('repository.write', _('Repository write access')),
2500 ('repository.admin', _('Repository admin access')),
2539 ('repository.admin', _('Repository admin access')),
2501
2540
2502 ('group.none', _('Repository group no access')),
2541 ('group.none', _('Repository group no access')),
2503 ('group.read', _('Repository group read access')),
2542 ('group.read', _('Repository group read access')),
2504 ('group.write', _('Repository group write access')),
2543 ('group.write', _('Repository group write access')),
2505 ('group.admin', _('Repository group admin access')),
2544 ('group.admin', _('Repository group admin access')),
2506
2545
2507 ('usergroup.none', _('User group no access')),
2546 ('usergroup.none', _('User group no access')),
2508 ('usergroup.read', _('User group read access')),
2547 ('usergroup.read', _('User group read access')),
2509 ('usergroup.write', _('User group write access')),
2548 ('usergroup.write', _('User group write access')),
2510 ('usergroup.admin', _('User group admin access')),
2549 ('usergroup.admin', _('User group admin access')),
2511
2550
2512 ('hg.repogroup.create.false', _('Repository Group creation disabled')),
2551 ('hg.repogroup.create.false', _('Repository Group creation disabled')),
2513 ('hg.repogroup.create.true', _('Repository Group creation enabled')),
2552 ('hg.repogroup.create.true', _('Repository Group creation enabled')),
2514
2553
2515 ('hg.usergroup.create.false', _('User Group creation disabled')),
2554 ('hg.usergroup.create.false', _('User Group creation disabled')),
2516 ('hg.usergroup.create.true', _('User Group creation enabled')),
2555 ('hg.usergroup.create.true', _('User Group creation enabled')),
2517
2556
2518 ('hg.create.none', _('Repository creation disabled')),
2557 ('hg.create.none', _('Repository creation disabled')),
2519 ('hg.create.repository', _('Repository creation enabled')),
2558 ('hg.create.repository', _('Repository creation enabled')),
2520 ('hg.create.write_on_repogroup.true', _('Repository creation enabled with write permission to a repository group')),
2559 ('hg.create.write_on_repogroup.true', _('Repository creation enabled with write permission to a repository group')),
2521 ('hg.create.write_on_repogroup.false', _('Repository creation disabled with write permission to a repository group')),
2560 ('hg.create.write_on_repogroup.false', _('Repository creation disabled with write permission to a repository group')),
2522
2561
2523 ('hg.fork.none', _('Repository forking disabled')),
2562 ('hg.fork.none', _('Repository forking disabled')),
2524 ('hg.fork.repository', _('Repository forking enabled')),
2563 ('hg.fork.repository', _('Repository forking enabled')),
2525
2564
2526 ('hg.register.none', _('Registration disabled')),
2565 ('hg.register.none', _('Registration disabled')),
2527 ('hg.register.manual_activate', _('User Registration with manual account activation')),
2566 ('hg.register.manual_activate', _('User Registration with manual account activation')),
2528 ('hg.register.auto_activate', _('User Registration with automatic account activation')),
2567 ('hg.register.auto_activate', _('User Registration with automatic account activation')),
2529
2568
2530 ('hg.password_reset.enabled', _('Password reset enabled')),
2569 ('hg.password_reset.enabled', _('Password reset enabled')),
2531 ('hg.password_reset.hidden', _('Password reset hidden')),
2570 ('hg.password_reset.hidden', _('Password reset hidden')),
2532 ('hg.password_reset.disabled', _('Password reset disabled')),
2571 ('hg.password_reset.disabled', _('Password reset disabled')),
2533
2572
2534 ('hg.extern_activate.manual', _('Manual activation of external account')),
2573 ('hg.extern_activate.manual', _('Manual activation of external account')),
2535 ('hg.extern_activate.auto', _('Automatic activation of external account')),
2574 ('hg.extern_activate.auto', _('Automatic activation of external account')),
2536
2575
2537 ('hg.inherit_default_perms.false', _('Inherit object permissions from default user disabled')),
2576 ('hg.inherit_default_perms.false', _('Inherit object permissions from default user disabled')),
2538 ('hg.inherit_default_perms.true', _('Inherit object permissions from default user enabled')),
2577 ('hg.inherit_default_perms.true', _('Inherit object permissions from default user enabled')),
2539 ]
2578 ]
2540
2579
2541 # definition of system default permissions for DEFAULT user
2580 # definition of system default permissions for DEFAULT user
2542 DEFAULT_USER_PERMISSIONS = [
2581 DEFAULT_USER_PERMISSIONS = [
2543 'repository.read',
2582 'repository.read',
2544 'group.read',
2583 'group.read',
2545 'usergroup.read',
2584 'usergroup.read',
2546 'hg.create.repository',
2585 'hg.create.repository',
2547 'hg.repogroup.create.false',
2586 'hg.repogroup.create.false',
2548 'hg.usergroup.create.false',
2587 'hg.usergroup.create.false',
2549 'hg.create.write_on_repogroup.true',
2588 'hg.create.write_on_repogroup.true',
2550 'hg.fork.repository',
2589 'hg.fork.repository',
2551 'hg.register.manual_activate',
2590 'hg.register.manual_activate',
2552 'hg.password_reset.enabled',
2591 'hg.password_reset.enabled',
2553 'hg.extern_activate.auto',
2592 'hg.extern_activate.auto',
2554 'hg.inherit_default_perms.true',
2593 'hg.inherit_default_perms.true',
2555 ]
2594 ]
2556
2595
2557 # defines which permissions are more important higher the more important
2596 # defines which permissions are more important higher the more important
2558 # Weight defines which permissions are more important.
2597 # Weight defines which permissions are more important.
2559 # The higher number the more important.
2598 # The higher number the more important.
2560 PERM_WEIGHTS = {
2599 PERM_WEIGHTS = {
2561 'repository.none': 0,
2600 'repository.none': 0,
2562 'repository.read': 1,
2601 'repository.read': 1,
2563 'repository.write': 3,
2602 'repository.write': 3,
2564 'repository.admin': 4,
2603 'repository.admin': 4,
2565
2604
2566 'group.none': 0,
2605 'group.none': 0,
2567 'group.read': 1,
2606 'group.read': 1,
2568 'group.write': 3,
2607 'group.write': 3,
2569 'group.admin': 4,
2608 'group.admin': 4,
2570
2609
2571 'usergroup.none': 0,
2610 'usergroup.none': 0,
2572 'usergroup.read': 1,
2611 'usergroup.read': 1,
2573 'usergroup.write': 3,
2612 'usergroup.write': 3,
2574 'usergroup.admin': 4,
2613 'usergroup.admin': 4,
2575
2614
2576 'hg.repogroup.create.false': 0,
2615 'hg.repogroup.create.false': 0,
2577 'hg.repogroup.create.true': 1,
2616 'hg.repogroup.create.true': 1,
2578
2617
2579 'hg.usergroup.create.false': 0,
2618 'hg.usergroup.create.false': 0,
2580 'hg.usergroup.create.true': 1,
2619 'hg.usergroup.create.true': 1,
2581
2620
2582 'hg.fork.none': 0,
2621 'hg.fork.none': 0,
2583 'hg.fork.repository': 1,
2622 'hg.fork.repository': 1,
2584 'hg.create.none': 0,
2623 'hg.create.none': 0,
2585 'hg.create.repository': 1
2624 'hg.create.repository': 1
2586 }
2625 }
2587
2626
2588 permission_id = Column("permission_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
2627 permission_id = Column("permission_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
2589 permission_name = Column("permission_name", String(255), nullable=True, unique=None, default=None)
2628 permission_name = Column("permission_name", String(255), nullable=True, unique=None, default=None)
2590 permission_longname = Column("permission_longname", String(255), nullable=True, unique=None, default=None)
2629 permission_longname = Column("permission_longname", String(255), nullable=True, unique=None, default=None)
2591
2630
2592 def __unicode__(self):
2631 def __unicode__(self):
2593 return u"<%s('%s:%s')>" % (
2632 return u"<%s('%s:%s')>" % (
2594 self.__class__.__name__, self.permission_id, self.permission_name
2633 self.__class__.__name__, self.permission_id, self.permission_name
2595 )
2634 )
2596
2635
2597 @classmethod
2636 @classmethod
2598 def get_by_key(cls, key):
2637 def get_by_key(cls, key):
2599 return cls.query().filter(cls.permission_name == key).scalar()
2638 return cls.query().filter(cls.permission_name == key).scalar()
2600
2639
2601 @classmethod
2640 @classmethod
2602 def get_default_repo_perms(cls, user_id, repo_id=None):
2641 def get_default_repo_perms(cls, user_id, repo_id=None):
2603 q = Session().query(UserRepoToPerm, Repository, Permission)\
2642 q = Session().query(UserRepoToPerm, Repository, Permission)\
2604 .join((Permission, UserRepoToPerm.permission_id == Permission.permission_id))\
2643 .join((Permission, UserRepoToPerm.permission_id == Permission.permission_id))\
2605 .join((Repository, UserRepoToPerm.repository_id == Repository.repo_id))\
2644 .join((Repository, UserRepoToPerm.repository_id == Repository.repo_id))\
2606 .filter(UserRepoToPerm.user_id == user_id)
2645 .filter(UserRepoToPerm.user_id == user_id)
2607 if repo_id:
2646 if repo_id:
2608 q = q.filter(UserRepoToPerm.repository_id == repo_id)
2647 q = q.filter(UserRepoToPerm.repository_id == repo_id)
2609 return q.all()
2648 return q.all()
2610
2649
2611 @classmethod
2650 @classmethod
2612 def get_default_repo_perms_from_user_group(cls, user_id, repo_id=None):
2651 def get_default_repo_perms_from_user_group(cls, user_id, repo_id=None):
2613 q = Session().query(UserGroupRepoToPerm, Repository, Permission)\
2652 q = Session().query(UserGroupRepoToPerm, Repository, Permission)\
2614 .join(
2653 .join(
2615 Permission,
2654 Permission,
2616 UserGroupRepoToPerm.permission_id == Permission.permission_id)\
2655 UserGroupRepoToPerm.permission_id == Permission.permission_id)\
2617 .join(
2656 .join(
2618 Repository,
2657 Repository,
2619 UserGroupRepoToPerm.repository_id == Repository.repo_id)\
2658 UserGroupRepoToPerm.repository_id == Repository.repo_id)\
2620 .join(
2659 .join(
2621 UserGroup,
2660 UserGroup,
2622 UserGroupRepoToPerm.users_group_id ==
2661 UserGroupRepoToPerm.users_group_id ==
2623 UserGroup.users_group_id)\
2662 UserGroup.users_group_id)\
2624 .join(
2663 .join(
2625 UserGroupMember,
2664 UserGroupMember,
2626 UserGroupRepoToPerm.users_group_id ==
2665 UserGroupRepoToPerm.users_group_id ==
2627 UserGroupMember.users_group_id)\
2666 UserGroupMember.users_group_id)\
2628 .filter(
2667 .filter(
2629 UserGroupMember.user_id == user_id,
2668 UserGroupMember.user_id == user_id,
2630 UserGroup.users_group_active == true())
2669 UserGroup.users_group_active == true())
2631 if repo_id:
2670 if repo_id:
2632 q = q.filter(UserGroupRepoToPerm.repository_id == repo_id)
2671 q = q.filter(UserGroupRepoToPerm.repository_id == repo_id)
2633 return q.all()
2672 return q.all()
2634
2673
2635 @classmethod
2674 @classmethod
2636 def get_default_group_perms(cls, user_id, repo_group_id=None):
2675 def get_default_group_perms(cls, user_id, repo_group_id=None):
2637 q = Session().query(UserRepoGroupToPerm, RepoGroup, Permission)\
2676 q = Session().query(UserRepoGroupToPerm, RepoGroup, Permission)\
2638 .join((Permission, UserRepoGroupToPerm.permission_id == Permission.permission_id))\
2677 .join((Permission, UserRepoGroupToPerm.permission_id == Permission.permission_id))\
2639 .join((RepoGroup, UserRepoGroupToPerm.group_id == RepoGroup.group_id))\
2678 .join((RepoGroup, UserRepoGroupToPerm.group_id == RepoGroup.group_id))\
2640 .filter(UserRepoGroupToPerm.user_id == user_id)
2679 .filter(UserRepoGroupToPerm.user_id == user_id)
2641 if repo_group_id:
2680 if repo_group_id:
2642 q = q.filter(UserRepoGroupToPerm.group_id == repo_group_id)
2681 q = q.filter(UserRepoGroupToPerm.group_id == repo_group_id)
2643 return q.all()
2682 return q.all()
2644
2683
2645 @classmethod
2684 @classmethod
2646 def get_default_group_perms_from_user_group(
2685 def get_default_group_perms_from_user_group(
2647 cls, user_id, repo_group_id=None):
2686 cls, user_id, repo_group_id=None):
2648 q = Session().query(UserGroupRepoGroupToPerm, RepoGroup, Permission)\
2687 q = Session().query(UserGroupRepoGroupToPerm, RepoGroup, Permission)\
2649 .join(
2688 .join(
2650 Permission,
2689 Permission,
2651 UserGroupRepoGroupToPerm.permission_id ==
2690 UserGroupRepoGroupToPerm.permission_id ==
2652 Permission.permission_id)\
2691 Permission.permission_id)\
2653 .join(
2692 .join(
2654 RepoGroup,
2693 RepoGroup,
2655 UserGroupRepoGroupToPerm.group_id == RepoGroup.group_id)\
2694 UserGroupRepoGroupToPerm.group_id == RepoGroup.group_id)\
2656 .join(
2695 .join(
2657 UserGroup,
2696 UserGroup,
2658 UserGroupRepoGroupToPerm.users_group_id ==
2697 UserGroupRepoGroupToPerm.users_group_id ==
2659 UserGroup.users_group_id)\
2698 UserGroup.users_group_id)\
2660 .join(
2699 .join(
2661 UserGroupMember,
2700 UserGroupMember,
2662 UserGroupRepoGroupToPerm.users_group_id ==
2701 UserGroupRepoGroupToPerm.users_group_id ==
2663 UserGroupMember.users_group_id)\
2702 UserGroupMember.users_group_id)\
2664 .filter(
2703 .filter(
2665 UserGroupMember.user_id == user_id,
2704 UserGroupMember.user_id == user_id,
2666 UserGroup.users_group_active == true())
2705 UserGroup.users_group_active == true())
2667 if repo_group_id:
2706 if repo_group_id:
2668 q = q.filter(UserGroupRepoGroupToPerm.group_id == repo_group_id)
2707 q = q.filter(UserGroupRepoGroupToPerm.group_id == repo_group_id)
2669 return q.all()
2708 return q.all()
2670
2709
2671 @classmethod
2710 @classmethod
2672 def get_default_user_group_perms(cls, user_id, user_group_id=None):
2711 def get_default_user_group_perms(cls, user_id, user_group_id=None):
2673 q = Session().query(UserUserGroupToPerm, UserGroup, Permission)\
2712 q = Session().query(UserUserGroupToPerm, UserGroup, Permission)\
2674 .join((Permission, UserUserGroupToPerm.permission_id == Permission.permission_id))\
2713 .join((Permission, UserUserGroupToPerm.permission_id == Permission.permission_id))\
2675 .join((UserGroup, UserUserGroupToPerm.user_group_id == UserGroup.users_group_id))\
2714 .join((UserGroup, UserUserGroupToPerm.user_group_id == UserGroup.users_group_id))\
2676 .filter(UserUserGroupToPerm.user_id == user_id)
2715 .filter(UserUserGroupToPerm.user_id == user_id)
2677 if user_group_id:
2716 if user_group_id:
2678 q = q.filter(UserUserGroupToPerm.user_group_id == user_group_id)
2717 q = q.filter(UserUserGroupToPerm.user_group_id == user_group_id)
2679 return q.all()
2718 return q.all()
2680
2719
2681 @classmethod
2720 @classmethod
2682 def get_default_user_group_perms_from_user_group(
2721 def get_default_user_group_perms_from_user_group(
2683 cls, user_id, user_group_id=None):
2722 cls, user_id, user_group_id=None):
2684 TargetUserGroup = aliased(UserGroup, name='target_user_group')
2723 TargetUserGroup = aliased(UserGroup, name='target_user_group')
2685 q = Session().query(UserGroupUserGroupToPerm, UserGroup, Permission)\
2724 q = Session().query(UserGroupUserGroupToPerm, UserGroup, Permission)\
2686 .join(
2725 .join(
2687 Permission,
2726 Permission,
2688 UserGroupUserGroupToPerm.permission_id ==
2727 UserGroupUserGroupToPerm.permission_id ==
2689 Permission.permission_id)\
2728 Permission.permission_id)\
2690 .join(
2729 .join(
2691 TargetUserGroup,
2730 TargetUserGroup,
2692 UserGroupUserGroupToPerm.target_user_group_id ==
2731 UserGroupUserGroupToPerm.target_user_group_id ==
2693 TargetUserGroup.users_group_id)\
2732 TargetUserGroup.users_group_id)\
2694 .join(
2733 .join(
2695 UserGroup,
2734 UserGroup,
2696 UserGroupUserGroupToPerm.user_group_id ==
2735 UserGroupUserGroupToPerm.user_group_id ==
2697 UserGroup.users_group_id)\
2736 UserGroup.users_group_id)\
2698 .join(
2737 .join(
2699 UserGroupMember,
2738 UserGroupMember,
2700 UserGroupUserGroupToPerm.user_group_id ==
2739 UserGroupUserGroupToPerm.user_group_id ==
2701 UserGroupMember.users_group_id)\
2740 UserGroupMember.users_group_id)\
2702 .filter(
2741 .filter(
2703 UserGroupMember.user_id == user_id,
2742 UserGroupMember.user_id == user_id,
2704 UserGroup.users_group_active == true())
2743 UserGroup.users_group_active == true())
2705 if user_group_id:
2744 if user_group_id:
2706 q = q.filter(
2745 q = q.filter(
2707 UserGroupUserGroupToPerm.user_group_id == user_group_id)
2746 UserGroupUserGroupToPerm.user_group_id == user_group_id)
2708
2747
2709 return q.all()
2748 return q.all()
2710
2749
2711
2750
2712 class UserRepoToPerm(Base, BaseModel):
2751 class UserRepoToPerm(Base, BaseModel):
2713 __tablename__ = 'repo_to_perm'
2752 __tablename__ = 'repo_to_perm'
2714 __table_args__ = (
2753 __table_args__ = (
2715 UniqueConstraint('user_id', 'repository_id', 'permission_id'),
2754 UniqueConstraint('user_id', 'repository_id', 'permission_id'),
2716 {'extend_existing': True, 'mysql_engine': 'InnoDB',
2755 {'extend_existing': True, 'mysql_engine': 'InnoDB',
2717 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
2756 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
2718 )
2757 )
2719 repo_to_perm_id = Column("repo_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
2758 repo_to_perm_id = Column("repo_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
2720 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=None, default=None)
2759 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=None, default=None)
2721 permission_id = Column("permission_id", Integer(), ForeignKey('permissions.permission_id'), nullable=False, unique=None, default=None)
2760 permission_id = Column("permission_id", Integer(), ForeignKey('permissions.permission_id'), nullable=False, unique=None, default=None)
2722 repository_id = Column("repository_id", Integer(), ForeignKey('repositories.repo_id'), nullable=False, unique=None, default=None)
2761 repository_id = Column("repository_id", Integer(), ForeignKey('repositories.repo_id'), nullable=False, unique=None, default=None)
2723
2762
2724 user = relationship('User')
2763 user = relationship('User')
2725 repository = relationship('Repository')
2764 repository = relationship('Repository')
2726 permission = relationship('Permission')
2765 permission = relationship('Permission')
2727
2766
2728 @classmethod
2767 @classmethod
2729 def create(cls, user, repository, permission):
2768 def create(cls, user, repository, permission):
2730 n = cls()
2769 n = cls()
2731 n.user = user
2770 n.user = user
2732 n.repository = repository
2771 n.repository = repository
2733 n.permission = permission
2772 n.permission = permission
2734 Session().add(n)
2773 Session().add(n)
2735 return n
2774 return n
2736
2775
2737 def __unicode__(self):
2776 def __unicode__(self):
2738 return u'<%s => %s >' % (self.user, self.repository)
2777 return u'<%s => %s >' % (self.user, self.repository)
2739
2778
2740
2779
2741 class UserUserGroupToPerm(Base, BaseModel):
2780 class UserUserGroupToPerm(Base, BaseModel):
2742 __tablename__ = 'user_user_group_to_perm'
2781 __tablename__ = 'user_user_group_to_perm'
2743 __table_args__ = (
2782 __table_args__ = (
2744 UniqueConstraint('user_id', 'user_group_id', 'permission_id'),
2783 UniqueConstraint('user_id', 'user_group_id', 'permission_id'),
2745 {'extend_existing': True, 'mysql_engine': 'InnoDB',
2784 {'extend_existing': True, 'mysql_engine': 'InnoDB',
2746 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
2785 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
2747 )
2786 )
2748 user_user_group_to_perm_id = Column("user_user_group_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
2787 user_user_group_to_perm_id = Column("user_user_group_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
2749 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=None, default=None)
2788 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=None, default=None)
2750 permission_id = Column("permission_id", Integer(), ForeignKey('permissions.permission_id'), nullable=False, unique=None, default=None)
2789 permission_id = Column("permission_id", Integer(), ForeignKey('permissions.permission_id'), nullable=False, unique=None, default=None)
2751 user_group_id = Column("user_group_id", Integer(), ForeignKey('users_groups.users_group_id'), nullable=False, unique=None, default=None)
2790 user_group_id = Column("user_group_id", Integer(), ForeignKey('users_groups.users_group_id'), nullable=False, unique=None, default=None)
2752
2791
2753 user = relationship('User')
2792 user = relationship('User')
2754 user_group = relationship('UserGroup')
2793 user_group = relationship('UserGroup')
2755 permission = relationship('Permission')
2794 permission = relationship('Permission')
2756
2795
2757 @classmethod
2796 @classmethod
2758 def create(cls, user, user_group, permission):
2797 def create(cls, user, user_group, permission):
2759 n = cls()
2798 n = cls()
2760 n.user = user
2799 n.user = user
2761 n.user_group = user_group
2800 n.user_group = user_group
2762 n.permission = permission
2801 n.permission = permission
2763 Session().add(n)
2802 Session().add(n)
2764 return n
2803 return n
2765
2804
2766 def __unicode__(self):
2805 def __unicode__(self):
2767 return u'<%s => %s >' % (self.user, self.user_group)
2806 return u'<%s => %s >' % (self.user, self.user_group)
2768
2807
2769
2808
2770 class UserToPerm(Base, BaseModel):
2809 class UserToPerm(Base, BaseModel):
2771 __tablename__ = 'user_to_perm'
2810 __tablename__ = 'user_to_perm'
2772 __table_args__ = (
2811 __table_args__ = (
2773 UniqueConstraint('user_id', 'permission_id'),
2812 UniqueConstraint('user_id', 'permission_id'),
2774 {'extend_existing': True, 'mysql_engine': 'InnoDB',
2813 {'extend_existing': True, 'mysql_engine': 'InnoDB',
2775 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
2814 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
2776 )
2815 )
2777 user_to_perm_id = Column("user_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
2816 user_to_perm_id = Column("user_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
2778 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=None, default=None)
2817 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=None, default=None)
2779 permission_id = Column("permission_id", Integer(), ForeignKey('permissions.permission_id'), nullable=False, unique=None, default=None)
2818 permission_id = Column("permission_id", Integer(), ForeignKey('permissions.permission_id'), nullable=False, unique=None, default=None)
2780
2819
2781 user = relationship('User')
2820 user = relationship('User')
2782 permission = relationship('Permission', lazy='joined')
2821 permission = relationship('Permission', lazy='joined')
2783
2822
2784 def __unicode__(self):
2823 def __unicode__(self):
2785 return u'<%s => %s >' % (self.user, self.permission)
2824 return u'<%s => %s >' % (self.user, self.permission)
2786
2825
2787
2826
2788 class UserGroupRepoToPerm(Base, BaseModel):
2827 class UserGroupRepoToPerm(Base, BaseModel):
2789 __tablename__ = 'users_group_repo_to_perm'
2828 __tablename__ = 'users_group_repo_to_perm'
2790 __table_args__ = (
2829 __table_args__ = (
2791 UniqueConstraint('repository_id', 'users_group_id', 'permission_id'),
2830 UniqueConstraint('repository_id', 'users_group_id', 'permission_id'),
2792 {'extend_existing': True, 'mysql_engine': 'InnoDB',
2831 {'extend_existing': True, 'mysql_engine': 'InnoDB',
2793 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
2832 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
2794 )
2833 )
2795 users_group_to_perm_id = Column("users_group_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
2834 users_group_to_perm_id = Column("users_group_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
2796 users_group_id = Column("users_group_id", Integer(), ForeignKey('users_groups.users_group_id'), nullable=False, unique=None, default=None)
2835 users_group_id = Column("users_group_id", Integer(), ForeignKey('users_groups.users_group_id'), nullable=False, unique=None, default=None)
2797 permission_id = Column("permission_id", Integer(), ForeignKey('permissions.permission_id'), nullable=False, unique=None, default=None)
2836 permission_id = Column("permission_id", Integer(), ForeignKey('permissions.permission_id'), nullable=False, unique=None, default=None)
2798 repository_id = Column("repository_id", Integer(), ForeignKey('repositories.repo_id'), nullable=False, unique=None, default=None)
2837 repository_id = Column("repository_id", Integer(), ForeignKey('repositories.repo_id'), nullable=False, unique=None, default=None)
2799
2838
2800 users_group = relationship('UserGroup')
2839 users_group = relationship('UserGroup')
2801 permission = relationship('Permission')
2840 permission = relationship('Permission')
2802 repository = relationship('Repository')
2841 repository = relationship('Repository')
2803
2842
2804 @classmethod
2843 @classmethod
2805 def create(cls, users_group, repository, permission):
2844 def create(cls, users_group, repository, permission):
2806 n = cls()
2845 n = cls()
2807 n.users_group = users_group
2846 n.users_group = users_group
2808 n.repository = repository
2847 n.repository = repository
2809 n.permission = permission
2848 n.permission = permission
2810 Session().add(n)
2849 Session().add(n)
2811 return n
2850 return n
2812
2851
2813 def __unicode__(self):
2852 def __unicode__(self):
2814 return u'<UserGroupRepoToPerm:%s => %s >' % (self.users_group, self.repository)
2853 return u'<UserGroupRepoToPerm:%s => %s >' % (self.users_group, self.repository)
2815
2854
2816
2855
2817 class UserGroupUserGroupToPerm(Base, BaseModel):
2856 class UserGroupUserGroupToPerm(Base, BaseModel):
2818 __tablename__ = 'user_group_user_group_to_perm'
2857 __tablename__ = 'user_group_user_group_to_perm'
2819 __table_args__ = (
2858 __table_args__ = (
2820 UniqueConstraint('target_user_group_id', 'user_group_id', 'permission_id'),
2859 UniqueConstraint('target_user_group_id', 'user_group_id', 'permission_id'),
2821 CheckConstraint('target_user_group_id != user_group_id'),
2860 CheckConstraint('target_user_group_id != user_group_id'),
2822 {'extend_existing': True, 'mysql_engine': 'InnoDB',
2861 {'extend_existing': True, 'mysql_engine': 'InnoDB',
2823 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
2862 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
2824 )
2863 )
2825 user_group_user_group_to_perm_id = Column("user_group_user_group_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
2864 user_group_user_group_to_perm_id = Column("user_group_user_group_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
2826 target_user_group_id = Column("target_user_group_id", Integer(), ForeignKey('users_groups.users_group_id'), nullable=False, unique=None, default=None)
2865 target_user_group_id = Column("target_user_group_id", Integer(), ForeignKey('users_groups.users_group_id'), nullable=False, unique=None, default=None)
2827 permission_id = Column("permission_id", Integer(), ForeignKey('permissions.permission_id'), nullable=False, unique=None, default=None)
2866 permission_id = Column("permission_id", Integer(), ForeignKey('permissions.permission_id'), nullable=False, unique=None, default=None)
2828 user_group_id = Column("user_group_id", Integer(), ForeignKey('users_groups.users_group_id'), nullable=False, unique=None, default=None)
2867 user_group_id = Column("user_group_id", Integer(), ForeignKey('users_groups.users_group_id'), nullable=False, unique=None, default=None)
2829
2868
2830 target_user_group = relationship('UserGroup', primaryjoin='UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id')
2869 target_user_group = relationship('UserGroup', primaryjoin='UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id')
2831 user_group = relationship('UserGroup', primaryjoin='UserGroupUserGroupToPerm.user_group_id==UserGroup.users_group_id')
2870 user_group = relationship('UserGroup', primaryjoin='UserGroupUserGroupToPerm.user_group_id==UserGroup.users_group_id')
2832 permission = relationship('Permission')
2871 permission = relationship('Permission')
2833
2872
2834 @classmethod
2873 @classmethod
2835 def create(cls, target_user_group, user_group, permission):
2874 def create(cls, target_user_group, user_group, permission):
2836 n = cls()
2875 n = cls()
2837 n.target_user_group = target_user_group
2876 n.target_user_group = target_user_group
2838 n.user_group = user_group
2877 n.user_group = user_group
2839 n.permission = permission
2878 n.permission = permission
2840 Session().add(n)
2879 Session().add(n)
2841 return n
2880 return n
2842
2881
2843 def __unicode__(self):
2882 def __unicode__(self):
2844 return u'<UserGroupUserGroup:%s => %s >' % (self.target_user_group, self.user_group)
2883 return u'<UserGroupUserGroup:%s => %s >' % (self.target_user_group, self.user_group)
2845
2884
2846
2885
2847 class UserGroupToPerm(Base, BaseModel):
2886 class UserGroupToPerm(Base, BaseModel):
2848 __tablename__ = 'users_group_to_perm'
2887 __tablename__ = 'users_group_to_perm'
2849 __table_args__ = (
2888 __table_args__ = (
2850 UniqueConstraint('users_group_id', 'permission_id',),
2889 UniqueConstraint('users_group_id', 'permission_id',),
2851 {'extend_existing': True, 'mysql_engine': 'InnoDB',
2890 {'extend_existing': True, 'mysql_engine': 'InnoDB',
2852 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
2891 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
2853 )
2892 )
2854 users_group_to_perm_id = Column("users_group_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
2893 users_group_to_perm_id = Column("users_group_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
2855 users_group_id = Column("users_group_id", Integer(), ForeignKey('users_groups.users_group_id'), nullable=False, unique=None, default=None)
2894 users_group_id = Column("users_group_id", Integer(), ForeignKey('users_groups.users_group_id'), nullable=False, unique=None, default=None)
2856 permission_id = Column("permission_id", Integer(), ForeignKey('permissions.permission_id'), nullable=False, unique=None, default=None)
2895 permission_id = Column("permission_id", Integer(), ForeignKey('permissions.permission_id'), nullable=False, unique=None, default=None)
2857
2896
2858 users_group = relationship('UserGroup')
2897 users_group = relationship('UserGroup')
2859 permission = relationship('Permission')
2898 permission = relationship('Permission')
2860
2899
2861
2900
2862 class UserRepoGroupToPerm(Base, BaseModel):
2901 class UserRepoGroupToPerm(Base, BaseModel):
2863 __tablename__ = 'user_repo_group_to_perm'
2902 __tablename__ = 'user_repo_group_to_perm'
2864 __table_args__ = (
2903 __table_args__ = (
2865 UniqueConstraint('user_id', 'group_id', 'permission_id'),
2904 UniqueConstraint('user_id', 'group_id', 'permission_id'),
2866 {'extend_existing': True, 'mysql_engine': 'InnoDB',
2905 {'extend_existing': True, 'mysql_engine': 'InnoDB',
2867 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
2906 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
2868 )
2907 )
2869
2908
2870 group_to_perm_id = Column("group_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
2909 group_to_perm_id = Column("group_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
2871 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=None, default=None)
2910 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=None, default=None)
2872 group_id = Column("group_id", Integer(), ForeignKey('groups.group_id'), nullable=False, unique=None, default=None)
2911 group_id = Column("group_id", Integer(), ForeignKey('groups.group_id'), nullable=False, unique=None, default=None)
2873 permission_id = Column("permission_id", Integer(), ForeignKey('permissions.permission_id'), nullable=False, unique=None, default=None)
2912 permission_id = Column("permission_id", Integer(), ForeignKey('permissions.permission_id'), nullable=False, unique=None, default=None)
2874
2913
2875 user = relationship('User')
2914 user = relationship('User')
2876 group = relationship('RepoGroup')
2915 group = relationship('RepoGroup')
2877 permission = relationship('Permission')
2916 permission = relationship('Permission')
2878
2917
2879 @classmethod
2918 @classmethod
2880 def create(cls, user, repository_group, permission):
2919 def create(cls, user, repository_group, permission):
2881 n = cls()
2920 n = cls()
2882 n.user = user
2921 n.user = user
2883 n.group = repository_group
2922 n.group = repository_group
2884 n.permission = permission
2923 n.permission = permission
2885 Session().add(n)
2924 Session().add(n)
2886 return n
2925 return n
2887
2926
2888
2927
2889 class UserGroupRepoGroupToPerm(Base, BaseModel):
2928 class UserGroupRepoGroupToPerm(Base, BaseModel):
2890 __tablename__ = 'users_group_repo_group_to_perm'
2929 __tablename__ = 'users_group_repo_group_to_perm'
2891 __table_args__ = (
2930 __table_args__ = (
2892 UniqueConstraint('users_group_id', 'group_id'),
2931 UniqueConstraint('users_group_id', 'group_id'),
2893 {'extend_existing': True, 'mysql_engine': 'InnoDB',
2932 {'extend_existing': True, 'mysql_engine': 'InnoDB',
2894 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
2933 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
2895 )
2934 )
2896
2935
2897 users_group_repo_group_to_perm_id = Column("users_group_repo_group_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
2936 users_group_repo_group_to_perm_id = Column("users_group_repo_group_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
2898 users_group_id = Column("users_group_id", Integer(), ForeignKey('users_groups.users_group_id'), nullable=False, unique=None, default=None)
2937 users_group_id = Column("users_group_id", Integer(), ForeignKey('users_groups.users_group_id'), nullable=False, unique=None, default=None)
2899 group_id = Column("group_id", Integer(), ForeignKey('groups.group_id'), nullable=False, unique=None, default=None)
2938 group_id = Column("group_id", Integer(), ForeignKey('groups.group_id'), nullable=False, unique=None, default=None)
2900 permission_id = Column("permission_id", Integer(), ForeignKey('permissions.permission_id'), nullable=False, unique=None, default=None)
2939 permission_id = Column("permission_id", Integer(), ForeignKey('permissions.permission_id'), nullable=False, unique=None, default=None)
2901
2940
2902 users_group = relationship('UserGroup')
2941 users_group = relationship('UserGroup')
2903 permission = relationship('Permission')
2942 permission = relationship('Permission')
2904 group = relationship('RepoGroup')
2943 group = relationship('RepoGroup')
2905
2944
2906 @classmethod
2945 @classmethod
2907 def create(cls, user_group, repository_group, permission):
2946 def create(cls, user_group, repository_group, permission):
2908 n = cls()
2947 n = cls()
2909 n.users_group = user_group
2948 n.users_group = user_group
2910 n.group = repository_group
2949 n.group = repository_group
2911 n.permission = permission
2950 n.permission = permission
2912 Session().add(n)
2951 Session().add(n)
2913 return n
2952 return n
2914
2953
2915 def __unicode__(self):
2954 def __unicode__(self):
2916 return u'<UserGroupRepoGroupToPerm:%s => %s >' % (self.users_group, self.group)
2955 return u'<UserGroupRepoGroupToPerm:%s => %s >' % (self.users_group, self.group)
2917
2956
2918
2957
2919 class Statistics(Base, BaseModel):
2958 class Statistics(Base, BaseModel):
2920 __tablename__ = 'statistics'
2959 __tablename__ = 'statistics'
2921 __table_args__ = (
2960 __table_args__ = (
2922 {'extend_existing': True, 'mysql_engine': 'InnoDB',
2961 {'extend_existing': True, 'mysql_engine': 'InnoDB',
2923 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
2962 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
2924 )
2963 )
2925 stat_id = Column("stat_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
2964 stat_id = Column("stat_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
2926 repository_id = Column("repository_id", Integer(), ForeignKey('repositories.repo_id'), nullable=False, unique=True, default=None)
2965 repository_id = Column("repository_id", Integer(), ForeignKey('repositories.repo_id'), nullable=False, unique=True, default=None)
2927 stat_on_revision = Column("stat_on_revision", Integer(), nullable=False)
2966 stat_on_revision = Column("stat_on_revision", Integer(), nullable=False)
2928 commit_activity = Column("commit_activity", LargeBinary(1000000), nullable=False)#JSON data
2967 commit_activity = Column("commit_activity", LargeBinary(1000000), nullable=False)#JSON data
2929 commit_activity_combined = Column("commit_activity_combined", LargeBinary(), nullable=False)#JSON data
2968 commit_activity_combined = Column("commit_activity_combined", LargeBinary(), nullable=False)#JSON data
2930 languages = Column("languages", LargeBinary(1000000), nullable=False)#JSON data
2969 languages = Column("languages", LargeBinary(1000000), nullable=False)#JSON data
2931
2970
2932 repository = relationship('Repository', single_parent=True)
2971 repository = relationship('Repository', single_parent=True)
2933
2972
2934
2973
2935 class UserFollowing(Base, BaseModel):
2974 class UserFollowing(Base, BaseModel):
2936 __tablename__ = 'user_followings'
2975 __tablename__ = 'user_followings'
2937 __table_args__ = (
2976 __table_args__ = (
2938 UniqueConstraint('user_id', 'follows_repository_id'),
2977 UniqueConstraint('user_id', 'follows_repository_id'),
2939 UniqueConstraint('user_id', 'follows_user_id'),
2978 UniqueConstraint('user_id', 'follows_user_id'),
2940 {'extend_existing': True, 'mysql_engine': 'InnoDB',
2979 {'extend_existing': True, 'mysql_engine': 'InnoDB',
2941 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
2980 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
2942 )
2981 )
2943
2982
2944 user_following_id = Column("user_following_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
2983 user_following_id = Column("user_following_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
2945 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=None, default=None)
2984 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=None, default=None)
2946 follows_repo_id = Column("follows_repository_id", Integer(), ForeignKey('repositories.repo_id'), nullable=True, unique=None, default=None)
2985 follows_repo_id = Column("follows_repository_id", Integer(), ForeignKey('repositories.repo_id'), nullable=True, unique=None, default=None)
2947 follows_user_id = Column("follows_user_id", Integer(), ForeignKey('users.user_id'), nullable=True, unique=None, default=None)
2986 follows_user_id = Column("follows_user_id", Integer(), ForeignKey('users.user_id'), nullable=True, unique=None, default=None)
2948 follows_from = Column('follows_from', DateTime(timezone=False), nullable=True, unique=None, default=datetime.datetime.now)
2987 follows_from = Column('follows_from', DateTime(timezone=False), nullable=True, unique=None, default=datetime.datetime.now)
2949
2988
2950 user = relationship('User', primaryjoin='User.user_id==UserFollowing.user_id')
2989 user = relationship('User', primaryjoin='User.user_id==UserFollowing.user_id')
2951
2990
2952 follows_user = relationship('User', primaryjoin='User.user_id==UserFollowing.follows_user_id')
2991 follows_user = relationship('User', primaryjoin='User.user_id==UserFollowing.follows_user_id')
2953 follows_repository = relationship('Repository', order_by='Repository.repo_name')
2992 follows_repository = relationship('Repository', order_by='Repository.repo_name')
2954
2993
2955 @classmethod
2994 @classmethod
2956 def get_repo_followers(cls, repo_id):
2995 def get_repo_followers(cls, repo_id):
2957 return cls.query().filter(cls.follows_repo_id == repo_id)
2996 return cls.query().filter(cls.follows_repo_id == repo_id)
2958
2997
2959
2998
2960 class CacheKey(Base, BaseModel):
2999 class CacheKey(Base, BaseModel):
2961 __tablename__ = 'cache_invalidation'
3000 __tablename__ = 'cache_invalidation'
2962 __table_args__ = (
3001 __table_args__ = (
2963 UniqueConstraint('cache_key'),
3002 UniqueConstraint('cache_key'),
2964 Index('key_idx', 'cache_key'),
3003 Index('key_idx', 'cache_key'),
2965 {'extend_existing': True, 'mysql_engine': 'InnoDB',
3004 {'extend_existing': True, 'mysql_engine': 'InnoDB',
2966 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
3005 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
2967 )
3006 )
2968 CACHE_TYPE_ATOM = 'ATOM'
3007 CACHE_TYPE_ATOM = 'ATOM'
2969 CACHE_TYPE_RSS = 'RSS'
3008 CACHE_TYPE_RSS = 'RSS'
2970 CACHE_TYPE_README = 'README'
3009 CACHE_TYPE_README = 'README'
2971
3010
2972 cache_id = Column("cache_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
3011 cache_id = Column("cache_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
2973 cache_key = Column("cache_key", String(255), nullable=True, unique=None, default=None)
3012 cache_key = Column("cache_key", String(255), nullable=True, unique=None, default=None)
2974 cache_args = Column("cache_args", String(255), nullable=True, unique=None, default=None)
3013 cache_args = Column("cache_args", String(255), nullable=True, unique=None, default=None)
2975 cache_active = Column("cache_active", Boolean(), nullable=True, unique=None, default=False)
3014 cache_active = Column("cache_active", Boolean(), nullable=True, unique=None, default=False)
2976
3015
2977 def __init__(self, cache_key, cache_args=''):
3016 def __init__(self, cache_key, cache_args=''):
2978 self.cache_key = cache_key
3017 self.cache_key = cache_key
2979 self.cache_args = cache_args
3018 self.cache_args = cache_args
2980 self.cache_active = False
3019 self.cache_active = False
2981
3020
2982 def __unicode__(self):
3021 def __unicode__(self):
2983 return u"<%s('%s:%s[%s]')>" % (
3022 return u"<%s('%s:%s[%s]')>" % (
2984 self.__class__.__name__,
3023 self.__class__.__name__,
2985 self.cache_id, self.cache_key, self.cache_active)
3024 self.cache_id, self.cache_key, self.cache_active)
2986
3025
2987 def _cache_key_partition(self):
3026 def _cache_key_partition(self):
2988 prefix, repo_name, suffix = self.cache_key.partition(self.cache_args)
3027 prefix, repo_name, suffix = self.cache_key.partition(self.cache_args)
2989 return prefix, repo_name, suffix
3028 return prefix, repo_name, suffix
2990
3029
2991 def get_prefix(self):
3030 def get_prefix(self):
2992 """
3031 """
2993 Try to extract prefix from existing cache key. The key could consist
3032 Try to extract prefix from existing cache key. The key could consist
2994 of prefix, repo_name, suffix
3033 of prefix, repo_name, suffix
2995 """
3034 """
2996 # this returns prefix, repo_name, suffix
3035 # this returns prefix, repo_name, suffix
2997 return self._cache_key_partition()[0]
3036 return self._cache_key_partition()[0]
2998
3037
2999 def get_suffix(self):
3038 def get_suffix(self):
3000 """
3039 """
3001 get suffix that might have been used in _get_cache_key to
3040 get suffix that might have been used in _get_cache_key to
3002 generate self.cache_key. Only used for informational purposes
3041 generate self.cache_key. Only used for informational purposes
3003 in repo_edit.mako.
3042 in repo_edit.mako.
3004 """
3043 """
3005 # prefix, repo_name, suffix
3044 # prefix, repo_name, suffix
3006 return self._cache_key_partition()[2]
3045 return self._cache_key_partition()[2]
3007
3046
3008 @classmethod
3047 @classmethod
3009 def delete_all_cache(cls):
3048 def delete_all_cache(cls):
3010 """
3049 """
3011 Delete all cache keys from database.
3050 Delete all cache keys from database.
3012 Should only be run when all instances are down and all entries
3051 Should only be run when all instances are down and all entries
3013 thus stale.
3052 thus stale.
3014 """
3053 """
3015 cls.query().delete()
3054 cls.query().delete()
3016 Session().commit()
3055 Session().commit()
3017
3056
3018 @classmethod
3057 @classmethod
3019 def get_cache_key(cls, repo_name, cache_type):
3058 def get_cache_key(cls, repo_name, cache_type):
3020 """
3059 """
3021
3060
3022 Generate a cache key for this process of RhodeCode instance.
3061 Generate a cache key for this process of RhodeCode instance.
3023 Prefix most likely will be process id or maybe explicitly set
3062 Prefix most likely will be process id or maybe explicitly set
3024 instance_id from .ini file.
3063 instance_id from .ini file.
3025 """
3064 """
3026 import rhodecode
3065 import rhodecode
3027 prefix = safe_unicode(rhodecode.CONFIG.get('instance_id') or '')
3066 prefix = safe_unicode(rhodecode.CONFIG.get('instance_id') or '')
3028
3067
3029 repo_as_unicode = safe_unicode(repo_name)
3068 repo_as_unicode = safe_unicode(repo_name)
3030 key = u'{}_{}'.format(repo_as_unicode, cache_type) \
3069 key = u'{}_{}'.format(repo_as_unicode, cache_type) \
3031 if cache_type else repo_as_unicode
3070 if cache_type else repo_as_unicode
3032
3071
3033 return u'{}{}'.format(prefix, key)
3072 return u'{}{}'.format(prefix, key)
3034
3073
3035 @classmethod
3074 @classmethod
3036 def set_invalidate(cls, repo_name, delete=False):
3075 def set_invalidate(cls, repo_name, delete=False):
3037 """
3076 """
3038 Mark all caches of a repo as invalid in the database.
3077 Mark all caches of a repo as invalid in the database.
3039 """
3078 """
3040
3079
3041 try:
3080 try:
3042 qry = Session().query(cls).filter(cls.cache_args == repo_name)
3081 qry = Session().query(cls).filter(cls.cache_args == repo_name)
3043 if delete:
3082 if delete:
3044 log.debug('cache objects deleted for repo %s',
3083 log.debug('cache objects deleted for repo %s',
3045 safe_str(repo_name))
3084 safe_str(repo_name))
3046 qry.delete()
3085 qry.delete()
3047 else:
3086 else:
3048 log.debug('cache objects marked as invalid for repo %s',
3087 log.debug('cache objects marked as invalid for repo %s',
3049 safe_str(repo_name))
3088 safe_str(repo_name))
3050 qry.update({"cache_active": False})
3089 qry.update({"cache_active": False})
3051
3090
3052 Session().commit()
3091 Session().commit()
3053 except Exception:
3092 except Exception:
3054 log.exception(
3093 log.exception(
3055 'Cache key invalidation failed for repository %s',
3094 'Cache key invalidation failed for repository %s',
3056 safe_str(repo_name))
3095 safe_str(repo_name))
3057 Session().rollback()
3096 Session().rollback()
3058
3097
3059 @classmethod
3098 @classmethod
3060 def get_active_cache(cls, cache_key):
3099 def get_active_cache(cls, cache_key):
3061 inv_obj = cls.query().filter(cls.cache_key == cache_key).scalar()
3100 inv_obj = cls.query().filter(cls.cache_key == cache_key).scalar()
3062 if inv_obj:
3101 if inv_obj:
3063 return inv_obj
3102 return inv_obj
3064 return None
3103 return None
3065
3104
3066 @classmethod
3105 @classmethod
3067 def repo_context_cache(cls, compute_func, repo_name, cache_type,
3106 def repo_context_cache(cls, compute_func, repo_name, cache_type,
3068 thread_scoped=False):
3107 thread_scoped=False):
3069 """
3108 """
3070 @cache_region('long_term')
3109 @cache_region('long_term')
3071 def _heavy_calculation(cache_key):
3110 def _heavy_calculation(cache_key):
3072 return 'result'
3111 return 'result'
3073
3112
3074 cache_context = CacheKey.repo_context_cache(
3113 cache_context = CacheKey.repo_context_cache(
3075 _heavy_calculation, repo_name, cache_type)
3114 _heavy_calculation, repo_name, cache_type)
3076
3115
3077 with cache_context as context:
3116 with cache_context as context:
3078 context.invalidate()
3117 context.invalidate()
3079 computed = context.compute()
3118 computed = context.compute()
3080
3119
3081 assert computed == 'result'
3120 assert computed == 'result'
3082 """
3121 """
3083 from rhodecode.lib import caches
3122 from rhodecode.lib import caches
3084 return caches.InvalidationContext(
3123 return caches.InvalidationContext(
3085 compute_func, repo_name, cache_type, thread_scoped=thread_scoped)
3124 compute_func, repo_name, cache_type, thread_scoped=thread_scoped)
3086
3125
3087
3126
3088 class ChangesetComment(Base, BaseModel):
3127 class ChangesetComment(Base, BaseModel):
3089 __tablename__ = 'changeset_comments'
3128 __tablename__ = 'changeset_comments'
3090 __table_args__ = (
3129 __table_args__ = (
3091 Index('cc_revision_idx', 'revision'),
3130 Index('cc_revision_idx', 'revision'),
3092 {'extend_existing': True, 'mysql_engine': 'InnoDB',
3131 {'extend_existing': True, 'mysql_engine': 'InnoDB',
3093 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
3132 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
3094 )
3133 )
3095
3134
3096 COMMENT_OUTDATED = u'comment_outdated'
3135 COMMENT_OUTDATED = u'comment_outdated'
3097 COMMENT_TYPE_NOTE = u'note'
3136 COMMENT_TYPE_NOTE = u'note'
3098 COMMENT_TYPE_TODO = u'todo'
3137 COMMENT_TYPE_TODO = u'todo'
3099 COMMENT_TYPES = [COMMENT_TYPE_NOTE, COMMENT_TYPE_TODO]
3138 COMMENT_TYPES = [COMMENT_TYPE_NOTE, COMMENT_TYPE_TODO]
3100
3139
3101 comment_id = Column('comment_id', Integer(), nullable=False, primary_key=True)
3140 comment_id = Column('comment_id', Integer(), nullable=False, primary_key=True)
3102 repo_id = Column('repo_id', Integer(), ForeignKey('repositories.repo_id'), nullable=False)
3141 repo_id = Column('repo_id', Integer(), ForeignKey('repositories.repo_id'), nullable=False)
3103 revision = Column('revision', String(40), nullable=True)
3142 revision = Column('revision', String(40), nullable=True)
3104 pull_request_id = Column("pull_request_id", Integer(), ForeignKey('pull_requests.pull_request_id'), nullable=True)
3143 pull_request_id = Column("pull_request_id", Integer(), ForeignKey('pull_requests.pull_request_id'), nullable=True)
3105 pull_request_version_id = Column("pull_request_version_id", Integer(), ForeignKey('pull_request_versions.pull_request_version_id'), nullable=True)
3144 pull_request_version_id = Column("pull_request_version_id", Integer(), ForeignKey('pull_request_versions.pull_request_version_id'), nullable=True)
3106 line_no = Column('line_no', Unicode(10), nullable=True)
3145 line_no = Column('line_no', Unicode(10), nullable=True)
3107 hl_lines = Column('hl_lines', Unicode(512), nullable=True)
3146 hl_lines = Column('hl_lines', Unicode(512), nullable=True)
3108 f_path = Column('f_path', Unicode(1000), nullable=True)
3147 f_path = Column('f_path', Unicode(1000), nullable=True)
3109 user_id = Column('user_id', Integer(), ForeignKey('users.user_id'), nullable=False)
3148 user_id = Column('user_id', Integer(), ForeignKey('users.user_id'), nullable=False)
3110 text = Column('text', UnicodeText().with_variant(UnicodeText(25000), 'mysql'), nullable=False)
3149 text = Column('text', UnicodeText().with_variant(UnicodeText(25000), 'mysql'), nullable=False)
3111 created_on = Column('created_on', DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
3150 created_on = Column('created_on', DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
3112 modified_at = Column('modified_at', DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
3151 modified_at = Column('modified_at', DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
3113 renderer = Column('renderer', Unicode(64), nullable=True)
3152 renderer = Column('renderer', Unicode(64), nullable=True)
3114 display_state = Column('display_state', Unicode(128), nullable=True)
3153 display_state = Column('display_state', Unicode(128), nullable=True)
3115
3154
3116 comment_type = Column('comment_type', Unicode(128), nullable=True, default=COMMENT_TYPE_NOTE)
3155 comment_type = Column('comment_type', Unicode(128), nullable=True, default=COMMENT_TYPE_NOTE)
3117 resolved_comment_id = Column('resolved_comment_id', Integer(), ForeignKey('changeset_comments.comment_id'), nullable=True)
3156 resolved_comment_id = Column('resolved_comment_id', Integer(), ForeignKey('changeset_comments.comment_id'), nullable=True)
3118 resolved_comment = relationship('ChangesetComment', remote_side=comment_id, backref='resolved_by')
3157 resolved_comment = relationship('ChangesetComment', remote_side=comment_id, backref='resolved_by')
3119 author = relationship('User', lazy='joined')
3158 author = relationship('User', lazy='joined')
3120 repo = relationship('Repository')
3159 repo = relationship('Repository')
3121 status_change = relationship('ChangesetStatus', cascade="all, delete, delete-orphan", lazy='joined')
3160 status_change = relationship('ChangesetStatus', cascade="all, delete, delete-orphan", lazy='joined')
3122 pull_request = relationship('PullRequest', lazy='joined')
3161 pull_request = relationship('PullRequest', lazy='joined')
3123 pull_request_version = relationship('PullRequestVersion')
3162 pull_request_version = relationship('PullRequestVersion')
3124
3163
3125 @classmethod
3164 @classmethod
3126 def get_users(cls, revision=None, pull_request_id=None):
3165 def get_users(cls, revision=None, pull_request_id=None):
3127 """
3166 """
3128 Returns user associated with this ChangesetComment. ie those
3167 Returns user associated with this ChangesetComment. ie those
3129 who actually commented
3168 who actually commented
3130
3169
3131 :param cls:
3170 :param cls:
3132 :param revision:
3171 :param revision:
3133 """
3172 """
3134 q = Session().query(User)\
3173 q = Session().query(User)\
3135 .join(ChangesetComment.author)
3174 .join(ChangesetComment.author)
3136 if revision:
3175 if revision:
3137 q = q.filter(cls.revision == revision)
3176 q = q.filter(cls.revision == revision)
3138 elif pull_request_id:
3177 elif pull_request_id:
3139 q = q.filter(cls.pull_request_id == pull_request_id)
3178 q = q.filter(cls.pull_request_id == pull_request_id)
3140 return q.all()
3179 return q.all()
3141
3180
3142 @classmethod
3181 @classmethod
3143 def get_index_from_version(cls, pr_version, versions):
3182 def get_index_from_version(cls, pr_version, versions):
3144 num_versions = [x.pull_request_version_id for x in versions]
3183 num_versions = [x.pull_request_version_id for x in versions]
3145 try:
3184 try:
3146 return num_versions.index(pr_version) +1
3185 return num_versions.index(pr_version) +1
3147 except (IndexError, ValueError):
3186 except (IndexError, ValueError):
3148 return
3187 return
3149
3188
3150 @property
3189 @property
3151 def outdated(self):
3190 def outdated(self):
3152 return self.display_state == self.COMMENT_OUTDATED
3191 return self.display_state == self.COMMENT_OUTDATED
3153
3192
3154 def outdated_at_version(self, version):
3193 def outdated_at_version(self, version):
3155 """
3194 """
3156 Checks if comment is outdated for given pull request version
3195 Checks if comment is outdated for given pull request version
3157 """
3196 """
3158 return self.outdated and self.pull_request_version_id != version
3197 return self.outdated and self.pull_request_version_id != version
3159
3198
3160 def older_than_version(self, version):
3199 def older_than_version(self, version):
3161 """
3200 """
3162 Checks if comment is made from previous version than given
3201 Checks if comment is made from previous version than given
3163 """
3202 """
3164 if version is None:
3203 if version is None:
3165 return self.pull_request_version_id is not None
3204 return self.pull_request_version_id is not None
3166
3205
3167 return self.pull_request_version_id < version
3206 return self.pull_request_version_id < version
3168
3207
3169 @property
3208 @property
3170 def resolved(self):
3209 def resolved(self):
3171 return self.resolved_by[0] if self.resolved_by else None
3210 return self.resolved_by[0] if self.resolved_by else None
3172
3211
3173 @property
3212 @property
3174 def is_todo(self):
3213 def is_todo(self):
3175 return self.comment_type == self.COMMENT_TYPE_TODO
3214 return self.comment_type == self.COMMENT_TYPE_TODO
3176
3215
3177 @property
3216 @property
3178 def is_inline(self):
3217 def is_inline(self):
3179 return self.line_no and self.f_path
3218 return self.line_no and self.f_path
3180
3219
3181 def get_index_version(self, versions):
3220 def get_index_version(self, versions):
3182 return self.get_index_from_version(
3221 return self.get_index_from_version(
3183 self.pull_request_version_id, versions)
3222 self.pull_request_version_id, versions)
3184
3223
3185 def __repr__(self):
3224 def __repr__(self):
3186 if self.comment_id:
3225 if self.comment_id:
3187 return '<DB:Comment #%s>' % self.comment_id
3226 return '<DB:Comment #%s>' % self.comment_id
3188 else:
3227 else:
3189 return '<DB:Comment at %#x>' % id(self)
3228 return '<DB:Comment at %#x>' % id(self)
3190
3229
3191 def get_api_data(self):
3230 def get_api_data(self):
3192 comment = self
3231 comment = self
3193 data = {
3232 data = {
3194 'comment_id': comment.comment_id,
3233 'comment_id': comment.comment_id,
3195 'comment_type': comment.comment_type,
3234 'comment_type': comment.comment_type,
3196 'comment_text': comment.text,
3235 'comment_text': comment.text,
3197 'comment_status': comment.status_change,
3236 'comment_status': comment.status_change,
3198 'comment_f_path': comment.f_path,
3237 'comment_f_path': comment.f_path,
3199 'comment_lineno': comment.line_no,
3238 'comment_lineno': comment.line_no,
3200 'comment_author': comment.author,
3239 'comment_author': comment.author,
3201 'comment_created_on': comment.created_on
3240 'comment_created_on': comment.created_on
3202 }
3241 }
3203 return data
3242 return data
3204
3243
3205 def __json__(self):
3244 def __json__(self):
3206 data = dict()
3245 data = dict()
3207 data.update(self.get_api_data())
3246 data.update(self.get_api_data())
3208 return data
3247 return data
3209
3248
3210
3249
3211 class ChangesetStatus(Base, BaseModel):
3250 class ChangesetStatus(Base, BaseModel):
3212 __tablename__ = 'changeset_statuses'
3251 __tablename__ = 'changeset_statuses'
3213 __table_args__ = (
3252 __table_args__ = (
3214 Index('cs_revision_idx', 'revision'),
3253 Index('cs_revision_idx', 'revision'),
3215 Index('cs_version_idx', 'version'),
3254 Index('cs_version_idx', 'version'),
3216 UniqueConstraint('repo_id', 'revision', 'version'),
3255 UniqueConstraint('repo_id', 'revision', 'version'),
3217 {'extend_existing': True, 'mysql_engine': 'InnoDB',
3256 {'extend_existing': True, 'mysql_engine': 'InnoDB',
3218 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
3257 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
3219 )
3258 )
3220 STATUS_NOT_REVIEWED = DEFAULT = 'not_reviewed'
3259 STATUS_NOT_REVIEWED = DEFAULT = 'not_reviewed'
3221 STATUS_APPROVED = 'approved'
3260 STATUS_APPROVED = 'approved'
3222 STATUS_REJECTED = 'rejected'
3261 STATUS_REJECTED = 'rejected'
3223 STATUS_UNDER_REVIEW = 'under_review'
3262 STATUS_UNDER_REVIEW = 'under_review'
3224
3263
3225 STATUSES = [
3264 STATUSES = [
3226 (STATUS_NOT_REVIEWED, _("Not Reviewed")), # (no icon) and default
3265 (STATUS_NOT_REVIEWED, _("Not Reviewed")), # (no icon) and default
3227 (STATUS_APPROVED, _("Approved")),
3266 (STATUS_APPROVED, _("Approved")),
3228 (STATUS_REJECTED, _("Rejected")),
3267 (STATUS_REJECTED, _("Rejected")),
3229 (STATUS_UNDER_REVIEW, _("Under Review")),
3268 (STATUS_UNDER_REVIEW, _("Under Review")),
3230 ]
3269 ]
3231
3270
3232 changeset_status_id = Column('changeset_status_id', Integer(), nullable=False, primary_key=True)
3271 changeset_status_id = Column('changeset_status_id', Integer(), nullable=False, primary_key=True)
3233 repo_id = Column('repo_id', Integer(), ForeignKey('repositories.repo_id'), nullable=False)
3272 repo_id = Column('repo_id', Integer(), ForeignKey('repositories.repo_id'), nullable=False)
3234 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=None)
3273 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=None)
3235 revision = Column('revision', String(40), nullable=False)
3274 revision = Column('revision', String(40), nullable=False)
3236 status = Column('status', String(128), nullable=False, default=DEFAULT)
3275 status = Column('status', String(128), nullable=False, default=DEFAULT)
3237 changeset_comment_id = Column('changeset_comment_id', Integer(), ForeignKey('changeset_comments.comment_id'))
3276 changeset_comment_id = Column('changeset_comment_id', Integer(), ForeignKey('changeset_comments.comment_id'))
3238 modified_at = Column('modified_at', DateTime(), nullable=False, default=datetime.datetime.now)
3277 modified_at = Column('modified_at', DateTime(), nullable=False, default=datetime.datetime.now)
3239 version = Column('version', Integer(), nullable=False, default=0)
3278 version = Column('version', Integer(), nullable=False, default=0)
3240 pull_request_id = Column("pull_request_id", Integer(), ForeignKey('pull_requests.pull_request_id'), nullable=True)
3279 pull_request_id = Column("pull_request_id", Integer(), ForeignKey('pull_requests.pull_request_id'), nullable=True)
3241
3280
3242 author = relationship('User', lazy='joined')
3281 author = relationship('User', lazy='joined')
3243 repo = relationship('Repository')
3282 repo = relationship('Repository')
3244 comment = relationship('ChangesetComment', lazy='joined')
3283 comment = relationship('ChangesetComment', lazy='joined')
3245 pull_request = relationship('PullRequest', lazy='joined')
3284 pull_request = relationship('PullRequest', lazy='joined')
3246
3285
3247 def __unicode__(self):
3286 def __unicode__(self):
3248 return u"<%s('%s[v%s]:%s')>" % (
3287 return u"<%s('%s[v%s]:%s')>" % (
3249 self.__class__.__name__,
3288 self.__class__.__name__,
3250 self.status, self.version, self.author
3289 self.status, self.version, self.author
3251 )
3290 )
3252
3291
3253 @classmethod
3292 @classmethod
3254 def get_status_lbl(cls, value):
3293 def get_status_lbl(cls, value):
3255 return dict(cls.STATUSES).get(value)
3294 return dict(cls.STATUSES).get(value)
3256
3295
3257 @property
3296 @property
3258 def status_lbl(self):
3297 def status_lbl(self):
3259 return ChangesetStatus.get_status_lbl(self.status)
3298 return ChangesetStatus.get_status_lbl(self.status)
3260
3299
3261 def get_api_data(self):
3300 def get_api_data(self):
3262 status = self
3301 status = self
3263 data = {
3302 data = {
3264 'status_id': status.changeset_status_id,
3303 'status_id': status.changeset_status_id,
3265 'status': status.status,
3304 'status': status.status,
3266 }
3305 }
3267 return data
3306 return data
3268
3307
3269 def __json__(self):
3308 def __json__(self):
3270 data = dict()
3309 data = dict()
3271 data.update(self.get_api_data())
3310 data.update(self.get_api_data())
3272 return data
3311 return data
3273
3312
3274
3313
3275 class _PullRequestBase(BaseModel):
3314 class _PullRequestBase(BaseModel):
3276 """
3315 """
3277 Common attributes of pull request and version entries.
3316 Common attributes of pull request and version entries.
3278 """
3317 """
3279
3318
3280 # .status values
3319 # .status values
3281 STATUS_NEW = u'new'
3320 STATUS_NEW = u'new'
3282 STATUS_OPEN = u'open'
3321 STATUS_OPEN = u'open'
3283 STATUS_CLOSED = u'closed'
3322 STATUS_CLOSED = u'closed'
3284
3323
3285 title = Column('title', Unicode(255), nullable=True)
3324 title = Column('title', Unicode(255), nullable=True)
3286 description = Column(
3325 description = Column(
3287 'description', UnicodeText().with_variant(UnicodeText(10240), 'mysql'),
3326 'description', UnicodeText().with_variant(UnicodeText(10240), 'mysql'),
3288 nullable=True)
3327 nullable=True)
3289 # new/open/closed status of pull request (not approve/reject/etc)
3328 # new/open/closed status of pull request (not approve/reject/etc)
3290 status = Column('status', Unicode(255), nullable=False, default=STATUS_NEW)
3329 status = Column('status', Unicode(255), nullable=False, default=STATUS_NEW)
3291 created_on = Column(
3330 created_on = Column(
3292 'created_on', DateTime(timezone=False), nullable=False,
3331 'created_on', DateTime(timezone=False), nullable=False,
3293 default=datetime.datetime.now)
3332 default=datetime.datetime.now)
3294 updated_on = Column(
3333 updated_on = Column(
3295 'updated_on', DateTime(timezone=False), nullable=False,
3334 'updated_on', DateTime(timezone=False), nullable=False,
3296 default=datetime.datetime.now)
3335 default=datetime.datetime.now)
3297
3336
3298 @declared_attr
3337 @declared_attr
3299 def user_id(cls):
3338 def user_id(cls):
3300 return Column(
3339 return Column(
3301 "user_id", Integer(), ForeignKey('users.user_id'), nullable=False,
3340 "user_id", Integer(), ForeignKey('users.user_id'), nullable=False,
3302 unique=None)
3341 unique=None)
3303
3342
3304 # 500 revisions max
3343 # 500 revisions max
3305 _revisions = Column(
3344 _revisions = Column(
3306 'revisions', UnicodeText().with_variant(UnicodeText(20500), 'mysql'))
3345 'revisions', UnicodeText().with_variant(UnicodeText(20500), 'mysql'))
3307
3346
3308 @declared_attr
3347 @declared_attr
3309 def source_repo_id(cls):
3348 def source_repo_id(cls):
3310 # TODO: dan: rename column to source_repo_id
3349 # TODO: dan: rename column to source_repo_id
3311 return Column(
3350 return Column(
3312 'org_repo_id', Integer(), ForeignKey('repositories.repo_id'),
3351 'org_repo_id', Integer(), ForeignKey('repositories.repo_id'),
3313 nullable=False)
3352 nullable=False)
3314
3353
3315 source_ref = Column('org_ref', Unicode(255), nullable=False)
3354 source_ref = Column('org_ref', Unicode(255), nullable=False)
3316
3355
3317 @declared_attr
3356 @declared_attr
3318 def target_repo_id(cls):
3357 def target_repo_id(cls):
3319 # TODO: dan: rename column to target_repo_id
3358 # TODO: dan: rename column to target_repo_id
3320 return Column(
3359 return Column(
3321 'other_repo_id', Integer(), ForeignKey('repositories.repo_id'),
3360 'other_repo_id', Integer(), ForeignKey('repositories.repo_id'),
3322 nullable=False)
3361 nullable=False)
3323
3362
3324 target_ref = Column('other_ref', Unicode(255), nullable=False)
3363 target_ref = Column('other_ref', Unicode(255), nullable=False)
3325 _shadow_merge_ref = Column('shadow_merge_ref', Unicode(255), nullable=True)
3364 _shadow_merge_ref = Column('shadow_merge_ref', Unicode(255), nullable=True)
3326
3365
3327 # TODO: dan: rename column to last_merge_source_rev
3366 # TODO: dan: rename column to last_merge_source_rev
3328 _last_merge_source_rev = Column(
3367 _last_merge_source_rev = Column(
3329 'last_merge_org_rev', String(40), nullable=True)
3368 'last_merge_org_rev', String(40), nullable=True)
3330 # TODO: dan: rename column to last_merge_target_rev
3369 # TODO: dan: rename column to last_merge_target_rev
3331 _last_merge_target_rev = Column(
3370 _last_merge_target_rev = Column(
3332 'last_merge_other_rev', String(40), nullable=True)
3371 'last_merge_other_rev', String(40), nullable=True)
3333 _last_merge_status = Column('merge_status', Integer(), nullable=True)
3372 _last_merge_status = Column('merge_status', Integer(), nullable=True)
3334 merge_rev = Column('merge_rev', String(40), nullable=True)
3373 merge_rev = Column('merge_rev', String(40), nullable=True)
3335
3374
3336 reviewer_data = Column(
3375 reviewer_data = Column(
3337 'reviewer_data_json', MutationObj.as_mutable(
3376 'reviewer_data_json', MutationObj.as_mutable(
3338 JsonType(dialect_map=dict(mysql=UnicodeText(16384)))))
3377 JsonType(dialect_map=dict(mysql=UnicodeText(16384)))))
3339
3378
3340 @property
3379 @property
3341 def reviewer_data_json(self):
3380 def reviewer_data_json(self):
3342 return json.dumps(self.reviewer_data)
3381 return json.dumps(self.reviewer_data)
3343
3382
3344 @hybrid_property
3383 @hybrid_property
3345 def description_safe(self):
3384 def description_safe(self):
3346 from rhodecode.lib import helpers as h
3385 from rhodecode.lib import helpers as h
3347 return h.escape(self.description)
3386 return h.escape(self.description)
3348
3387
3349 @hybrid_property
3388 @hybrid_property
3350 def revisions(self):
3389 def revisions(self):
3351 return self._revisions.split(':') if self._revisions else []
3390 return self._revisions.split(':') if self._revisions else []
3352
3391
3353 @revisions.setter
3392 @revisions.setter
3354 def revisions(self, val):
3393 def revisions(self, val):
3355 self._revisions = ':'.join(val)
3394 self._revisions = ':'.join(val)
3356
3395
3357 @hybrid_property
3396 @hybrid_property
3358 def last_merge_status(self):
3397 def last_merge_status(self):
3359 return safe_int(self._last_merge_status)
3398 return safe_int(self._last_merge_status)
3360
3399
3361 @last_merge_status.setter
3400 @last_merge_status.setter
3362 def last_merge_status(self, val):
3401 def last_merge_status(self, val):
3363 self._last_merge_status = val
3402 self._last_merge_status = val
3364
3403
3365 @declared_attr
3404 @declared_attr
3366 def author(cls):
3405 def author(cls):
3367 return relationship('User', lazy='joined')
3406 return relationship('User', lazy='joined')
3368
3407
3369 @declared_attr
3408 @declared_attr
3370 def source_repo(cls):
3409 def source_repo(cls):
3371 return relationship(
3410 return relationship(
3372 'Repository',
3411 'Repository',
3373 primaryjoin='%s.source_repo_id==Repository.repo_id' % cls.__name__)
3412 primaryjoin='%s.source_repo_id==Repository.repo_id' % cls.__name__)
3374
3413
3375 @property
3414 @property
3376 def source_ref_parts(self):
3415 def source_ref_parts(self):
3377 return self.unicode_to_reference(self.source_ref)
3416 return self.unicode_to_reference(self.source_ref)
3378
3417
3379 @declared_attr
3418 @declared_attr
3380 def target_repo(cls):
3419 def target_repo(cls):
3381 return relationship(
3420 return relationship(
3382 'Repository',
3421 'Repository',
3383 primaryjoin='%s.target_repo_id==Repository.repo_id' % cls.__name__)
3422 primaryjoin='%s.target_repo_id==Repository.repo_id' % cls.__name__)
3384
3423
3385 @property
3424 @property
3386 def target_ref_parts(self):
3425 def target_ref_parts(self):
3387 return self.unicode_to_reference(self.target_ref)
3426 return self.unicode_to_reference(self.target_ref)
3388
3427
3389 @property
3428 @property
3390 def shadow_merge_ref(self):
3429 def shadow_merge_ref(self):
3391 return self.unicode_to_reference(self._shadow_merge_ref)
3430 return self.unicode_to_reference(self._shadow_merge_ref)
3392
3431
3393 @shadow_merge_ref.setter
3432 @shadow_merge_ref.setter
3394 def shadow_merge_ref(self, ref):
3433 def shadow_merge_ref(self, ref):
3395 self._shadow_merge_ref = self.reference_to_unicode(ref)
3434 self._shadow_merge_ref = self.reference_to_unicode(ref)
3396
3435
3397 def unicode_to_reference(self, raw):
3436 def unicode_to_reference(self, raw):
3398 """
3437 """
3399 Convert a unicode (or string) to a reference object.
3438 Convert a unicode (or string) to a reference object.
3400 If unicode evaluates to False it returns None.
3439 If unicode evaluates to False it returns None.
3401 """
3440 """
3402 if raw:
3441 if raw:
3403 refs = raw.split(':')
3442 refs = raw.split(':')
3404 return Reference(*refs)
3443 return Reference(*refs)
3405 else:
3444 else:
3406 return None
3445 return None
3407
3446
3408 def reference_to_unicode(self, ref):
3447 def reference_to_unicode(self, ref):
3409 """
3448 """
3410 Convert a reference object to unicode.
3449 Convert a reference object to unicode.
3411 If reference is None it returns None.
3450 If reference is None it returns None.
3412 """
3451 """
3413 if ref:
3452 if ref:
3414 return u':'.join(ref)
3453 return u':'.join(ref)
3415 else:
3454 else:
3416 return None
3455 return None
3417
3456
3418 def get_api_data(self, with_merge_state=True):
3457 def get_api_data(self, with_merge_state=True):
3419 from rhodecode.model.pull_request import PullRequestModel
3458 from rhodecode.model.pull_request import PullRequestModel
3420
3459
3421 pull_request = self
3460 pull_request = self
3422 if with_merge_state:
3461 if with_merge_state:
3423 merge_status = PullRequestModel().merge_status(pull_request)
3462 merge_status = PullRequestModel().merge_status(pull_request)
3424 merge_state = {
3463 merge_state = {
3425 'status': merge_status[0],
3464 'status': merge_status[0],
3426 'message': safe_unicode(merge_status[1]),
3465 'message': safe_unicode(merge_status[1]),
3427 }
3466 }
3428 else:
3467 else:
3429 merge_state = {'status': 'not_available',
3468 merge_state = {'status': 'not_available',
3430 'message': 'not_available'}
3469 'message': 'not_available'}
3431
3470
3432 merge_data = {
3471 merge_data = {
3433 'clone_url': PullRequestModel().get_shadow_clone_url(pull_request),
3472 'clone_url': PullRequestModel().get_shadow_clone_url(pull_request),
3434 'reference': (
3473 'reference': (
3435 pull_request.shadow_merge_ref._asdict()
3474 pull_request.shadow_merge_ref._asdict()
3436 if pull_request.shadow_merge_ref else None),
3475 if pull_request.shadow_merge_ref else None),
3437 }
3476 }
3438
3477
3439 data = {
3478 data = {
3440 'pull_request_id': pull_request.pull_request_id,
3479 'pull_request_id': pull_request.pull_request_id,
3441 'url': PullRequestModel().get_url(pull_request),
3480 'url': PullRequestModel().get_url(pull_request),
3442 'title': pull_request.title,
3481 'title': pull_request.title,
3443 'description': pull_request.description,
3482 'description': pull_request.description,
3444 'status': pull_request.status,
3483 'status': pull_request.status,
3445 'created_on': pull_request.created_on,
3484 'created_on': pull_request.created_on,
3446 'updated_on': pull_request.updated_on,
3485 'updated_on': pull_request.updated_on,
3447 'commit_ids': pull_request.revisions,
3486 'commit_ids': pull_request.revisions,
3448 'review_status': pull_request.calculated_review_status(),
3487 'review_status': pull_request.calculated_review_status(),
3449 'mergeable': merge_state,
3488 'mergeable': merge_state,
3450 'source': {
3489 'source': {
3451 'clone_url': pull_request.source_repo.clone_url(),
3490 'clone_url': pull_request.source_repo.clone_url(),
3452 'repository': pull_request.source_repo.repo_name,
3491 'repository': pull_request.source_repo.repo_name,
3453 'reference': {
3492 'reference': {
3454 'name': pull_request.source_ref_parts.name,
3493 'name': pull_request.source_ref_parts.name,
3455 'type': pull_request.source_ref_parts.type,
3494 'type': pull_request.source_ref_parts.type,
3456 'commit_id': pull_request.source_ref_parts.commit_id,
3495 'commit_id': pull_request.source_ref_parts.commit_id,
3457 },
3496 },
3458 },
3497 },
3459 'target': {
3498 'target': {
3460 'clone_url': pull_request.target_repo.clone_url(),
3499 'clone_url': pull_request.target_repo.clone_url(),
3461 'repository': pull_request.target_repo.repo_name,
3500 'repository': pull_request.target_repo.repo_name,
3462 'reference': {
3501 'reference': {
3463 'name': pull_request.target_ref_parts.name,
3502 'name': pull_request.target_ref_parts.name,
3464 'type': pull_request.target_ref_parts.type,
3503 'type': pull_request.target_ref_parts.type,
3465 'commit_id': pull_request.target_ref_parts.commit_id,
3504 'commit_id': pull_request.target_ref_parts.commit_id,
3466 },
3505 },
3467 },
3506 },
3468 'merge': merge_data,
3507 'merge': merge_data,
3469 'author': pull_request.author.get_api_data(include_secrets=False,
3508 'author': pull_request.author.get_api_data(include_secrets=False,
3470 details='basic'),
3509 details='basic'),
3471 'reviewers': [
3510 'reviewers': [
3472 {
3511 {
3473 'user': reviewer.get_api_data(include_secrets=False,
3512 'user': reviewer.get_api_data(include_secrets=False,
3474 details='basic'),
3513 details='basic'),
3475 'reasons': reasons,
3514 'reasons': reasons,
3476 'review_status': st[0][1].status if st else 'not_reviewed',
3515 'review_status': st[0][1].status if st else 'not_reviewed',
3477 }
3516 }
3478 for reviewer, reasons, mandatory, st in
3517 for reviewer, reasons, mandatory, st in
3479 pull_request.reviewers_statuses()
3518 pull_request.reviewers_statuses()
3480 ]
3519 ]
3481 }
3520 }
3482
3521
3483 return data
3522 return data
3484
3523
3485
3524
3486 class PullRequest(Base, _PullRequestBase):
3525 class PullRequest(Base, _PullRequestBase):
3487 __tablename__ = 'pull_requests'
3526 __tablename__ = 'pull_requests'
3488 __table_args__ = (
3527 __table_args__ = (
3489 {'extend_existing': True, 'mysql_engine': 'InnoDB',
3528 {'extend_existing': True, 'mysql_engine': 'InnoDB',
3490 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
3529 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
3491 )
3530 )
3492
3531
3493 pull_request_id = Column(
3532 pull_request_id = Column(
3494 'pull_request_id', Integer(), nullable=False, primary_key=True)
3533 'pull_request_id', Integer(), nullable=False, primary_key=True)
3495
3534
3496 def __repr__(self):
3535 def __repr__(self):
3497 if self.pull_request_id:
3536 if self.pull_request_id:
3498 return '<DB:PullRequest #%s>' % self.pull_request_id
3537 return '<DB:PullRequest #%s>' % self.pull_request_id
3499 else:
3538 else:
3500 return '<DB:PullRequest at %#x>' % id(self)
3539 return '<DB:PullRequest at %#x>' % id(self)
3501
3540
3502 reviewers = relationship('PullRequestReviewers',
3541 reviewers = relationship('PullRequestReviewers',
3503 cascade="all, delete, delete-orphan")
3542 cascade="all, delete, delete-orphan")
3504 statuses = relationship('ChangesetStatus',
3543 statuses = relationship('ChangesetStatus',
3505 cascade="all, delete, delete-orphan")
3544 cascade="all, delete, delete-orphan")
3506 comments = relationship('ChangesetComment',
3545 comments = relationship('ChangesetComment',
3507 cascade="all, delete, delete-orphan")
3546 cascade="all, delete, delete-orphan")
3508 versions = relationship('PullRequestVersion',
3547 versions = relationship('PullRequestVersion',
3509 cascade="all, delete, delete-orphan",
3548 cascade="all, delete, delete-orphan",
3510 lazy='dynamic')
3549 lazy='dynamic')
3511
3550
3512 @classmethod
3551 @classmethod
3513 def get_pr_display_object(cls, pull_request_obj, org_pull_request_obj,
3552 def get_pr_display_object(cls, pull_request_obj, org_pull_request_obj,
3514 internal_methods=None):
3553 internal_methods=None):
3515
3554
3516 class PullRequestDisplay(object):
3555 class PullRequestDisplay(object):
3517 """
3556 """
3518 Special object wrapper for showing PullRequest data via Versions
3557 Special object wrapper for showing PullRequest data via Versions
3519 It mimics PR object as close as possible. This is read only object
3558 It mimics PR object as close as possible. This is read only object
3520 just for display
3559 just for display
3521 """
3560 """
3522
3561
3523 def __init__(self, attrs, internal=None):
3562 def __init__(self, attrs, internal=None):
3524 self.attrs = attrs
3563 self.attrs = attrs
3525 # internal have priority over the given ones via attrs
3564 # internal have priority over the given ones via attrs
3526 self.internal = internal or ['versions']
3565 self.internal = internal or ['versions']
3527
3566
3528 def __getattr__(self, item):
3567 def __getattr__(self, item):
3529 if item in self.internal:
3568 if item in self.internal:
3530 return getattr(self, item)
3569 return getattr(self, item)
3531 try:
3570 try:
3532 return self.attrs[item]
3571 return self.attrs[item]
3533 except KeyError:
3572 except KeyError:
3534 raise AttributeError(
3573 raise AttributeError(
3535 '%s object has no attribute %s' % (self, item))
3574 '%s object has no attribute %s' % (self, item))
3536
3575
3537 def __repr__(self):
3576 def __repr__(self):
3538 return '<DB:PullRequestDisplay #%s>' % self.attrs.get('pull_request_id')
3577 return '<DB:PullRequestDisplay #%s>' % self.attrs.get('pull_request_id')
3539
3578
3540 def versions(self):
3579 def versions(self):
3541 return pull_request_obj.versions.order_by(
3580 return pull_request_obj.versions.order_by(
3542 PullRequestVersion.pull_request_version_id).all()
3581 PullRequestVersion.pull_request_version_id).all()
3543
3582
3544 def is_closed(self):
3583 def is_closed(self):
3545 return pull_request_obj.is_closed()
3584 return pull_request_obj.is_closed()
3546
3585
3547 @property
3586 @property
3548 def pull_request_version_id(self):
3587 def pull_request_version_id(self):
3549 return getattr(pull_request_obj, 'pull_request_version_id', None)
3588 return getattr(pull_request_obj, 'pull_request_version_id', None)
3550
3589
3551 attrs = StrictAttributeDict(pull_request_obj.get_api_data())
3590 attrs = StrictAttributeDict(pull_request_obj.get_api_data())
3552
3591
3553 attrs.author = StrictAttributeDict(
3592 attrs.author = StrictAttributeDict(
3554 pull_request_obj.author.get_api_data())
3593 pull_request_obj.author.get_api_data())
3555 if pull_request_obj.target_repo:
3594 if pull_request_obj.target_repo:
3556 attrs.target_repo = StrictAttributeDict(
3595 attrs.target_repo = StrictAttributeDict(
3557 pull_request_obj.target_repo.get_api_data())
3596 pull_request_obj.target_repo.get_api_data())
3558 attrs.target_repo.clone_url = pull_request_obj.target_repo.clone_url
3597 attrs.target_repo.clone_url = pull_request_obj.target_repo.clone_url
3559
3598
3560 if pull_request_obj.source_repo:
3599 if pull_request_obj.source_repo:
3561 attrs.source_repo = StrictAttributeDict(
3600 attrs.source_repo = StrictAttributeDict(
3562 pull_request_obj.source_repo.get_api_data())
3601 pull_request_obj.source_repo.get_api_data())
3563 attrs.source_repo.clone_url = pull_request_obj.source_repo.clone_url
3602 attrs.source_repo.clone_url = pull_request_obj.source_repo.clone_url
3564
3603
3565 attrs.source_ref_parts = pull_request_obj.source_ref_parts
3604 attrs.source_ref_parts = pull_request_obj.source_ref_parts
3566 attrs.target_ref_parts = pull_request_obj.target_ref_parts
3605 attrs.target_ref_parts = pull_request_obj.target_ref_parts
3567 attrs.revisions = pull_request_obj.revisions
3606 attrs.revisions = pull_request_obj.revisions
3568
3607
3569 attrs.shadow_merge_ref = org_pull_request_obj.shadow_merge_ref
3608 attrs.shadow_merge_ref = org_pull_request_obj.shadow_merge_ref
3570 attrs.reviewer_data = org_pull_request_obj.reviewer_data
3609 attrs.reviewer_data = org_pull_request_obj.reviewer_data
3571 attrs.reviewer_data_json = org_pull_request_obj.reviewer_data_json
3610 attrs.reviewer_data_json = org_pull_request_obj.reviewer_data_json
3572
3611
3573 return PullRequestDisplay(attrs, internal=internal_methods)
3612 return PullRequestDisplay(attrs, internal=internal_methods)
3574
3613
3575 def is_closed(self):
3614 def is_closed(self):
3576 return self.status == self.STATUS_CLOSED
3615 return self.status == self.STATUS_CLOSED
3577
3616
3578 def __json__(self):
3617 def __json__(self):
3579 return {
3618 return {
3580 'revisions': self.revisions,
3619 'revisions': self.revisions,
3581 }
3620 }
3582
3621
3583 def calculated_review_status(self):
3622 def calculated_review_status(self):
3584 from rhodecode.model.changeset_status import ChangesetStatusModel
3623 from rhodecode.model.changeset_status import ChangesetStatusModel
3585 return ChangesetStatusModel().calculated_review_status(self)
3624 return ChangesetStatusModel().calculated_review_status(self)
3586
3625
3587 def reviewers_statuses(self):
3626 def reviewers_statuses(self):
3588 from rhodecode.model.changeset_status import ChangesetStatusModel
3627 from rhodecode.model.changeset_status import ChangesetStatusModel
3589 return ChangesetStatusModel().reviewers_statuses(self)
3628 return ChangesetStatusModel().reviewers_statuses(self)
3590
3629
3591 @property
3630 @property
3592 def workspace_id(self):
3631 def workspace_id(self):
3593 from rhodecode.model.pull_request import PullRequestModel
3632 from rhodecode.model.pull_request import PullRequestModel
3594 return PullRequestModel()._workspace_id(self)
3633 return PullRequestModel()._workspace_id(self)
3595
3634
3596 def get_shadow_repo(self):
3635 def get_shadow_repo(self):
3597 workspace_id = self.workspace_id
3636 workspace_id = self.workspace_id
3598 vcs_obj = self.target_repo.scm_instance()
3637 vcs_obj = self.target_repo.scm_instance()
3599 shadow_repository_path = vcs_obj._get_shadow_repository_path(
3638 shadow_repository_path = vcs_obj._get_shadow_repository_path(
3600 workspace_id)
3639 workspace_id)
3601 return vcs_obj._get_shadow_instance(shadow_repository_path)
3640 return vcs_obj._get_shadow_instance(shadow_repository_path)
3602
3641
3603
3642
3604 class PullRequestVersion(Base, _PullRequestBase):
3643 class PullRequestVersion(Base, _PullRequestBase):
3605 __tablename__ = 'pull_request_versions'
3644 __tablename__ = 'pull_request_versions'
3606 __table_args__ = (
3645 __table_args__ = (
3607 {'extend_existing': True, 'mysql_engine': 'InnoDB',
3646 {'extend_existing': True, 'mysql_engine': 'InnoDB',
3608 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
3647 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
3609 )
3648 )
3610
3649
3611 pull_request_version_id = Column(
3650 pull_request_version_id = Column(
3612 'pull_request_version_id', Integer(), nullable=False, primary_key=True)
3651 'pull_request_version_id', Integer(), nullable=False, primary_key=True)
3613 pull_request_id = Column(
3652 pull_request_id = Column(
3614 'pull_request_id', Integer(),
3653 'pull_request_id', Integer(),
3615 ForeignKey('pull_requests.pull_request_id'), nullable=False)
3654 ForeignKey('pull_requests.pull_request_id'), nullable=False)
3616 pull_request = relationship('PullRequest')
3655 pull_request = relationship('PullRequest')
3617
3656
3618 def __repr__(self):
3657 def __repr__(self):
3619 if self.pull_request_version_id:
3658 if self.pull_request_version_id:
3620 return '<DB:PullRequestVersion #%s>' % self.pull_request_version_id
3659 return '<DB:PullRequestVersion #%s>' % self.pull_request_version_id
3621 else:
3660 else:
3622 return '<DB:PullRequestVersion at %#x>' % id(self)
3661 return '<DB:PullRequestVersion at %#x>' % id(self)
3623
3662
3624 @property
3663 @property
3625 def reviewers(self):
3664 def reviewers(self):
3626 return self.pull_request.reviewers
3665 return self.pull_request.reviewers
3627
3666
3628 @property
3667 @property
3629 def versions(self):
3668 def versions(self):
3630 return self.pull_request.versions
3669 return self.pull_request.versions
3631
3670
3632 def is_closed(self):
3671 def is_closed(self):
3633 # calculate from original
3672 # calculate from original
3634 return self.pull_request.status == self.STATUS_CLOSED
3673 return self.pull_request.status == self.STATUS_CLOSED
3635
3674
3636 def calculated_review_status(self):
3675 def calculated_review_status(self):
3637 return self.pull_request.calculated_review_status()
3676 return self.pull_request.calculated_review_status()
3638
3677
3639 def reviewers_statuses(self):
3678 def reviewers_statuses(self):
3640 return self.pull_request.reviewers_statuses()
3679 return self.pull_request.reviewers_statuses()
3641
3680
3642
3681
3643 class PullRequestReviewers(Base, BaseModel):
3682 class PullRequestReviewers(Base, BaseModel):
3644 __tablename__ = 'pull_request_reviewers'
3683 __tablename__ = 'pull_request_reviewers'
3645 __table_args__ = (
3684 __table_args__ = (
3646 {'extend_existing': True, 'mysql_engine': 'InnoDB',
3685 {'extend_existing': True, 'mysql_engine': 'InnoDB',
3647 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
3686 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
3648 )
3687 )
3649
3688
3650 @hybrid_property
3689 @hybrid_property
3651 def reasons(self):
3690 def reasons(self):
3652 if not self._reasons:
3691 if not self._reasons:
3653 return []
3692 return []
3654 return self._reasons
3693 return self._reasons
3655
3694
3656 @reasons.setter
3695 @reasons.setter
3657 def reasons(self, val):
3696 def reasons(self, val):
3658 val = val or []
3697 val = val or []
3659 if any(not isinstance(x, basestring) for x in val):
3698 if any(not isinstance(x, basestring) for x in val):
3660 raise Exception('invalid reasons type, must be list of strings')
3699 raise Exception('invalid reasons type, must be list of strings')
3661 self._reasons = val
3700 self._reasons = val
3662
3701
3663 pull_requests_reviewers_id = Column(
3702 pull_requests_reviewers_id = Column(
3664 'pull_requests_reviewers_id', Integer(), nullable=False,
3703 'pull_requests_reviewers_id', Integer(), nullable=False,
3665 primary_key=True)
3704 primary_key=True)
3666 pull_request_id = Column(
3705 pull_request_id = Column(
3667 "pull_request_id", Integer(),
3706 "pull_request_id", Integer(),
3668 ForeignKey('pull_requests.pull_request_id'), nullable=False)
3707 ForeignKey('pull_requests.pull_request_id'), nullable=False)
3669 user_id = Column(
3708 user_id = Column(
3670 "user_id", Integer(), ForeignKey('users.user_id'), nullable=True)
3709 "user_id", Integer(), ForeignKey('users.user_id'), nullable=True)
3671 _reasons = Column(
3710 _reasons = Column(
3672 'reason', MutationList.as_mutable(
3711 'reason', MutationList.as_mutable(
3673 JsonType('list', dialect_map=dict(mysql=UnicodeText(16384)))))
3712 JsonType('list', dialect_map=dict(mysql=UnicodeText(16384)))))
3674 mandatory = Column("mandatory", Boolean(), nullable=False, default=False)
3713 mandatory = Column("mandatory", Boolean(), nullable=False, default=False)
3675 user = relationship('User')
3714 user = relationship('User')
3676 pull_request = relationship('PullRequest')
3715 pull_request = relationship('PullRequest')
3677
3716
3678
3717
3679 class Notification(Base, BaseModel):
3718 class Notification(Base, BaseModel):
3680 __tablename__ = 'notifications'
3719 __tablename__ = 'notifications'
3681 __table_args__ = (
3720 __table_args__ = (
3682 Index('notification_type_idx', 'type'),
3721 Index('notification_type_idx', 'type'),
3683 {'extend_existing': True, 'mysql_engine': 'InnoDB',
3722 {'extend_existing': True, 'mysql_engine': 'InnoDB',
3684 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
3723 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
3685 )
3724 )
3686
3725
3687 TYPE_CHANGESET_COMMENT = u'cs_comment'
3726 TYPE_CHANGESET_COMMENT = u'cs_comment'
3688 TYPE_MESSAGE = u'message'
3727 TYPE_MESSAGE = u'message'
3689 TYPE_MENTION = u'mention'
3728 TYPE_MENTION = u'mention'
3690 TYPE_REGISTRATION = u'registration'
3729 TYPE_REGISTRATION = u'registration'
3691 TYPE_PULL_REQUEST = u'pull_request'
3730 TYPE_PULL_REQUEST = u'pull_request'
3692 TYPE_PULL_REQUEST_COMMENT = u'pull_request_comment'
3731 TYPE_PULL_REQUEST_COMMENT = u'pull_request_comment'
3693
3732
3694 notification_id = Column('notification_id', Integer(), nullable=False, primary_key=True)
3733 notification_id = Column('notification_id', Integer(), nullable=False, primary_key=True)
3695 subject = Column('subject', Unicode(512), nullable=True)
3734 subject = Column('subject', Unicode(512), nullable=True)
3696 body = Column('body', UnicodeText().with_variant(UnicodeText(50000), 'mysql'), nullable=True)
3735 body = Column('body', UnicodeText().with_variant(UnicodeText(50000), 'mysql'), nullable=True)
3697 created_by = Column("created_by", Integer(), ForeignKey('users.user_id'), nullable=True)
3736 created_by = Column("created_by", Integer(), ForeignKey('users.user_id'), nullable=True)
3698 created_on = Column('created_on', DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
3737 created_on = Column('created_on', DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
3699 type_ = Column('type', Unicode(255))
3738 type_ = Column('type', Unicode(255))
3700
3739
3701 created_by_user = relationship('User')
3740 created_by_user = relationship('User')
3702 notifications_to_users = relationship('UserNotification', lazy='joined',
3741 notifications_to_users = relationship('UserNotification', lazy='joined',
3703 cascade="all, delete, delete-orphan")
3742 cascade="all, delete, delete-orphan")
3704
3743
3705 @property
3744 @property
3706 def recipients(self):
3745 def recipients(self):
3707 return [x.user for x in UserNotification.query()\
3746 return [x.user for x in UserNotification.query()\
3708 .filter(UserNotification.notification == self)\
3747 .filter(UserNotification.notification == self)\
3709 .order_by(UserNotification.user_id.asc()).all()]
3748 .order_by(UserNotification.user_id.asc()).all()]
3710
3749
3711 @classmethod
3750 @classmethod
3712 def create(cls, created_by, subject, body, recipients, type_=None):
3751 def create(cls, created_by, subject, body, recipients, type_=None):
3713 if type_ is None:
3752 if type_ is None:
3714 type_ = Notification.TYPE_MESSAGE
3753 type_ = Notification.TYPE_MESSAGE
3715
3754
3716 notification = cls()
3755 notification = cls()
3717 notification.created_by_user = created_by
3756 notification.created_by_user = created_by
3718 notification.subject = subject
3757 notification.subject = subject
3719 notification.body = body
3758 notification.body = body
3720 notification.type_ = type_
3759 notification.type_ = type_
3721 notification.created_on = datetime.datetime.now()
3760 notification.created_on = datetime.datetime.now()
3722
3761
3723 for u in recipients:
3762 for u in recipients:
3724 assoc = UserNotification()
3763 assoc = UserNotification()
3725 assoc.notification = notification
3764 assoc.notification = notification
3726
3765
3727 # if created_by is inside recipients mark his notification
3766 # if created_by is inside recipients mark his notification
3728 # as read
3767 # as read
3729 if u.user_id == created_by.user_id:
3768 if u.user_id == created_by.user_id:
3730 assoc.read = True
3769 assoc.read = True
3731
3770
3732 u.notifications.append(assoc)
3771 u.notifications.append(assoc)
3733 Session().add(notification)
3772 Session().add(notification)
3734
3773
3735 return notification
3774 return notification
3736
3775
3737
3776
3738 class UserNotification(Base, BaseModel):
3777 class UserNotification(Base, BaseModel):
3739 __tablename__ = 'user_to_notification'
3778 __tablename__ = 'user_to_notification'
3740 __table_args__ = (
3779 __table_args__ = (
3741 UniqueConstraint('user_id', 'notification_id'),
3780 UniqueConstraint('user_id', 'notification_id'),
3742 {'extend_existing': True, 'mysql_engine': 'InnoDB',
3781 {'extend_existing': True, 'mysql_engine': 'InnoDB',
3743 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
3782 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
3744 )
3783 )
3745 user_id = Column('user_id', Integer(), ForeignKey('users.user_id'), primary_key=True)
3784 user_id = Column('user_id', Integer(), ForeignKey('users.user_id'), primary_key=True)
3746 notification_id = Column("notification_id", Integer(), ForeignKey('notifications.notification_id'), primary_key=True)
3785 notification_id = Column("notification_id", Integer(), ForeignKey('notifications.notification_id'), primary_key=True)
3747 read = Column('read', Boolean, default=False)
3786 read = Column('read', Boolean, default=False)
3748 sent_on = Column('sent_on', DateTime(timezone=False), nullable=True, unique=None)
3787 sent_on = Column('sent_on', DateTime(timezone=False), nullable=True, unique=None)
3749
3788
3750 user = relationship('User', lazy="joined")
3789 user = relationship('User', lazy="joined")
3751 notification = relationship('Notification', lazy="joined",
3790 notification = relationship('Notification', lazy="joined",
3752 order_by=lambda: Notification.created_on.desc(),)
3791 order_by=lambda: Notification.created_on.desc(),)
3753
3792
3754 def mark_as_read(self):
3793 def mark_as_read(self):
3755 self.read = True
3794 self.read = True
3756 Session().add(self)
3795 Session().add(self)
3757
3796
3758
3797
3759 class Gist(Base, BaseModel):
3798 class Gist(Base, BaseModel):
3760 __tablename__ = 'gists'
3799 __tablename__ = 'gists'
3761 __table_args__ = (
3800 __table_args__ = (
3762 Index('g_gist_access_id_idx', 'gist_access_id'),
3801 Index('g_gist_access_id_idx', 'gist_access_id'),
3763 Index('g_created_on_idx', 'created_on'),
3802 Index('g_created_on_idx', 'created_on'),
3764 {'extend_existing': True, 'mysql_engine': 'InnoDB',
3803 {'extend_existing': True, 'mysql_engine': 'InnoDB',
3765 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
3804 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
3766 )
3805 )
3767 GIST_PUBLIC = u'public'
3806 GIST_PUBLIC = u'public'
3768 GIST_PRIVATE = u'private'
3807 GIST_PRIVATE = u'private'
3769 DEFAULT_FILENAME = u'gistfile1.txt'
3808 DEFAULT_FILENAME = u'gistfile1.txt'
3770
3809
3771 ACL_LEVEL_PUBLIC = u'acl_public'
3810 ACL_LEVEL_PUBLIC = u'acl_public'
3772 ACL_LEVEL_PRIVATE = u'acl_private'
3811 ACL_LEVEL_PRIVATE = u'acl_private'
3773
3812
3774 gist_id = Column('gist_id', Integer(), primary_key=True)
3813 gist_id = Column('gist_id', Integer(), primary_key=True)
3775 gist_access_id = Column('gist_access_id', Unicode(250))
3814 gist_access_id = Column('gist_access_id', Unicode(250))
3776 gist_description = Column('gist_description', UnicodeText().with_variant(UnicodeText(1024), 'mysql'))
3815 gist_description = Column('gist_description', UnicodeText().with_variant(UnicodeText(1024), 'mysql'))
3777 gist_owner = Column('user_id', Integer(), ForeignKey('users.user_id'), nullable=True)
3816 gist_owner = Column('user_id', Integer(), ForeignKey('users.user_id'), nullable=True)
3778 gist_expires = Column('gist_expires', Float(53), nullable=False)
3817 gist_expires = Column('gist_expires', Float(53), nullable=False)
3779 gist_type = Column('gist_type', Unicode(128), nullable=False)
3818 gist_type = Column('gist_type', Unicode(128), nullable=False)
3780 created_on = Column('created_on', DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
3819 created_on = Column('created_on', DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
3781 modified_at = Column('modified_at', DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
3820 modified_at = Column('modified_at', DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
3782 acl_level = Column('acl_level', Unicode(128), nullable=True)
3821 acl_level = Column('acl_level', Unicode(128), nullable=True)
3783
3822
3784 owner = relationship('User')
3823 owner = relationship('User')
3785
3824
3786 def __repr__(self):
3825 def __repr__(self):
3787 return '<Gist:[%s]%s>' % (self.gist_type, self.gist_access_id)
3826 return '<Gist:[%s]%s>' % (self.gist_type, self.gist_access_id)
3788
3827
3789 @hybrid_property
3828 @hybrid_property
3790 def description_safe(self):
3829 def description_safe(self):
3791 from rhodecode.lib import helpers as h
3830 from rhodecode.lib import helpers as h
3792 return h.escape(self.gist_description)
3831 return h.escape(self.gist_description)
3793
3832
3794 @classmethod
3833 @classmethod
3795 def get_or_404(cls, id_):
3834 def get_or_404(cls, id_):
3796 from pyramid.httpexceptions import HTTPNotFound
3835 from pyramid.httpexceptions import HTTPNotFound
3797
3836
3798 res = cls.query().filter(cls.gist_access_id == id_).scalar()
3837 res = cls.query().filter(cls.gist_access_id == id_).scalar()
3799 if not res:
3838 if not res:
3800 raise HTTPNotFound()
3839 raise HTTPNotFound()
3801 return res
3840 return res
3802
3841
3803 @classmethod
3842 @classmethod
3804 def get_by_access_id(cls, gist_access_id):
3843 def get_by_access_id(cls, gist_access_id):
3805 return cls.query().filter(cls.gist_access_id == gist_access_id).scalar()
3844 return cls.query().filter(cls.gist_access_id == gist_access_id).scalar()
3806
3845
3807 def gist_url(self):
3846 def gist_url(self):
3808 from rhodecode.model.gist import GistModel
3847 from rhodecode.model.gist import GistModel
3809 return GistModel().get_url(self)
3848 return GistModel().get_url(self)
3810
3849
3811 @classmethod
3850 @classmethod
3812 def base_path(cls):
3851 def base_path(cls):
3813 """
3852 """
3814 Returns base path when all gists are stored
3853 Returns base path when all gists are stored
3815
3854
3816 :param cls:
3855 :param cls:
3817 """
3856 """
3818 from rhodecode.model.gist import GIST_STORE_LOC
3857 from rhodecode.model.gist import GIST_STORE_LOC
3819 q = Session().query(RhodeCodeUi)\
3858 q = Session().query(RhodeCodeUi)\
3820 .filter(RhodeCodeUi.ui_key == URL_SEP)
3859 .filter(RhodeCodeUi.ui_key == URL_SEP)
3821 q = q.options(FromCache("sql_cache_short", "repository_repo_path"))
3860 q = q.options(FromCache("sql_cache_short", "repository_repo_path"))
3822 return os.path.join(q.one().ui_value, GIST_STORE_LOC)
3861 return os.path.join(q.one().ui_value, GIST_STORE_LOC)
3823
3862
3824 def get_api_data(self):
3863 def get_api_data(self):
3825 """
3864 """
3826 Common function for generating gist related data for API
3865 Common function for generating gist related data for API
3827 """
3866 """
3828 gist = self
3867 gist = self
3829 data = {
3868 data = {
3830 'gist_id': gist.gist_id,
3869 'gist_id': gist.gist_id,
3831 'type': gist.gist_type,
3870 'type': gist.gist_type,
3832 'access_id': gist.gist_access_id,
3871 'access_id': gist.gist_access_id,
3833 'description': gist.gist_description,
3872 'description': gist.gist_description,
3834 'url': gist.gist_url(),
3873 'url': gist.gist_url(),
3835 'expires': gist.gist_expires,
3874 'expires': gist.gist_expires,
3836 'created_on': gist.created_on,
3875 'created_on': gist.created_on,
3837 'modified_at': gist.modified_at,
3876 'modified_at': gist.modified_at,
3838 'content': None,
3877 'content': None,
3839 'acl_level': gist.acl_level,
3878 'acl_level': gist.acl_level,
3840 }
3879 }
3841 return data
3880 return data
3842
3881
3843 def __json__(self):
3882 def __json__(self):
3844 data = dict(
3883 data = dict(
3845 )
3884 )
3846 data.update(self.get_api_data())
3885 data.update(self.get_api_data())
3847 return data
3886 return data
3848 # SCM functions
3887 # SCM functions
3849
3888
3850 def scm_instance(self, **kwargs):
3889 def scm_instance(self, **kwargs):
3851 full_repo_path = os.path.join(self.base_path(), self.gist_access_id)
3890 full_repo_path = os.path.join(self.base_path(), self.gist_access_id)
3852 return get_vcs_instance(
3891 return get_vcs_instance(
3853 repo_path=safe_str(full_repo_path), create=False)
3892 repo_path=safe_str(full_repo_path), create=False)
3854
3893
3855
3894
3856 class ExternalIdentity(Base, BaseModel):
3895 class ExternalIdentity(Base, BaseModel):
3857 __tablename__ = 'external_identities'
3896 __tablename__ = 'external_identities'
3858 __table_args__ = (
3897 __table_args__ = (
3859 Index('local_user_id_idx', 'local_user_id'),
3898 Index('local_user_id_idx', 'local_user_id'),
3860 Index('external_id_idx', 'external_id'),
3899 Index('external_id_idx', 'external_id'),
3861 {'extend_existing': True, 'mysql_engine': 'InnoDB',
3900 {'extend_existing': True, 'mysql_engine': 'InnoDB',
3862 'mysql_charset': 'utf8'})
3901 'mysql_charset': 'utf8'})
3863
3902
3864 external_id = Column('external_id', Unicode(255), default=u'',
3903 external_id = Column('external_id', Unicode(255), default=u'',
3865 primary_key=True)
3904 primary_key=True)
3866 external_username = Column('external_username', Unicode(1024), default=u'')
3905 external_username = Column('external_username', Unicode(1024), default=u'')
3867 local_user_id = Column('local_user_id', Integer(),
3906 local_user_id = Column('local_user_id', Integer(),
3868 ForeignKey('users.user_id'), primary_key=True)
3907 ForeignKey('users.user_id'), primary_key=True)
3869 provider_name = Column('provider_name', Unicode(255), default=u'',
3908 provider_name = Column('provider_name', Unicode(255), default=u'',
3870 primary_key=True)
3909 primary_key=True)
3871 access_token = Column('access_token', String(1024), default=u'')
3910 access_token = Column('access_token', String(1024), default=u'')
3872 alt_token = Column('alt_token', String(1024), default=u'')
3911 alt_token = Column('alt_token', String(1024), default=u'')
3873 token_secret = Column('token_secret', String(1024), default=u'')
3912 token_secret = Column('token_secret', String(1024), default=u'')
3874
3913
3875 @classmethod
3914 @classmethod
3876 def by_external_id_and_provider(cls, external_id, provider_name,
3915 def by_external_id_and_provider(cls, external_id, provider_name,
3877 local_user_id=None):
3916 local_user_id=None):
3878 """
3917 """
3879 Returns ExternalIdentity instance based on search params
3918 Returns ExternalIdentity instance based on search params
3880
3919
3881 :param external_id:
3920 :param external_id:
3882 :param provider_name:
3921 :param provider_name:
3883 :return: ExternalIdentity
3922 :return: ExternalIdentity
3884 """
3923 """
3885 query = cls.query()
3924 query = cls.query()
3886 query = query.filter(cls.external_id == external_id)
3925 query = query.filter(cls.external_id == external_id)
3887 query = query.filter(cls.provider_name == provider_name)
3926 query = query.filter(cls.provider_name == provider_name)
3888 if local_user_id:
3927 if local_user_id:
3889 query = query.filter(cls.local_user_id == local_user_id)
3928 query = query.filter(cls.local_user_id == local_user_id)
3890 return query.first()
3929 return query.first()
3891
3930
3892 @classmethod
3931 @classmethod
3893 def user_by_external_id_and_provider(cls, external_id, provider_name):
3932 def user_by_external_id_and_provider(cls, external_id, provider_name):
3894 """
3933 """
3895 Returns User instance based on search params
3934 Returns User instance based on search params
3896
3935
3897 :param external_id:
3936 :param external_id:
3898 :param provider_name:
3937 :param provider_name:
3899 :return: User
3938 :return: User
3900 """
3939 """
3901 query = User.query()
3940 query = User.query()
3902 query = query.filter(cls.external_id == external_id)
3941 query = query.filter(cls.external_id == external_id)
3903 query = query.filter(cls.provider_name == provider_name)
3942 query = query.filter(cls.provider_name == provider_name)
3904 query = query.filter(User.user_id == cls.local_user_id)
3943 query = query.filter(User.user_id == cls.local_user_id)
3905 return query.first()
3944 return query.first()
3906
3945
3907 @classmethod
3946 @classmethod
3908 def by_local_user_id(cls, local_user_id):
3947 def by_local_user_id(cls, local_user_id):
3909 """
3948 """
3910 Returns all tokens for user
3949 Returns all tokens for user
3911
3950
3912 :param local_user_id:
3951 :param local_user_id:
3913 :return: ExternalIdentity
3952 :return: ExternalIdentity
3914 """
3953 """
3915 query = cls.query()
3954 query = cls.query()
3916 query = query.filter(cls.local_user_id == local_user_id)
3955 query = query.filter(cls.local_user_id == local_user_id)
3917 return query
3956 return query
3918
3957
3919
3958
3920 class Integration(Base, BaseModel):
3959 class Integration(Base, BaseModel):
3921 __tablename__ = 'integrations'
3960 __tablename__ = 'integrations'
3922 __table_args__ = (
3961 __table_args__ = (
3923 {'extend_existing': True, 'mysql_engine': 'InnoDB',
3962 {'extend_existing': True, 'mysql_engine': 'InnoDB',
3924 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
3963 'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
3925 )
3964 )
3926
3965
3927 integration_id = Column('integration_id', Integer(), primary_key=True)
3966 integration_id = Column('integration_id', Integer(), primary_key=True)
3928 integration_type = Column('integration_type', String(255))
3967 integration_type = Column('integration_type', String(255))
3929 enabled = Column('enabled', Boolean(), nullable=False)
3968 enabled = Column('enabled', Boolean(), nullable=False)
3930 name = Column('name', String(255), nullable=False)
3969 name = Column('name', String(255), nullable=False)
3931 child_repos_only = Column('child_repos_only', Boolean(), nullable=False,
3970 child_repos_only = Column('child_repos_only', Boolean(), nullable=False,
3932 default=False)
3971 default=False)
3933
3972
3934 settings = Column(
3973 settings = Column(
3935 'settings_json', MutationObj.as_mutable(
3974 'settings_json', MutationObj.as_mutable(
3936 JsonType(dialect_map=dict(mysql=UnicodeText(16384)))))
3975 JsonType(dialect_map=dict(mysql=UnicodeText(16384)))))
3937 repo_id = Column(
3976 repo_id = Column(
3938 'repo_id', Integer(), ForeignKey('repositories.repo_id'),
3977 'repo_id', Integer(), ForeignKey('repositories.repo_id'),
3939 nullable=True, unique=None, default=None)
3978 nullable=True, unique=None, default=None)
3940 repo = relationship('Repository', lazy='joined')
3979 repo = relationship('Repository', lazy='joined')
3941
3980
3942 repo_group_id = Column(
3981 repo_group_id = Column(
3943 'repo_group_id', Integer(), ForeignKey('groups.group_id'),
3982 'repo_group_id', Integer(), ForeignKey('groups.group_id'),
3944 nullable=True, unique=None, default=None)
3983 nullable=True, unique=None, default=None)
3945 repo_group = relationship('RepoGroup', lazy='joined')
3984 repo_group = relationship('RepoGroup', lazy='joined')
3946
3985
3947 @property
3986 @property
3948 def scope(self):
3987 def scope(self):
3949 if self.repo:
3988 if self.repo:
3950 return repr(self.repo)
3989 return repr(self.repo)
3951 if self.repo_group:
3990 if self.repo_group:
3952 if self.child_repos_only:
3991 if self.child_repos_only:
3953 return repr(self.repo_group) + ' (child repos only)'
3992 return repr(self.repo_group) + ' (child repos only)'
3954 else:
3993 else:
3955 return repr(self.repo_group) + ' (recursive)'
3994 return repr(self.repo_group) + ' (recursive)'
3956 if self.child_repos_only:
3995 if self.child_repos_only:
3957 return 'root_repos'
3996 return 'root_repos'
3958 return 'global'
3997 return 'global'
3959
3998
3960 def __repr__(self):
3999 def __repr__(self):
3961 return '<Integration(%r, %r)>' % (self.integration_type, self.scope)
4000 return '<Integration(%r, %r)>' % (self.integration_type, self.scope)
3962
4001
3963
4002
3964 class RepoReviewRuleUser(Base, BaseModel):
4003 class RepoReviewRuleUser(Base, BaseModel):
3965 __tablename__ = 'repo_review_rules_users'
4004 __tablename__ = 'repo_review_rules_users'
3966 __table_args__ = (
4005 __table_args__ = (
3967 {'extend_existing': True, 'mysql_engine': 'InnoDB',
4006 {'extend_existing': True, 'mysql_engine': 'InnoDB',
3968 'mysql_charset': 'utf8', 'sqlite_autoincrement': True,}
4007 'mysql_charset': 'utf8', 'sqlite_autoincrement': True,}
3969 )
4008 )
3970 repo_review_rule_user_id = Column('repo_review_rule_user_id', Integer(), primary_key=True)
4009 repo_review_rule_user_id = Column('repo_review_rule_user_id', Integer(), primary_key=True)
3971 repo_review_rule_id = Column("repo_review_rule_id", Integer(), ForeignKey('repo_review_rules.repo_review_rule_id'))
4010 repo_review_rule_id = Column("repo_review_rule_id", Integer(), ForeignKey('repo_review_rules.repo_review_rule_id'))
3972 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False)
4011 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False)
3973 mandatory = Column("mandatory", Boolean(), nullable=False, default=False)
4012 mandatory = Column("mandatory", Boolean(), nullable=False, default=False)
3974 user = relationship('User')
4013 user = relationship('User')
3975
4014
3976 def rule_data(self):
4015 def rule_data(self):
3977 return {
4016 return {
3978 'mandatory': self.mandatory
4017 'mandatory': self.mandatory
3979 }
4018 }
3980
4019
3981
4020
3982 class RepoReviewRuleUserGroup(Base, BaseModel):
4021 class RepoReviewRuleUserGroup(Base, BaseModel):
3983 __tablename__ = 'repo_review_rules_users_groups'
4022 __tablename__ = 'repo_review_rules_users_groups'
3984 __table_args__ = (
4023 __table_args__ = (
3985 {'extend_existing': True, 'mysql_engine': 'InnoDB',
4024 {'extend_existing': True, 'mysql_engine': 'InnoDB',
3986 'mysql_charset': 'utf8', 'sqlite_autoincrement': True,}
4025 'mysql_charset': 'utf8', 'sqlite_autoincrement': True,}
3987 )
4026 )
3988 repo_review_rule_users_group_id = Column('repo_review_rule_users_group_id', Integer(), primary_key=True)
4027 repo_review_rule_users_group_id = Column('repo_review_rule_users_group_id', Integer(), primary_key=True)
3989 repo_review_rule_id = Column("repo_review_rule_id", Integer(), ForeignKey('repo_review_rules.repo_review_rule_id'))
4028 repo_review_rule_id = Column("repo_review_rule_id", Integer(), ForeignKey('repo_review_rules.repo_review_rule_id'))
3990 users_group_id = Column("users_group_id", Integer(),ForeignKey('users_groups.users_group_id'), nullable=False)
4029 users_group_id = Column("users_group_id", Integer(),ForeignKey('users_groups.users_group_id'), nullable=False)
3991 mandatory = Column("mandatory", Boolean(), nullable=False, default=False)
4030 mandatory = Column("mandatory", Boolean(), nullable=False, default=False)
3992 users_group = relationship('UserGroup')
4031 users_group = relationship('UserGroup')
3993
4032
3994 def rule_data(self):
4033 def rule_data(self):
3995 return {
4034 return {
3996 'mandatory': self.mandatory
4035 'mandatory': self.mandatory
3997 }
4036 }
3998
4037
3999
4038
4000 class RepoReviewRule(Base, BaseModel):
4039 class RepoReviewRule(Base, BaseModel):
4001 __tablename__ = 'repo_review_rules'
4040 __tablename__ = 'repo_review_rules'
4002 __table_args__ = (
4041 __table_args__ = (
4003 {'extend_existing': True, 'mysql_engine': 'InnoDB',
4042 {'extend_existing': True, 'mysql_engine': 'InnoDB',
4004 'mysql_charset': 'utf8', 'sqlite_autoincrement': True,}
4043 'mysql_charset': 'utf8', 'sqlite_autoincrement': True,}
4005 )
4044 )
4006
4045
4007 repo_review_rule_id = Column(
4046 repo_review_rule_id = Column(
4008 'repo_review_rule_id', Integer(), primary_key=True)
4047 'repo_review_rule_id', Integer(), primary_key=True)
4009 repo_id = Column(
4048 repo_id = Column(
4010 "repo_id", Integer(), ForeignKey('repositories.repo_id'))
4049 "repo_id", Integer(), ForeignKey('repositories.repo_id'))
4011 repo = relationship('Repository', backref='review_rules')
4050 repo = relationship('Repository', backref='review_rules')
4012
4051
4013 _branch_pattern = Column("branch_pattern", UnicodeText().with_variant(UnicodeText(255), 'mysql'), default=u'*') # glob
4052 _branch_pattern = Column("branch_pattern", UnicodeText().with_variant(UnicodeText(255), 'mysql'), default=u'*') # glob
4014 _file_pattern = Column("file_pattern", UnicodeText().with_variant(UnicodeText(255), 'mysql'), default=u'*') # glob
4053 _file_pattern = Column("file_pattern", UnicodeText().with_variant(UnicodeText(255), 'mysql'), default=u'*') # glob
4015
4054
4016 use_authors_for_review = Column("use_authors_for_review", Boolean(), nullable=False, default=False)
4055 use_authors_for_review = Column("use_authors_for_review", Boolean(), nullable=False, default=False)
4017 forbid_author_to_review = Column("forbid_author_to_review", Boolean(), nullable=False, default=False)
4056 forbid_author_to_review = Column("forbid_author_to_review", Boolean(), nullable=False, default=False)
4018 forbid_commit_author_to_review = Column("forbid_commit_author_to_review", Boolean(), nullable=False, default=False)
4057 forbid_commit_author_to_review = Column("forbid_commit_author_to_review", Boolean(), nullable=False, default=False)
4019 forbid_adding_reviewers = Column("forbid_adding_reviewers", Boolean(), nullable=False, default=False)
4058 forbid_adding_reviewers = Column("forbid_adding_reviewers", Boolean(), nullable=False, default=False)
4020
4059
4021 rule_users = relationship('RepoReviewRuleUser')
4060 rule_users = relationship('RepoReviewRuleUser')
4022 rule_user_groups = relationship('RepoReviewRuleUserGroup')
4061 rule_user_groups = relationship('RepoReviewRuleUserGroup')
4023
4062
4024 @hybrid_property
4063 @hybrid_property
4025 def branch_pattern(self):
4064 def branch_pattern(self):
4026 return self._branch_pattern or '*'
4065 return self._branch_pattern or '*'
4027
4066
4028 def _validate_glob(self, value):
4067 def _validate_glob(self, value):
4029 re.compile('^' + glob2re(value) + '$')
4068 re.compile('^' + glob2re(value) + '$')
4030
4069
4031 @branch_pattern.setter
4070 @branch_pattern.setter
4032 def branch_pattern(self, value):
4071 def branch_pattern(self, value):
4033 self._validate_glob(value)
4072 self._validate_glob(value)
4034 self._branch_pattern = value or '*'
4073 self._branch_pattern = value or '*'
4035
4074
4036 @hybrid_property
4075 @hybrid_property
4037 def file_pattern(self):
4076 def file_pattern(self):
4038 return self._file_pattern or '*'
4077 return self._file_pattern or '*'
4039
4078
4040 @file_pattern.setter
4079 @file_pattern.setter
4041 def file_pattern(self, value):
4080 def file_pattern(self, value):
4042 self._validate_glob(value)
4081 self._validate_glob(value)
4043 self._file_pattern = value or '*'
4082 self._file_pattern = value or '*'
4044
4083
4045 def matches(self, branch, files_changed):
4084 def matches(self, branch, files_changed):
4046 """
4085 """
4047 Check if this review rule matches a branch/files in a pull request
4086 Check if this review rule matches a branch/files in a pull request
4048
4087
4049 :param branch: branch name for the commit
4088 :param branch: branch name for the commit
4050 :param files_changed: list of file paths changed in the pull request
4089 :param files_changed: list of file paths changed in the pull request
4051 """
4090 """
4052
4091
4053 branch = branch or ''
4092 branch = branch or ''
4054 files_changed = files_changed or []
4093 files_changed = files_changed or []
4055
4094
4056 branch_matches = True
4095 branch_matches = True
4057 if branch:
4096 if branch:
4058 branch_regex = re.compile('^' + glob2re(self.branch_pattern) + '$')
4097 branch_regex = re.compile('^' + glob2re(self.branch_pattern) + '$')
4059 branch_matches = bool(branch_regex.search(branch))
4098 branch_matches = bool(branch_regex.search(branch))
4060
4099
4061 files_matches = True
4100 files_matches = True
4062 if self.file_pattern != '*':
4101 if self.file_pattern != '*':
4063 files_matches = False
4102 files_matches = False
4064 file_regex = re.compile(glob2re(self.file_pattern))
4103 file_regex = re.compile(glob2re(self.file_pattern))
4065 for filename in files_changed:
4104 for filename in files_changed:
4066 if file_regex.search(filename):
4105 if file_regex.search(filename):
4067 files_matches = True
4106 files_matches = True
4068 break
4107 break
4069
4108
4070 return branch_matches and files_matches
4109 return branch_matches and files_matches
4071
4110
4072 @property
4111 @property
4073 def review_users(self):
4112 def review_users(self):
4074 """ Returns the users which this rule applies to """
4113 """ Returns the users which this rule applies to """
4075
4114
4076 users = collections.OrderedDict()
4115 users = collections.OrderedDict()
4077
4116
4078 for rule_user in self.rule_users:
4117 for rule_user in self.rule_users:
4079 if rule_user.user.active:
4118 if rule_user.user.active:
4080 if rule_user.user not in users:
4119 if rule_user.user not in users:
4081 users[rule_user.user.username] = {
4120 users[rule_user.user.username] = {
4082 'user': rule_user.user,
4121 'user': rule_user.user,
4083 'source': 'user',
4122 'source': 'user',
4084 'source_data': {},
4123 'source_data': {},
4085 'data': rule_user.rule_data()
4124 'data': rule_user.rule_data()
4086 }
4125 }
4087
4126
4088 for rule_user_group in self.rule_user_groups:
4127 for rule_user_group in self.rule_user_groups:
4089 source_data = {
4128 source_data = {
4090 'name': rule_user_group.users_group.users_group_name,
4129 'name': rule_user_group.users_group.users_group_name,
4091 'members': len(rule_user_group.users_group.members)
4130 'members': len(rule_user_group.users_group.members)
4092 }
4131 }
4093 for member in rule_user_group.users_group.members:
4132 for member in rule_user_group.users_group.members:
4094 if member.user.active:
4133 if member.user.active:
4095 users[member.user.username] = {
4134 users[member.user.username] = {
4096 'user': member.user,
4135 'user': member.user,
4097 'source': 'user_group',
4136 'source': 'user_group',
4098 'source_data': source_data,
4137 'source_data': source_data,
4099 'data': rule_user_group.rule_data()
4138 'data': rule_user_group.rule_data()
4100 }
4139 }
4101
4140
4102 return users
4141 return users
4103
4142
4104 def __repr__(self):
4143 def __repr__(self):
4105 return '<RepoReviewerRule(id=%r, repo=%r)>' % (
4144 return '<RepoReviewerRule(id=%r, repo=%r)>' % (
4106 self.repo_review_rule_id, self.repo)
4145 self.repo_review_rule_id, self.repo)
4107
4146
4108
4147
4109 class DbMigrateVersion(Base, BaseModel):
4148 class DbMigrateVersion(Base, BaseModel):
4110 __tablename__ = 'db_migrate_version'
4149 __tablename__ = 'db_migrate_version'
4111 __table_args__ = (
4150 __table_args__ = (
4112 {'extend_existing': True, 'mysql_engine': 'InnoDB',
4151 {'extend_existing': True, 'mysql_engine': 'InnoDB',
4113 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
4152 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
4114 )
4153 )
4115 repository_id = Column('repository_id', String(250), primary_key=True)
4154 repository_id = Column('repository_id', String(250), primary_key=True)
4116 repository_path = Column('repository_path', Text)
4155 repository_path = Column('repository_path', Text)
4117 version = Column('version', Integer)
4156 version = Column('version', Integer)
4118
4157
4119
4158
4120 class DbSession(Base, BaseModel):
4159 class DbSession(Base, BaseModel):
4121 __tablename__ = 'db_session'
4160 __tablename__ = 'db_session'
4122 __table_args__ = (
4161 __table_args__ = (
4123 {'extend_existing': True, 'mysql_engine': 'InnoDB',
4162 {'extend_existing': True, 'mysql_engine': 'InnoDB',
4124 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
4163 'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
4125 )
4164 )
4126
4165
4127 def __repr__(self):
4166 def __repr__(self):
4128 return '<DB:DbSession({})>'.format(self.id)
4167 return '<DB:DbSession({})>'.format(self.id)
4129
4168
4130 id = Column('id', Integer())
4169 id = Column('id', Integer())
4131 namespace = Column('namespace', String(255), primary_key=True)
4170 namespace = Column('namespace', String(255), primary_key=True)
4132 accessed = Column('accessed', DateTime, nullable=False)
4171 accessed = Column('accessed', DateTime, nullable=False)
4133 created = Column('created', DateTime, nullable=False)
4172 created = Column('created', DateTime, nullable=False)
4134 data = Column('data', PickleType, nullable=False)
4173 data = Column('data', PickleType, nullable=False)
@@ -1,226 +1,230 b''
1
1
2 /******************************************************************************
2 /******************************************************************************
3 * *
3 * *
4 * DO NOT CHANGE THIS FILE MANUALLY *
4 * DO NOT CHANGE THIS FILE MANUALLY *
5 * *
5 * *
6 * *
6 * *
7 * This file is automatically generated when the app starts up with *
7 * This file is automatically generated when the app starts up with *
8 * generate_js_files = true *
8 * generate_js_files = true *
9 * *
9 * *
10 * To add a route here pass jsroute=True to the route definition in the app *
10 * To add a route here pass jsroute=True to the route definition in the app *
11 * *
11 * *
12 ******************************************************************************/
12 ******************************************************************************/
13 function registerRCRoutes() {
13 function registerRCRoutes() {
14 // routes registration
14 // routes registration
15 pyroutes.register('new_repo', '/_admin/create_repository', []);
15 pyroutes.register('new_repo', '/_admin/create_repository', []);
16 pyroutes.register('edit_user', '/_admin/users/%(user_id)s/edit', ['user_id']);
16 pyroutes.register('edit_user', '/_admin/users/%(user_id)s/edit', ['user_id']);
17 pyroutes.register('favicon', '/favicon.ico', []);
17 pyroutes.register('favicon', '/favicon.ico', []);
18 pyroutes.register('robots', '/robots.txt', []);
18 pyroutes.register('robots', '/robots.txt', []);
19 pyroutes.register('auth_home', '/_admin/auth*traverse', []);
19 pyroutes.register('auth_home', '/_admin/auth*traverse', []);
20 pyroutes.register('global_integrations_new', '/_admin/integrations/new', []);
20 pyroutes.register('global_integrations_new', '/_admin/integrations/new', []);
21 pyroutes.register('global_integrations_home', '/_admin/integrations', []);
21 pyroutes.register('global_integrations_home', '/_admin/integrations', []);
22 pyroutes.register('global_integrations_list', '/_admin/integrations/%(integration)s', ['integration']);
22 pyroutes.register('global_integrations_list', '/_admin/integrations/%(integration)s', ['integration']);
23 pyroutes.register('global_integrations_create', '/_admin/integrations/%(integration)s/new', ['integration']);
23 pyroutes.register('global_integrations_create', '/_admin/integrations/%(integration)s/new', ['integration']);
24 pyroutes.register('global_integrations_edit', '/_admin/integrations/%(integration)s/%(integration_id)s', ['integration', 'integration_id']);
24 pyroutes.register('global_integrations_edit', '/_admin/integrations/%(integration)s/%(integration_id)s', ['integration', 'integration_id']);
25 pyroutes.register('repo_group_integrations_home', '/%(repo_group_name)s/settings/integrations', ['repo_group_name']);
25 pyroutes.register('repo_group_integrations_home', '/%(repo_group_name)s/settings/integrations', ['repo_group_name']);
26 pyroutes.register('repo_group_integrations_new', '/%(repo_group_name)s/settings/integrations/new', ['repo_group_name']);
26 pyroutes.register('repo_group_integrations_new', '/%(repo_group_name)s/settings/integrations/new', ['repo_group_name']);
27 pyroutes.register('repo_group_integrations_list', '/%(repo_group_name)s/settings/integrations/%(integration)s', ['repo_group_name', 'integration']);
27 pyroutes.register('repo_group_integrations_list', '/%(repo_group_name)s/settings/integrations/%(integration)s', ['repo_group_name', 'integration']);
28 pyroutes.register('repo_group_integrations_create', '/%(repo_group_name)s/settings/integrations/%(integration)s/new', ['repo_group_name', 'integration']);
28 pyroutes.register('repo_group_integrations_create', '/%(repo_group_name)s/settings/integrations/%(integration)s/new', ['repo_group_name', 'integration']);
29 pyroutes.register('repo_group_integrations_edit', '/%(repo_group_name)s/settings/integrations/%(integration)s/%(integration_id)s', ['repo_group_name', 'integration', 'integration_id']);
29 pyroutes.register('repo_group_integrations_edit', '/%(repo_group_name)s/settings/integrations/%(integration)s/%(integration_id)s', ['repo_group_name', 'integration', 'integration_id']);
30 pyroutes.register('repo_integrations_home', '/%(repo_name)s/settings/integrations', ['repo_name']);
30 pyroutes.register('repo_integrations_home', '/%(repo_name)s/settings/integrations', ['repo_name']);
31 pyroutes.register('repo_integrations_new', '/%(repo_name)s/settings/integrations/new', ['repo_name']);
31 pyroutes.register('repo_integrations_new', '/%(repo_name)s/settings/integrations/new', ['repo_name']);
32 pyroutes.register('repo_integrations_list', '/%(repo_name)s/settings/integrations/%(integration)s', ['repo_name', 'integration']);
32 pyroutes.register('repo_integrations_list', '/%(repo_name)s/settings/integrations/%(integration)s', ['repo_name', 'integration']);
33 pyroutes.register('repo_integrations_create', '/%(repo_name)s/settings/integrations/%(integration)s/new', ['repo_name', 'integration']);
33 pyroutes.register('repo_integrations_create', '/%(repo_name)s/settings/integrations/%(integration)s/new', ['repo_name', 'integration']);
34 pyroutes.register('repo_integrations_edit', '/%(repo_name)s/settings/integrations/%(integration)s/%(integration_id)s', ['repo_name', 'integration', 'integration_id']);
34 pyroutes.register('repo_integrations_edit', '/%(repo_name)s/settings/integrations/%(integration)s/%(integration_id)s', ['repo_name', 'integration', 'integration_id']);
35 pyroutes.register('ops_ping', '/_admin/ops/ping', []);
35 pyroutes.register('ops_ping', '/_admin/ops/ping', []);
36 pyroutes.register('ops_error_test', '/_admin/ops/error', []);
36 pyroutes.register('ops_error_test', '/_admin/ops/error', []);
37 pyroutes.register('ops_redirect_test', '/_admin/ops/redirect', []);
37 pyroutes.register('ops_redirect_test', '/_admin/ops/redirect', []);
38 pyroutes.register('admin_home', '/_admin', []);
38 pyroutes.register('admin_home', '/_admin', []);
39 pyroutes.register('admin_audit_logs', '/_admin/audit_logs', []);
39 pyroutes.register('admin_audit_logs', '/_admin/audit_logs', []);
40 pyroutes.register('pull_requests_global_0', '/_admin/pull_requests/%(pull_request_id)s', ['pull_request_id']);
40 pyroutes.register('pull_requests_global_0', '/_admin/pull_requests/%(pull_request_id)s', ['pull_request_id']);
41 pyroutes.register('pull_requests_global_1', '/_admin/pull-requests/%(pull_request_id)s', ['pull_request_id']);
41 pyroutes.register('pull_requests_global_1', '/_admin/pull-requests/%(pull_request_id)s', ['pull_request_id']);
42 pyroutes.register('pull_requests_global', '/_admin/pull-request/%(pull_request_id)s', ['pull_request_id']);
42 pyroutes.register('pull_requests_global', '/_admin/pull-request/%(pull_request_id)s', ['pull_request_id']);
43 pyroutes.register('admin_settings_open_source', '/_admin/settings/open_source', []);
43 pyroutes.register('admin_settings_open_source', '/_admin/settings/open_source', []);
44 pyroutes.register('admin_settings_vcs_svn_generate_cfg', '/_admin/settings/vcs/svn_generate_cfg', []);
44 pyroutes.register('admin_settings_vcs_svn_generate_cfg', '/_admin/settings/vcs/svn_generate_cfg', []);
45 pyroutes.register('admin_settings_system', '/_admin/settings/system', []);
45 pyroutes.register('admin_settings_system', '/_admin/settings/system', []);
46 pyroutes.register('admin_settings_system_update', '/_admin/settings/system/updates', []);
46 pyroutes.register('admin_settings_system_update', '/_admin/settings/system/updates', []);
47 pyroutes.register('admin_settings_sessions', '/_admin/settings/sessions', []);
47 pyroutes.register('admin_settings_sessions', '/_admin/settings/sessions', []);
48 pyroutes.register('admin_settings_sessions_cleanup', '/_admin/settings/sessions/cleanup', []);
48 pyroutes.register('admin_settings_sessions_cleanup', '/_admin/settings/sessions/cleanup', []);
49 pyroutes.register('admin_settings_process_management', '/_admin/settings/process_management', []);
49 pyroutes.register('admin_settings_process_management', '/_admin/settings/process_management', []);
50 pyroutes.register('admin_settings_process_management_signal', '/_admin/settings/process_management/signal', []);
50 pyroutes.register('admin_settings_process_management_signal', '/_admin/settings/process_management/signal', []);
51 pyroutes.register('admin_permissions_application', '/_admin/permissions/application', []);
51 pyroutes.register('admin_permissions_application', '/_admin/permissions/application', []);
52 pyroutes.register('admin_permissions_application_update', '/_admin/permissions/application/update', []);
52 pyroutes.register('admin_permissions_application_update', '/_admin/permissions/application/update', []);
53 pyroutes.register('admin_permissions_global', '/_admin/permissions/global', []);
53 pyroutes.register('admin_permissions_global', '/_admin/permissions/global', []);
54 pyroutes.register('admin_permissions_global_update', '/_admin/permissions/global/update', []);
54 pyroutes.register('admin_permissions_global_update', '/_admin/permissions/global/update', []);
55 pyroutes.register('admin_permissions_object', '/_admin/permissions/object', []);
55 pyroutes.register('admin_permissions_object', '/_admin/permissions/object', []);
56 pyroutes.register('admin_permissions_object_update', '/_admin/permissions/object/update', []);
56 pyroutes.register('admin_permissions_object_update', '/_admin/permissions/object/update', []);
57 pyroutes.register('admin_permissions_ips', '/_admin/permissions/ips', []);
57 pyroutes.register('admin_permissions_ips', '/_admin/permissions/ips', []);
58 pyroutes.register('admin_permissions_overview', '/_admin/permissions/overview', []);
58 pyroutes.register('admin_permissions_overview', '/_admin/permissions/overview', []);
59 pyroutes.register('admin_permissions_auth_token_access', '/_admin/permissions/auth_token_access', []);
59 pyroutes.register('admin_permissions_auth_token_access', '/_admin/permissions/auth_token_access', []);
60 pyroutes.register('users', '/_admin/users', []);
60 pyroutes.register('users', '/_admin/users', []);
61 pyroutes.register('users_data', '/_admin/users_data', []);
61 pyroutes.register('users_data', '/_admin/users_data', []);
62 pyroutes.register('edit_user_auth_tokens', '/_admin/users/%(user_id)s/edit/auth_tokens', ['user_id']);
62 pyroutes.register('edit_user_auth_tokens', '/_admin/users/%(user_id)s/edit/auth_tokens', ['user_id']);
63 pyroutes.register('edit_user_auth_tokens_add', '/_admin/users/%(user_id)s/edit/auth_tokens/new', ['user_id']);
63 pyroutes.register('edit_user_auth_tokens_add', '/_admin/users/%(user_id)s/edit/auth_tokens/new', ['user_id']);
64 pyroutes.register('edit_user_auth_tokens_delete', '/_admin/users/%(user_id)s/edit/auth_tokens/delete', ['user_id']);
64 pyroutes.register('edit_user_auth_tokens_delete', '/_admin/users/%(user_id)s/edit/auth_tokens/delete', ['user_id']);
65 pyroutes.register('edit_user_ssh_keys', '/_admin/users/%(user_id)s/edit/ssh_keys', ['user_id']);
66 pyroutes.register('edit_user_ssh_keys_generate_keypair', '/_admin/users/%(user_id)s/edit/ssh_keys/generate', ['user_id']);
67 pyroutes.register('edit_user_ssh_keys_add', '/_admin/users/%(user_id)s/edit/ssh_keys/new', ['user_id']);
68 pyroutes.register('edit_user_ssh_keys_delete', '/_admin/users/%(user_id)s/edit/ssh_keys/delete', ['user_id']);
65 pyroutes.register('edit_user_emails', '/_admin/users/%(user_id)s/edit/emails', ['user_id']);
69 pyroutes.register('edit_user_emails', '/_admin/users/%(user_id)s/edit/emails', ['user_id']);
66 pyroutes.register('edit_user_emails_add', '/_admin/users/%(user_id)s/edit/emails/new', ['user_id']);
70 pyroutes.register('edit_user_emails_add', '/_admin/users/%(user_id)s/edit/emails/new', ['user_id']);
67 pyroutes.register('edit_user_emails_delete', '/_admin/users/%(user_id)s/edit/emails/delete', ['user_id']);
71 pyroutes.register('edit_user_emails_delete', '/_admin/users/%(user_id)s/edit/emails/delete', ['user_id']);
68 pyroutes.register('edit_user_ips', '/_admin/users/%(user_id)s/edit/ips', ['user_id']);
72 pyroutes.register('edit_user_ips', '/_admin/users/%(user_id)s/edit/ips', ['user_id']);
69 pyroutes.register('edit_user_ips_add', '/_admin/users/%(user_id)s/edit/ips/new', ['user_id']);
73 pyroutes.register('edit_user_ips_add', '/_admin/users/%(user_id)s/edit/ips/new', ['user_id']);
70 pyroutes.register('edit_user_ips_delete', '/_admin/users/%(user_id)s/edit/ips/delete', ['user_id']);
74 pyroutes.register('edit_user_ips_delete', '/_admin/users/%(user_id)s/edit/ips/delete', ['user_id']);
71 pyroutes.register('edit_user_groups_management', '/_admin/users/%(user_id)s/edit/groups_management', ['user_id']);
75 pyroutes.register('edit_user_groups_management', '/_admin/users/%(user_id)s/edit/groups_management', ['user_id']);
72 pyroutes.register('edit_user_groups_management_updates', '/_admin/users/%(user_id)s/edit/edit_user_groups_management/updates', ['user_id']);
76 pyroutes.register('edit_user_groups_management_updates', '/_admin/users/%(user_id)s/edit/edit_user_groups_management/updates', ['user_id']);
73 pyroutes.register('edit_user_audit_logs', '/_admin/users/%(user_id)s/edit/audit', ['user_id']);
77 pyroutes.register('edit_user_audit_logs', '/_admin/users/%(user_id)s/edit/audit', ['user_id']);
74 pyroutes.register('user_groups', '/_admin/user_groups', []);
78 pyroutes.register('user_groups', '/_admin/user_groups', []);
75 pyroutes.register('user_groups_data', '/_admin/user_groups_data', []);
79 pyroutes.register('user_groups_data', '/_admin/user_groups_data', []);
76 pyroutes.register('user_group_members_data', '/_admin/user_groups/%(user_group_id)s/members', ['user_group_id']);
80 pyroutes.register('user_group_members_data', '/_admin/user_groups/%(user_group_id)s/members', ['user_group_id']);
77 pyroutes.register('channelstream_connect', '/_admin/channelstream/connect', []);
81 pyroutes.register('channelstream_connect', '/_admin/channelstream/connect', []);
78 pyroutes.register('channelstream_subscribe', '/_admin/channelstream/subscribe', []);
82 pyroutes.register('channelstream_subscribe', '/_admin/channelstream/subscribe', []);
79 pyroutes.register('channelstream_proxy', '/_channelstream', []);
83 pyroutes.register('channelstream_proxy', '/_channelstream', []);
80 pyroutes.register('login', '/_admin/login', []);
84 pyroutes.register('login', '/_admin/login', []);
81 pyroutes.register('logout', '/_admin/logout', []);
85 pyroutes.register('logout', '/_admin/logout', []);
82 pyroutes.register('register', '/_admin/register', []);
86 pyroutes.register('register', '/_admin/register', []);
83 pyroutes.register('reset_password', '/_admin/password_reset', []);
87 pyroutes.register('reset_password', '/_admin/password_reset', []);
84 pyroutes.register('reset_password_confirmation', '/_admin/password_reset_confirmation', []);
88 pyroutes.register('reset_password_confirmation', '/_admin/password_reset_confirmation', []);
85 pyroutes.register('home', '/', []);
89 pyroutes.register('home', '/', []);
86 pyroutes.register('user_autocomplete_data', '/_users', []);
90 pyroutes.register('user_autocomplete_data', '/_users', []);
87 pyroutes.register('user_group_autocomplete_data', '/_user_groups', []);
91 pyroutes.register('user_group_autocomplete_data', '/_user_groups', []);
88 pyroutes.register('repo_list_data', '/_repos', []);
92 pyroutes.register('repo_list_data', '/_repos', []);
89 pyroutes.register('goto_switcher_data', '/_goto_data', []);
93 pyroutes.register('goto_switcher_data', '/_goto_data', []);
90 pyroutes.register('journal', '/_admin/journal', []);
94 pyroutes.register('journal', '/_admin/journal', []);
91 pyroutes.register('journal_rss', '/_admin/journal/rss', []);
95 pyroutes.register('journal_rss', '/_admin/journal/rss', []);
92 pyroutes.register('journal_atom', '/_admin/journal/atom', []);
96 pyroutes.register('journal_atom', '/_admin/journal/atom', []);
93 pyroutes.register('journal_public', '/_admin/public_journal', []);
97 pyroutes.register('journal_public', '/_admin/public_journal', []);
94 pyroutes.register('journal_public_atom', '/_admin/public_journal/atom', []);
98 pyroutes.register('journal_public_atom', '/_admin/public_journal/atom', []);
95 pyroutes.register('journal_public_atom_old', '/_admin/public_journal_atom', []);
99 pyroutes.register('journal_public_atom_old', '/_admin/public_journal_atom', []);
96 pyroutes.register('journal_public_rss', '/_admin/public_journal/rss', []);
100 pyroutes.register('journal_public_rss', '/_admin/public_journal/rss', []);
97 pyroutes.register('journal_public_rss_old', '/_admin/public_journal_rss', []);
101 pyroutes.register('journal_public_rss_old', '/_admin/public_journal_rss', []);
98 pyroutes.register('toggle_following', '/_admin/toggle_following', []);
102 pyroutes.register('toggle_following', '/_admin/toggle_following', []);
99 pyroutes.register('repo_creating', '/%(repo_name)s/repo_creating', ['repo_name']);
103 pyroutes.register('repo_creating', '/%(repo_name)s/repo_creating', ['repo_name']);
100 pyroutes.register('repo_creating_check', '/%(repo_name)s/repo_creating_check', ['repo_name']);
104 pyroutes.register('repo_creating_check', '/%(repo_name)s/repo_creating_check', ['repo_name']);
101 pyroutes.register('repo_summary_explicit', '/%(repo_name)s/summary', ['repo_name']);
105 pyroutes.register('repo_summary_explicit', '/%(repo_name)s/summary', ['repo_name']);
102 pyroutes.register('repo_summary_commits', '/%(repo_name)s/summary-commits', ['repo_name']);
106 pyroutes.register('repo_summary_commits', '/%(repo_name)s/summary-commits', ['repo_name']);
103 pyroutes.register('repo_commit', '/%(repo_name)s/changeset/%(commit_id)s', ['repo_name', 'commit_id']);
107 pyroutes.register('repo_commit', '/%(repo_name)s/changeset/%(commit_id)s', ['repo_name', 'commit_id']);
104 pyroutes.register('repo_commit_children', '/%(repo_name)s/changeset_children/%(commit_id)s', ['repo_name', 'commit_id']);
108 pyroutes.register('repo_commit_children', '/%(repo_name)s/changeset_children/%(commit_id)s', ['repo_name', 'commit_id']);
105 pyroutes.register('repo_commit_parents', '/%(repo_name)s/changeset_parents/%(commit_id)s', ['repo_name', 'commit_id']);
109 pyroutes.register('repo_commit_parents', '/%(repo_name)s/changeset_parents/%(commit_id)s', ['repo_name', 'commit_id']);
106 pyroutes.register('repo_commit_raw', '/%(repo_name)s/changeset-diff/%(commit_id)s', ['repo_name', 'commit_id']);
110 pyroutes.register('repo_commit_raw', '/%(repo_name)s/changeset-diff/%(commit_id)s', ['repo_name', 'commit_id']);
107 pyroutes.register('repo_commit_patch', '/%(repo_name)s/changeset-patch/%(commit_id)s', ['repo_name', 'commit_id']);
111 pyroutes.register('repo_commit_patch', '/%(repo_name)s/changeset-patch/%(commit_id)s', ['repo_name', 'commit_id']);
108 pyroutes.register('repo_commit_download', '/%(repo_name)s/changeset-download/%(commit_id)s', ['repo_name', 'commit_id']);
112 pyroutes.register('repo_commit_download', '/%(repo_name)s/changeset-download/%(commit_id)s', ['repo_name', 'commit_id']);
109 pyroutes.register('repo_commit_data', '/%(repo_name)s/changeset-data/%(commit_id)s', ['repo_name', 'commit_id']);
113 pyroutes.register('repo_commit_data', '/%(repo_name)s/changeset-data/%(commit_id)s', ['repo_name', 'commit_id']);
110 pyroutes.register('repo_commit_comment_create', '/%(repo_name)s/changeset/%(commit_id)s/comment/create', ['repo_name', 'commit_id']);
114 pyroutes.register('repo_commit_comment_create', '/%(repo_name)s/changeset/%(commit_id)s/comment/create', ['repo_name', 'commit_id']);
111 pyroutes.register('repo_commit_comment_preview', '/%(repo_name)s/changeset/%(commit_id)s/comment/preview', ['repo_name', 'commit_id']);
115 pyroutes.register('repo_commit_comment_preview', '/%(repo_name)s/changeset/%(commit_id)s/comment/preview', ['repo_name', 'commit_id']);
112 pyroutes.register('repo_commit_comment_delete', '/%(repo_name)s/changeset/%(commit_id)s/comment/%(comment_id)s/delete', ['repo_name', 'commit_id', 'comment_id']);
116 pyroutes.register('repo_commit_comment_delete', '/%(repo_name)s/changeset/%(commit_id)s/comment/%(comment_id)s/delete', ['repo_name', 'commit_id', 'comment_id']);
113 pyroutes.register('repo_commit_raw_deprecated', '/%(repo_name)s/raw-changeset/%(commit_id)s', ['repo_name', 'commit_id']);
117 pyroutes.register('repo_commit_raw_deprecated', '/%(repo_name)s/raw-changeset/%(commit_id)s', ['repo_name', 'commit_id']);
114 pyroutes.register('repo_archivefile', '/%(repo_name)s/archive/%(fname)s', ['repo_name', 'fname']);
118 pyroutes.register('repo_archivefile', '/%(repo_name)s/archive/%(fname)s', ['repo_name', 'fname']);
115 pyroutes.register('repo_files_diff', '/%(repo_name)s/diff/%(f_path)s', ['repo_name', 'f_path']);
119 pyroutes.register('repo_files_diff', '/%(repo_name)s/diff/%(f_path)s', ['repo_name', 'f_path']);
116 pyroutes.register('repo_files_diff_2way_redirect', '/%(repo_name)s/diff-2way/%(f_path)s', ['repo_name', 'f_path']);
120 pyroutes.register('repo_files_diff_2way_redirect', '/%(repo_name)s/diff-2way/%(f_path)s', ['repo_name', 'f_path']);
117 pyroutes.register('repo_files', '/%(repo_name)s/files/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']);
121 pyroutes.register('repo_files', '/%(repo_name)s/files/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']);
118 pyroutes.register('repo_files:default_path', '/%(repo_name)s/files/%(commit_id)s/', ['repo_name', 'commit_id']);
122 pyroutes.register('repo_files:default_path', '/%(repo_name)s/files/%(commit_id)s/', ['repo_name', 'commit_id']);
119 pyroutes.register('repo_files:default_commit', '/%(repo_name)s/files', ['repo_name']);
123 pyroutes.register('repo_files:default_commit', '/%(repo_name)s/files', ['repo_name']);
120 pyroutes.register('repo_files:rendered', '/%(repo_name)s/render/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']);
124 pyroutes.register('repo_files:rendered', '/%(repo_name)s/render/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']);
121 pyroutes.register('repo_files:annotated', '/%(repo_name)s/annotate/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']);
125 pyroutes.register('repo_files:annotated', '/%(repo_name)s/annotate/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']);
122 pyroutes.register('repo_files:annotated_previous', '/%(repo_name)s/annotate-previous/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']);
126 pyroutes.register('repo_files:annotated_previous', '/%(repo_name)s/annotate-previous/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']);
123 pyroutes.register('repo_nodetree_full', '/%(repo_name)s/nodetree_full/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']);
127 pyroutes.register('repo_nodetree_full', '/%(repo_name)s/nodetree_full/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']);
124 pyroutes.register('repo_nodetree_full:default_path', '/%(repo_name)s/nodetree_full/%(commit_id)s/', ['repo_name', 'commit_id']);
128 pyroutes.register('repo_nodetree_full:default_path', '/%(repo_name)s/nodetree_full/%(commit_id)s/', ['repo_name', 'commit_id']);
125 pyroutes.register('repo_files_nodelist', '/%(repo_name)s/nodelist/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']);
129 pyroutes.register('repo_files_nodelist', '/%(repo_name)s/nodelist/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']);
126 pyroutes.register('repo_file_raw', '/%(repo_name)s/raw/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']);
130 pyroutes.register('repo_file_raw', '/%(repo_name)s/raw/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']);
127 pyroutes.register('repo_file_download', '/%(repo_name)s/download/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']);
131 pyroutes.register('repo_file_download', '/%(repo_name)s/download/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']);
128 pyroutes.register('repo_file_download:legacy', '/%(repo_name)s/rawfile/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']);
132 pyroutes.register('repo_file_download:legacy', '/%(repo_name)s/rawfile/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']);
129 pyroutes.register('repo_file_history', '/%(repo_name)s/history/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']);
133 pyroutes.register('repo_file_history', '/%(repo_name)s/history/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']);
130 pyroutes.register('repo_file_authors', '/%(repo_name)s/authors/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']);
134 pyroutes.register('repo_file_authors', '/%(repo_name)s/authors/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']);
131 pyroutes.register('repo_files_remove_file', '/%(repo_name)s/remove_file/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']);
135 pyroutes.register('repo_files_remove_file', '/%(repo_name)s/remove_file/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']);
132 pyroutes.register('repo_files_delete_file', '/%(repo_name)s/delete_file/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']);
136 pyroutes.register('repo_files_delete_file', '/%(repo_name)s/delete_file/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']);
133 pyroutes.register('repo_files_edit_file', '/%(repo_name)s/edit_file/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']);
137 pyroutes.register('repo_files_edit_file', '/%(repo_name)s/edit_file/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']);
134 pyroutes.register('repo_files_update_file', '/%(repo_name)s/update_file/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']);
138 pyroutes.register('repo_files_update_file', '/%(repo_name)s/update_file/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']);
135 pyroutes.register('repo_files_add_file', '/%(repo_name)s/add_file/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']);
139 pyroutes.register('repo_files_add_file', '/%(repo_name)s/add_file/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']);
136 pyroutes.register('repo_files_create_file', '/%(repo_name)s/create_file/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']);
140 pyroutes.register('repo_files_create_file', '/%(repo_name)s/create_file/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']);
137 pyroutes.register('repo_refs_data', '/%(repo_name)s/refs-data', ['repo_name']);
141 pyroutes.register('repo_refs_data', '/%(repo_name)s/refs-data', ['repo_name']);
138 pyroutes.register('repo_refs_changelog_data', '/%(repo_name)s/refs-data-changelog', ['repo_name']);
142 pyroutes.register('repo_refs_changelog_data', '/%(repo_name)s/refs-data-changelog', ['repo_name']);
139 pyroutes.register('repo_stats', '/%(repo_name)s/repo_stats/%(commit_id)s', ['repo_name', 'commit_id']);
143 pyroutes.register('repo_stats', '/%(repo_name)s/repo_stats/%(commit_id)s', ['repo_name', 'commit_id']);
140 pyroutes.register('repo_changelog', '/%(repo_name)s/changelog', ['repo_name']);
144 pyroutes.register('repo_changelog', '/%(repo_name)s/changelog', ['repo_name']);
141 pyroutes.register('repo_changelog_file', '/%(repo_name)s/changelog/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']);
145 pyroutes.register('repo_changelog_file', '/%(repo_name)s/changelog/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']);
142 pyroutes.register('repo_changelog_elements', '/%(repo_name)s/changelog_elements', ['repo_name']);
146 pyroutes.register('repo_changelog_elements', '/%(repo_name)s/changelog_elements', ['repo_name']);
143 pyroutes.register('repo_compare_select', '/%(repo_name)s/compare', ['repo_name']);
147 pyroutes.register('repo_compare_select', '/%(repo_name)s/compare', ['repo_name']);
144 pyroutes.register('repo_compare', '/%(repo_name)s/compare/%(source_ref_type)s@%(source_ref)s...%(target_ref_type)s@%(target_ref)s', ['repo_name', 'source_ref_type', 'source_ref', 'target_ref_type', 'target_ref']);
148 pyroutes.register('repo_compare', '/%(repo_name)s/compare/%(source_ref_type)s@%(source_ref)s...%(target_ref_type)s@%(target_ref)s', ['repo_name', 'source_ref_type', 'source_ref', 'target_ref_type', 'target_ref']);
145 pyroutes.register('tags_home', '/%(repo_name)s/tags', ['repo_name']);
149 pyroutes.register('tags_home', '/%(repo_name)s/tags', ['repo_name']);
146 pyroutes.register('branches_home', '/%(repo_name)s/branches', ['repo_name']);
150 pyroutes.register('branches_home', '/%(repo_name)s/branches', ['repo_name']);
147 pyroutes.register('bookmarks_home', '/%(repo_name)s/bookmarks', ['repo_name']);
151 pyroutes.register('bookmarks_home', '/%(repo_name)s/bookmarks', ['repo_name']);
148 pyroutes.register('repo_fork_new', '/%(repo_name)s/fork', ['repo_name']);
152 pyroutes.register('repo_fork_new', '/%(repo_name)s/fork', ['repo_name']);
149 pyroutes.register('repo_fork_create', '/%(repo_name)s/fork/create', ['repo_name']);
153 pyroutes.register('repo_fork_create', '/%(repo_name)s/fork/create', ['repo_name']);
150 pyroutes.register('repo_forks_show_all', '/%(repo_name)s/forks', ['repo_name']);
154 pyroutes.register('repo_forks_show_all', '/%(repo_name)s/forks', ['repo_name']);
151 pyroutes.register('repo_forks_data', '/%(repo_name)s/forks/data', ['repo_name']);
155 pyroutes.register('repo_forks_data', '/%(repo_name)s/forks/data', ['repo_name']);
152 pyroutes.register('pullrequest_show', '/%(repo_name)s/pull-request/%(pull_request_id)s', ['repo_name', 'pull_request_id']);
156 pyroutes.register('pullrequest_show', '/%(repo_name)s/pull-request/%(pull_request_id)s', ['repo_name', 'pull_request_id']);
153 pyroutes.register('pullrequest_show_all', '/%(repo_name)s/pull-request', ['repo_name']);
157 pyroutes.register('pullrequest_show_all', '/%(repo_name)s/pull-request', ['repo_name']);
154 pyroutes.register('pullrequest_show_all_data', '/%(repo_name)s/pull-request-data', ['repo_name']);
158 pyroutes.register('pullrequest_show_all_data', '/%(repo_name)s/pull-request-data', ['repo_name']);
155 pyroutes.register('pullrequest_repo_refs', '/%(repo_name)s/pull-request/refs/%(target_repo_name)s', ['repo_name', 'target_repo_name']);
159 pyroutes.register('pullrequest_repo_refs', '/%(repo_name)s/pull-request/refs/%(target_repo_name)s', ['repo_name', 'target_repo_name']);
156 pyroutes.register('pullrequest_repo_destinations', '/%(repo_name)s/pull-request/repo-destinations', ['repo_name']);
160 pyroutes.register('pullrequest_repo_destinations', '/%(repo_name)s/pull-request/repo-destinations', ['repo_name']);
157 pyroutes.register('pullrequest_new', '/%(repo_name)s/pull-request/new', ['repo_name']);
161 pyroutes.register('pullrequest_new', '/%(repo_name)s/pull-request/new', ['repo_name']);
158 pyroutes.register('pullrequest_create', '/%(repo_name)s/pull-request/create', ['repo_name']);
162 pyroutes.register('pullrequest_create', '/%(repo_name)s/pull-request/create', ['repo_name']);
159 pyroutes.register('pullrequest_update', '/%(repo_name)s/pull-request/%(pull_request_id)s/update', ['repo_name', 'pull_request_id']);
163 pyroutes.register('pullrequest_update', '/%(repo_name)s/pull-request/%(pull_request_id)s/update', ['repo_name', 'pull_request_id']);
160 pyroutes.register('pullrequest_merge', '/%(repo_name)s/pull-request/%(pull_request_id)s/merge', ['repo_name', 'pull_request_id']);
164 pyroutes.register('pullrequest_merge', '/%(repo_name)s/pull-request/%(pull_request_id)s/merge', ['repo_name', 'pull_request_id']);
161 pyroutes.register('pullrequest_delete', '/%(repo_name)s/pull-request/%(pull_request_id)s/delete', ['repo_name', 'pull_request_id']);
165 pyroutes.register('pullrequest_delete', '/%(repo_name)s/pull-request/%(pull_request_id)s/delete', ['repo_name', 'pull_request_id']);
162 pyroutes.register('pullrequest_comment_create', '/%(repo_name)s/pull-request/%(pull_request_id)s/comment', ['repo_name', 'pull_request_id']);
166 pyroutes.register('pullrequest_comment_create', '/%(repo_name)s/pull-request/%(pull_request_id)s/comment', ['repo_name', 'pull_request_id']);
163 pyroutes.register('pullrequest_comment_delete', '/%(repo_name)s/pull-request/%(pull_request_id)s/comment/%(comment_id)s/delete', ['repo_name', 'pull_request_id', 'comment_id']);
167 pyroutes.register('pullrequest_comment_delete', '/%(repo_name)s/pull-request/%(pull_request_id)s/comment/%(comment_id)s/delete', ['repo_name', 'pull_request_id', 'comment_id']);
164 pyroutes.register('edit_repo', '/%(repo_name)s/settings', ['repo_name']);
168 pyroutes.register('edit_repo', '/%(repo_name)s/settings', ['repo_name']);
165 pyroutes.register('edit_repo_advanced', '/%(repo_name)s/settings/advanced', ['repo_name']);
169 pyroutes.register('edit_repo_advanced', '/%(repo_name)s/settings/advanced', ['repo_name']);
166 pyroutes.register('edit_repo_advanced_delete', '/%(repo_name)s/settings/advanced/delete', ['repo_name']);
170 pyroutes.register('edit_repo_advanced_delete', '/%(repo_name)s/settings/advanced/delete', ['repo_name']);
167 pyroutes.register('edit_repo_advanced_locking', '/%(repo_name)s/settings/advanced/locking', ['repo_name']);
171 pyroutes.register('edit_repo_advanced_locking', '/%(repo_name)s/settings/advanced/locking', ['repo_name']);
168 pyroutes.register('edit_repo_advanced_journal', '/%(repo_name)s/settings/advanced/journal', ['repo_name']);
172 pyroutes.register('edit_repo_advanced_journal', '/%(repo_name)s/settings/advanced/journal', ['repo_name']);
169 pyroutes.register('edit_repo_advanced_fork', '/%(repo_name)s/settings/advanced/fork', ['repo_name']);
173 pyroutes.register('edit_repo_advanced_fork', '/%(repo_name)s/settings/advanced/fork', ['repo_name']);
170 pyroutes.register('edit_repo_caches', '/%(repo_name)s/settings/caches', ['repo_name']);
174 pyroutes.register('edit_repo_caches', '/%(repo_name)s/settings/caches', ['repo_name']);
171 pyroutes.register('edit_repo_perms', '/%(repo_name)s/settings/permissions', ['repo_name']);
175 pyroutes.register('edit_repo_perms', '/%(repo_name)s/settings/permissions', ['repo_name']);
172 pyroutes.register('repo_reviewers', '/%(repo_name)s/settings/review/rules', ['repo_name']);
176 pyroutes.register('repo_reviewers', '/%(repo_name)s/settings/review/rules', ['repo_name']);
173 pyroutes.register('repo_default_reviewers_data', '/%(repo_name)s/settings/review/default-reviewers', ['repo_name']);
177 pyroutes.register('repo_default_reviewers_data', '/%(repo_name)s/settings/review/default-reviewers', ['repo_name']);
174 pyroutes.register('repo_maintenance', '/%(repo_name)s/settings/maintenance', ['repo_name']);
178 pyroutes.register('repo_maintenance', '/%(repo_name)s/settings/maintenance', ['repo_name']);
175 pyroutes.register('repo_maintenance_execute', '/%(repo_name)s/settings/maintenance/execute', ['repo_name']);
179 pyroutes.register('repo_maintenance_execute', '/%(repo_name)s/settings/maintenance/execute', ['repo_name']);
176 pyroutes.register('strip', '/%(repo_name)s/settings/strip', ['repo_name']);
180 pyroutes.register('strip', '/%(repo_name)s/settings/strip', ['repo_name']);
177 pyroutes.register('strip_check', '/%(repo_name)s/settings/strip_check', ['repo_name']);
181 pyroutes.register('strip_check', '/%(repo_name)s/settings/strip_check', ['repo_name']);
178 pyroutes.register('strip_execute', '/%(repo_name)s/settings/strip_execute', ['repo_name']);
182 pyroutes.register('strip_execute', '/%(repo_name)s/settings/strip_execute', ['repo_name']);
179 pyroutes.register('rss_feed_home', '/%(repo_name)s/feed/rss', ['repo_name']);
183 pyroutes.register('rss_feed_home', '/%(repo_name)s/feed/rss', ['repo_name']);
180 pyroutes.register('atom_feed_home', '/%(repo_name)s/feed/atom', ['repo_name']);
184 pyroutes.register('atom_feed_home', '/%(repo_name)s/feed/atom', ['repo_name']);
181 pyroutes.register('repo_summary', '/%(repo_name)s', ['repo_name']);
185 pyroutes.register('repo_summary', '/%(repo_name)s', ['repo_name']);
182 pyroutes.register('repo_summary_slash', '/%(repo_name)s/', ['repo_name']);
186 pyroutes.register('repo_summary_slash', '/%(repo_name)s/', ['repo_name']);
183 pyroutes.register('repo_group_home', '/%(repo_group_name)s', ['repo_group_name']);
187 pyroutes.register('repo_group_home', '/%(repo_group_name)s', ['repo_group_name']);
184 pyroutes.register('repo_group_home_slash', '/%(repo_group_name)s/', ['repo_group_name']);
188 pyroutes.register('repo_group_home_slash', '/%(repo_group_name)s/', ['repo_group_name']);
185 pyroutes.register('search', '/_admin/search', []);
189 pyroutes.register('search', '/_admin/search', []);
186 pyroutes.register('search_repo', '/%(repo_name)s/search', ['repo_name']);
190 pyroutes.register('search_repo', '/%(repo_name)s/search', ['repo_name']);
187 pyroutes.register('user_profile', '/_profiles/%(username)s', ['username']);
191 pyroutes.register('user_profile', '/_profiles/%(username)s', ['username']);
188 pyroutes.register('my_account_profile', '/_admin/my_account/profile', []);
192 pyroutes.register('my_account_profile', '/_admin/my_account/profile', []);
189 pyroutes.register('my_account_edit', '/_admin/my_account/edit', []);
193 pyroutes.register('my_account_edit', '/_admin/my_account/edit', []);
190 pyroutes.register('my_account_update', '/_admin/my_account/update', []);
194 pyroutes.register('my_account_update', '/_admin/my_account/update', []);
191 pyroutes.register('my_account_password', '/_admin/my_account/password', []);
195 pyroutes.register('my_account_password', '/_admin/my_account/password', []);
192 pyroutes.register('my_account_password_update', '/_admin/my_account/password/update', []);
196 pyroutes.register('my_account_password_update', '/_admin/my_account/password/update', []);
193 pyroutes.register('my_account_auth_tokens', '/_admin/my_account/auth_tokens', []);
197 pyroutes.register('my_account_auth_tokens', '/_admin/my_account/auth_tokens', []);
194 pyroutes.register('my_account_auth_tokens_add', '/_admin/my_account/auth_tokens/new', []);
198 pyroutes.register('my_account_auth_tokens_add', '/_admin/my_account/auth_tokens/new', []);
195 pyroutes.register('my_account_auth_tokens_delete', '/_admin/my_account/auth_tokens/delete', []);
199 pyroutes.register('my_account_auth_tokens_delete', '/_admin/my_account/auth_tokens/delete', []);
196 pyroutes.register('my_account_emails', '/_admin/my_account/emails', []);
200 pyroutes.register('my_account_emails', '/_admin/my_account/emails', []);
197 pyroutes.register('my_account_emails_add', '/_admin/my_account/emails/new', []);
201 pyroutes.register('my_account_emails_add', '/_admin/my_account/emails/new', []);
198 pyroutes.register('my_account_emails_delete', '/_admin/my_account/emails/delete', []);
202 pyroutes.register('my_account_emails_delete', '/_admin/my_account/emails/delete', []);
199 pyroutes.register('my_account_repos', '/_admin/my_account/repos', []);
203 pyroutes.register('my_account_repos', '/_admin/my_account/repos', []);
200 pyroutes.register('my_account_watched', '/_admin/my_account/watched', []);
204 pyroutes.register('my_account_watched', '/_admin/my_account/watched', []);
201 pyroutes.register('my_account_perms', '/_admin/my_account/perms', []);
205 pyroutes.register('my_account_perms', '/_admin/my_account/perms', []);
202 pyroutes.register('my_account_notifications', '/_admin/my_account/notifications', []);
206 pyroutes.register('my_account_notifications', '/_admin/my_account/notifications', []);
203 pyroutes.register('my_account_notifications_toggle_visibility', '/_admin/my_account/toggle_visibility', []);
207 pyroutes.register('my_account_notifications_toggle_visibility', '/_admin/my_account/toggle_visibility', []);
204 pyroutes.register('my_account_pullrequests', '/_admin/my_account/pull_requests', []);
208 pyroutes.register('my_account_pullrequests', '/_admin/my_account/pull_requests', []);
205 pyroutes.register('my_account_pullrequests_data', '/_admin/my_account/pull_requests/data', []);
209 pyroutes.register('my_account_pullrequests_data', '/_admin/my_account/pull_requests/data', []);
206 pyroutes.register('notifications_show_all', '/_admin/notifications', []);
210 pyroutes.register('notifications_show_all', '/_admin/notifications', []);
207 pyroutes.register('notifications_mark_all_read', '/_admin/notifications/mark_all_read', []);
211 pyroutes.register('notifications_mark_all_read', '/_admin/notifications/mark_all_read', []);
208 pyroutes.register('notifications_show', '/_admin/notifications/%(notification_id)s', ['notification_id']);
212 pyroutes.register('notifications_show', '/_admin/notifications/%(notification_id)s', ['notification_id']);
209 pyroutes.register('notifications_update', '/_admin/notifications/%(notification_id)s/update', ['notification_id']);
213 pyroutes.register('notifications_update', '/_admin/notifications/%(notification_id)s/update', ['notification_id']);
210 pyroutes.register('notifications_delete', '/_admin/notifications/%(notification_id)s/delete', ['notification_id']);
214 pyroutes.register('notifications_delete', '/_admin/notifications/%(notification_id)s/delete', ['notification_id']);
211 pyroutes.register('my_account_notifications_test_channelstream', '/_admin/my_account/test_channelstream', []);
215 pyroutes.register('my_account_notifications_test_channelstream', '/_admin/my_account/test_channelstream', []);
212 pyroutes.register('gists_show', '/_admin/gists', []);
216 pyroutes.register('gists_show', '/_admin/gists', []);
213 pyroutes.register('gists_new', '/_admin/gists/new', []);
217 pyroutes.register('gists_new', '/_admin/gists/new', []);
214 pyroutes.register('gists_create', '/_admin/gists/create', []);
218 pyroutes.register('gists_create', '/_admin/gists/create', []);
215 pyroutes.register('gist_show', '/_admin/gists/%(gist_id)s', ['gist_id']);
219 pyroutes.register('gist_show', '/_admin/gists/%(gist_id)s', ['gist_id']);
216 pyroutes.register('gist_delete', '/_admin/gists/%(gist_id)s/delete', ['gist_id']);
220 pyroutes.register('gist_delete', '/_admin/gists/%(gist_id)s/delete', ['gist_id']);
217 pyroutes.register('gist_edit', '/_admin/gists/%(gist_id)s/edit', ['gist_id']);
221 pyroutes.register('gist_edit', '/_admin/gists/%(gist_id)s/edit', ['gist_id']);
218 pyroutes.register('gist_edit_check_revision', '/_admin/gists/%(gist_id)s/edit/check_revision', ['gist_id']);
222 pyroutes.register('gist_edit_check_revision', '/_admin/gists/%(gist_id)s/edit/check_revision', ['gist_id']);
219 pyroutes.register('gist_update', '/_admin/gists/%(gist_id)s/update', ['gist_id']);
223 pyroutes.register('gist_update', '/_admin/gists/%(gist_id)s/update', ['gist_id']);
220 pyroutes.register('gist_show_rev', '/_admin/gists/%(gist_id)s/%(revision)s', ['gist_id', 'revision']);
224 pyroutes.register('gist_show_rev', '/_admin/gists/%(gist_id)s/%(revision)s', ['gist_id', 'revision']);
221 pyroutes.register('gist_show_formatted', '/_admin/gists/%(gist_id)s/%(revision)s/%(format)s', ['gist_id', 'revision', 'format']);
225 pyroutes.register('gist_show_formatted', '/_admin/gists/%(gist_id)s/%(revision)s/%(format)s', ['gist_id', 'revision', 'format']);
222 pyroutes.register('gist_show_formatted_path', '/_admin/gists/%(gist_id)s/%(revision)s/%(format)s/%(f_path)s', ['gist_id', 'revision', 'format', 'f_path']);
226 pyroutes.register('gist_show_formatted_path', '/_admin/gists/%(gist_id)s/%(revision)s/%(format)s/%(f_path)s', ['gist_id', 'revision', 'format', 'f_path']);
223 pyroutes.register('debug_style_home', '/_admin/debug_style', []);
227 pyroutes.register('debug_style_home', '/_admin/debug_style', []);
224 pyroutes.register('debug_style_template', '/_admin/debug_style/t/%(t_path)s', ['t_path']);
228 pyroutes.register('debug_style_template', '/_admin/debug_style/t/%(t_path)s', ['t_path']);
225 pyroutes.register('apiv2', '/_admin/api', []);
229 pyroutes.register('apiv2', '/_admin/api', []);
226 }
230 }
@@ -1,56 +1,57 b''
1 ## -*- coding: utf-8 -*-
1 ## -*- coding: utf-8 -*-
2 <%inherit file="/base/base.mako"/>
2 <%inherit file="/base/base.mako"/>
3
3
4 <%def name="title()">
4 <%def name="title()">
5 ${_('%s user settings') % c.user.username}
5 ${_('%s user settings') % c.user.username}
6 %if c.rhodecode_name:
6 %if c.rhodecode_name:
7 &middot; ${h.branding(c.rhodecode_name)}
7 &middot; ${h.branding(c.rhodecode_name)}
8 %endif
8 %endif
9 </%def>
9 </%def>
10
10
11 <%def name="breadcrumbs_links()">
11 <%def name="breadcrumbs_links()">
12 ${h.link_to(_('Admin'),h.route_path('admin_home'))}
12 ${h.link_to(_('Admin'),h.route_path('admin_home'))}
13 &raquo;
13 &raquo;
14 ${h.link_to(_('Users'),h.route_path('users'))}
14 ${h.link_to(_('Users'),h.route_path('users'))}
15 &raquo;
15 &raquo;
16 % if c.user.active:
16 % if c.user.active:
17 ${c.user.username}
17 ${c.user.username}
18 % else:
18 % else:
19 <strike title="${_('This user is set as disabled')}">${c.user.username}</strike>
19 <strike title="${_('This user is set as disabled')}">${c.user.username}</strike>
20 % endif
20 % endif
21
21
22 </%def>
22 </%def>
23
23
24 <%def name="menu_bar_nav()">
24 <%def name="menu_bar_nav()">
25 ${self.menu_items(active='admin')}
25 ${self.menu_items(active='admin')}
26 </%def>
26 </%def>
27
27
28 <%def name="main()">
28 <%def name="main()">
29 <div class="box user_settings">
29 <div class="box user_settings">
30 <div class="title">
30 <div class="title">
31 ${self.breadcrumbs()}
31 ${self.breadcrumbs()}
32 </div>
32 </div>
33
33
34 ##main
34 ##main
35 <div class="sidebar-col-wrapper">
35 <div class="sidebar-col-wrapper">
36 <div class="sidebar">
36 <div class="sidebar">
37 <ul class="nav nav-pills nav-stacked">
37 <ul class="nav nav-pills nav-stacked">
38 <li class="${'active' if c.active=='profile' else ''}"><a href="${h.url('edit_user', user_id=c.user.user_id)}">${_('User Profile')}</a></li>
38 <li class="${'active' if c.active=='profile' else ''}"><a href="${h.url('edit_user', user_id=c.user.user_id)}">${_('User Profile')}</a></li>
39 <li class="${'active' if c.active=='auth_tokens' else ''}"><a href="${h.route_path('edit_user_auth_tokens', user_id=c.user.user_id)}">${_('Auth tokens')}</a></li>
39 <li class="${'active' if c.active=='auth_tokens' else ''}"><a href="${h.route_path('edit_user_auth_tokens', user_id=c.user.user_id)}">${_('Auth tokens')}</a></li>
40 <li class="${'active' if c.active in ['ssh_keys','ssh_keys_generate'] else ''}"><a href="${h.route_path('edit_user_ssh_keys', user_id=c.user.user_id)}">${_('SSH Keys')}</a></li>
40 <li class="${'active' if c.active=='advanced' else ''}"><a href="${h.url('edit_user_advanced', user_id=c.user.user_id)}">${_('Advanced')}</a></li>
41 <li class="${'active' if c.active=='advanced' else ''}"><a href="${h.url('edit_user_advanced', user_id=c.user.user_id)}">${_('Advanced')}</a></li>
41 <li class="${'active' if c.active=='global_perms' else ''}"><a href="${h.url('edit_user_global_perms', user_id=c.user.user_id)}">${_('Global permissions')}</a></li>
42 <li class="${'active' if c.active=='global_perms' else ''}"><a href="${h.url('edit_user_global_perms', user_id=c.user.user_id)}">${_('Global permissions')}</a></li>
42 <li class="${'active' if c.active=='perms_summary' else ''}"><a href="${h.url('edit_user_perms_summary', user_id=c.user.user_id)}">${_('Permissions summary')}</a></li>
43 <li class="${'active' if c.active=='perms_summary' else ''}"><a href="${h.url('edit_user_perms_summary', user_id=c.user.user_id)}">${_('Permissions summary')}</a></li>
43 <li class="${'active' if c.active=='emails' else ''}"><a href="${h.route_path('edit_user_emails', user_id=c.user.user_id)}">${_('Emails')}</a></li>
44 <li class="${'active' if c.active=='emails' else ''}"><a href="${h.route_path('edit_user_emails', user_id=c.user.user_id)}">${_('Emails')}</a></li>
44 <li class="${'active' if c.active=='ips' else ''}"><a href="${h.route_path('edit_user_ips', user_id=c.user.user_id)}">${_('Ip Whitelist')}</a></li>
45 <li class="${'active' if c.active=='ips' else ''}"><a href="${h.route_path('edit_user_ips', user_id=c.user.user_id)}">${_('Ip Whitelist')}</a></li>
45 <li class="${'active' if c.active=='groups' else ''}"><a href="${h.route_path('edit_user_groups_management', user_id=c.user.user_id)}">${_('User Groups Management')}</a></li>
46 <li class="${'active' if c.active=='groups' else ''}"><a href="${h.route_path('edit_user_groups_management', user_id=c.user.user_id)}">${_('User Groups Management')}</a></li>
46 <li class="${'active' if c.active=='audit' else ''}"><a href="${h.route_path('edit_user_audit_logs', user_id=c.user.user_id)}">${_('User audit')}</a></li>
47 <li class="${'active' if c.active=='audit' else ''}"><a href="${h.route_path('edit_user_audit_logs', user_id=c.user.user_id)}">${_('User audit')}</a></li>
47 </ul>
48 </ul>
48 </div>
49 </div>
49
50
50 <div class="main-content-full-width">
51 <div class="main-content-full-width">
51 <%include file="/admin/users/user_edit_${c.active}.mako"/>
52 <%include file="/admin/users/user_edit_${c.active}.mako"/>
52 </div>
53 </div>
53 </div>
54 </div>
54 </div>
55 </div>
55
56
56 </%def>
57 </%def>
@@ -1,254 +1,255 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2
2
3 # Copyright (C) 2010-2017 RhodeCode GmbH
3 # Copyright (C) 2010-2017 RhodeCode GmbH
4 #
4 #
5 # This program is free software: you can redistribute it and/or modify
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License, version 3
6 # it under the terms of the GNU Affero General Public License, version 3
7 # (only), as published by the Free Software Foundation.
7 # (only), as published by the Free Software Foundation.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU Affero General Public License
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 #
16 #
17 # This program is dual-licensed. If you wish to learn more about the
17 # This program is dual-licensed. If you wish to learn more about the
18 # RhodeCode Enterprise Edition, including its added features, Support services,
18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
20
21 # Import early to make sure things are patched up properly
21 # Import early to make sure things are patched up properly
22 from setuptools import setup, find_packages
22 from setuptools import setup, find_packages
23
23
24 import os
24 import os
25 import sys
25 import sys
26 import pkgutil
26 import pkgutil
27 import platform
27 import platform
28
28
29 from pip.download import PipSession
29 from pip.download import PipSession
30 from pip.req import parse_requirements
30 from pip.req import parse_requirements
31
31
32 from codecs import open
32 from codecs import open
33
33
34
34
35 if sys.version_info < (2, 7):
35 if sys.version_info < (2, 7):
36 raise Exception('RhodeCode requires Python 2.7 or later')
36 raise Exception('RhodeCode requires Python 2.7 or later')
37
37
38 here = os.path.abspath(os.path.dirname(__file__))
38 here = os.path.abspath(os.path.dirname(__file__))
39
39
40 # defines current platform
40 # defines current platform
41 __platform__ = platform.system()
41 __platform__ = platform.system()
42 __license__ = 'AGPLv3, and Commercial License'
42 __license__ = 'AGPLv3, and Commercial License'
43 __author__ = 'RhodeCode GmbH'
43 __author__ = 'RhodeCode GmbH'
44 __url__ = 'https://code.rhodecode.com'
44 __url__ = 'https://code.rhodecode.com'
45 is_windows = __platform__ in ('Windows',)
45 is_windows = __platform__ in ('Windows',)
46
46
47
47
48 def _get_requirements(req_filename, exclude=None, extras=None):
48 def _get_requirements(req_filename, exclude=None, extras=None):
49 extras = extras or []
49 extras = extras or []
50 exclude = exclude or []
50 exclude = exclude or []
51
51
52 try:
52 try:
53 parsed = parse_requirements(
53 parsed = parse_requirements(
54 os.path.join(here, req_filename), session=PipSession())
54 os.path.join(here, req_filename), session=PipSession())
55 except TypeError:
55 except TypeError:
56 # try pip < 6.0.0, that doesn't support session
56 # try pip < 6.0.0, that doesn't support session
57 parsed = parse_requirements(os.path.join(here, req_filename))
57 parsed = parse_requirements(os.path.join(here, req_filename))
58
58
59 requirements = []
59 requirements = []
60 for ir in parsed:
60 for ir in parsed:
61 if ir.req and ir.name not in exclude:
61 if ir.req and ir.name not in exclude:
62 requirements.append(str(ir.req))
62 requirements.append(str(ir.req))
63 return requirements + extras
63 return requirements + extras
64
64
65
65
66 # requirements extract
66 # requirements extract
67 setup_requirements = ['PasteScript', 'pytest-runner']
67 setup_requirements = ['PasteScript', 'pytest-runner']
68 install_requirements = _get_requirements(
68 install_requirements = _get_requirements(
69 'requirements.txt', exclude=['setuptools'])
69 'requirements.txt', exclude=['setuptools'])
70 test_requirements = _get_requirements(
70 test_requirements = _get_requirements(
71 'requirements_test.txt', extras=['configobj'])
71 'requirements_test.txt', extras=['configobj'])
72
72
73 install_requirements = [
73 install_requirements = [
74 'Babel',
74 'Babel',
75 'Beaker',
75 'Beaker',
76 'FormEncode',
76 'FormEncode',
77 'Mako',
77 'Mako',
78 'Markdown',
78 'Markdown',
79 'MarkupSafe',
79 'MarkupSafe',
80 'MySQL-python',
80 'MySQL-python',
81 'Paste',
81 'Paste',
82 'PasteDeploy',
82 'PasteDeploy',
83 'PasteScript',
83 'PasteScript',
84 'Pygments',
84 'Pygments',
85 'pygments-markdown-lexer',
85 'pygments-markdown-lexer',
86 'Pylons',
86 'Pylons',
87 'Routes',
87 'Routes',
88 'SQLAlchemy',
88 'SQLAlchemy',
89 'Tempita',
89 'Tempita',
90 'URLObject',
90 'URLObject',
91 'WebError',
91 'WebError',
92 'WebHelpers',
92 'WebHelpers',
93 'WebHelpers2',
93 'WebHelpers2',
94 'WebOb',
94 'WebOb',
95 'WebTest',
95 'WebTest',
96 'Whoosh',
96 'Whoosh',
97 'alembic',
97 'alembic',
98 'amqplib',
98 'amqplib',
99 'anyjson',
99 'anyjson',
100 'appenlight-client',
100 'appenlight-client',
101 'authomatic',
101 'authomatic',
102 'cssselect',
102 'cssselect',
103 'celery',
103 'celery',
104 'channelstream',
104 'channelstream',
105 'colander',
105 'colander',
106 'decorator',
106 'decorator',
107 'deform',
107 'deform',
108 'docutils',
108 'docutils',
109 'gevent',
109 'gevent',
110 'gunicorn',
110 'gunicorn',
111 'infrae.cache',
111 'infrae.cache',
112 'ipython',
112 'ipython',
113 'iso8601',
113 'iso8601',
114 'kombu',
114 'kombu',
115 'lxml',
115 'lxml',
116 'msgpack-python',
116 'msgpack-python',
117 'nbconvert',
117 'nbconvert',
118 'packaging',
118 'packaging',
119 'psycopg2',
119 'psycopg2',
120 'py-gfm',
120 'py-gfm',
121 'pycrypto',
121 'pycrypto',
122 'pycurl',
122 'pycurl',
123 'pyparsing',
123 'pyparsing',
124 'pyramid',
124 'pyramid',
125 'pyramid-debugtoolbar',
125 'pyramid-debugtoolbar',
126 'pyramid-mako',
126 'pyramid-mako',
127 'pyramid-beaker',
127 'pyramid-beaker',
128 'pysqlite',
128 'pysqlite',
129 'python-dateutil',
129 'python-dateutil',
130 'python-ldap',
130 'python-ldap',
131 'python-memcached',
131 'python-memcached',
132 'python-pam',
132 'python-pam',
133 'recaptcha-client',
133 'recaptcha-client',
134 'repoze.lru',
134 'repoze.lru',
135 'requests',
135 'requests',
136 'simplejson',
136 'simplejson',
137 'sshpubkeys',
137 'subprocess32',
138 'subprocess32',
138 'waitress',
139 'waitress',
139 'zope.cachedescriptors',
140 'zope.cachedescriptors',
140 'dogpile.cache',
141 'dogpile.cache',
141 'dogpile.core',
142 'dogpile.core',
142 'psutil',
143 'psutil',
143 'py-bcrypt',
144 'py-bcrypt',
144 ]
145 ]
145
146
146
147
147 def get_version():
148 def get_version():
148 version = pkgutil.get_data('rhodecode', 'VERSION')
149 version = pkgutil.get_data('rhodecode', 'VERSION')
149 return version.strip()
150 return version.strip()
150
151
151
152
152 # additional files that goes into package itself
153 # additional files that goes into package itself
153 package_data = {
154 package_data = {
154 '': ['*.txt', '*.rst'],
155 '': ['*.txt', '*.rst'],
155 'configs': ['*.ini'],
156 'configs': ['*.ini'],
156 'rhodecode': ['VERSION', 'i18n/*/LC_MESSAGES/*.mo', ],
157 'rhodecode': ['VERSION', 'i18n/*/LC_MESSAGES/*.mo', ],
157 }
158 }
158
159
159 description = 'Source Code Management Platform'
160 description = 'Source Code Management Platform'
160 keywords = ' '.join([
161 keywords = ' '.join([
161 'rhodecode', 'mercurial', 'git', 'svn',
162 'rhodecode', 'mercurial', 'git', 'svn',
162 'code review',
163 'code review',
163 'repo groups', 'ldap', 'repository management', 'hgweb',
164 'repo groups', 'ldap', 'repository management', 'hgweb',
164 'hgwebdir', 'gitweb', 'serving hgweb',
165 'hgwebdir', 'gitweb', 'serving hgweb',
165 ])
166 ])
166
167
167
168
168 # README/DESCRIPTION generation
169 # README/DESCRIPTION generation
169 readme_file = 'README.rst'
170 readme_file = 'README.rst'
170 changelog_file = 'CHANGES.rst'
171 changelog_file = 'CHANGES.rst'
171 try:
172 try:
172 long_description = open(readme_file).read() + '\n\n' + \
173 long_description = open(readme_file).read() + '\n\n' + \
173 open(changelog_file).read()
174 open(changelog_file).read()
174 except IOError as err:
175 except IOError as err:
175 sys.stderr.write(
176 sys.stderr.write(
176 "[WARNING] Cannot find file specified as long_description (%s)\n "
177 "[WARNING] Cannot find file specified as long_description (%s)\n "
177 "or changelog (%s) skipping that file" % (readme_file, changelog_file))
178 "or changelog (%s) skipping that file" % (readme_file, changelog_file))
178 long_description = description
179 long_description = description
179
180
180
181
181 setup(
182 setup(
182 name='rhodecode-enterprise-ce',
183 name='rhodecode-enterprise-ce',
183 version=get_version(),
184 version=get_version(),
184 description=description,
185 description=description,
185 long_description=long_description,
186 long_description=long_description,
186 keywords=keywords,
187 keywords=keywords,
187 license=__license__,
188 license=__license__,
188 author=__author__,
189 author=__author__,
189 author_email='marcin@rhodecode.com',
190 author_email='marcin@rhodecode.com',
190 url=__url__,
191 url=__url__,
191 setup_requires=setup_requirements,
192 setup_requires=setup_requirements,
192 install_requires=install_requirements,
193 install_requires=install_requirements,
193 tests_require=test_requirements,
194 tests_require=test_requirements,
194 zip_safe=False,
195 zip_safe=False,
195 packages=find_packages(exclude=["docs", "tests*"]),
196 packages=find_packages(exclude=["docs", "tests*"]),
196 package_data=package_data,
197 package_data=package_data,
197 include_package_data=True,
198 include_package_data=True,
198 classifiers=[
199 classifiers=[
199 'Development Status :: 6 - Mature',
200 'Development Status :: 6 - Mature',
200 'Environment :: Web Environment',
201 'Environment :: Web Environment',
201 'Intended Audience :: Developers',
202 'Intended Audience :: Developers',
202 'Operating System :: OS Independent',
203 'Operating System :: OS Independent',
203 'Topic :: Software Development :: Version Control',
204 'Topic :: Software Development :: Version Control',
204 'License :: OSI Approved :: Affero GNU General Public License v3 or later (AGPLv3+)',
205 'License :: OSI Approved :: Affero GNU General Public License v3 or later (AGPLv3+)',
205 'Programming Language :: Python :: 2.7',
206 'Programming Language :: Python :: 2.7',
206 ],
207 ],
207 message_extractors={
208 message_extractors={
208 'rhodecode': [
209 'rhodecode': [
209 ('**.py', 'python', None),
210 ('**.py', 'python', None),
210 ('**.js', 'javascript', None),
211 ('**.js', 'javascript', None),
211 ('templates/**.mako', 'mako', {'input_encoding': 'utf-8'}),
212 ('templates/**.mako', 'mako', {'input_encoding': 'utf-8'}),
212 ('templates/**.html', 'mako', {'input_encoding': 'utf-8'}),
213 ('templates/**.html', 'mako', {'input_encoding': 'utf-8'}),
213 ('public/**', 'ignore', None),
214 ('public/**', 'ignore', None),
214 ]
215 ]
215 },
216 },
216 paster_plugins=['PasteScript', 'Pylons'],
217 paster_plugins=['PasteScript', 'Pylons'],
217 entry_points={
218 entry_points={
218 'enterprise.plugins1': [
219 'enterprise.plugins1': [
219 'crowd=rhodecode.authentication.plugins.auth_crowd:plugin_factory',
220 'crowd=rhodecode.authentication.plugins.auth_crowd:plugin_factory',
220 'headers=rhodecode.authentication.plugins.auth_headers:plugin_factory',
221 'headers=rhodecode.authentication.plugins.auth_headers:plugin_factory',
221 'jasig_cas=rhodecode.authentication.plugins.auth_jasig_cas:plugin_factory',
222 'jasig_cas=rhodecode.authentication.plugins.auth_jasig_cas:plugin_factory',
222 'ldap=rhodecode.authentication.plugins.auth_ldap:plugin_factory',
223 'ldap=rhodecode.authentication.plugins.auth_ldap:plugin_factory',
223 'pam=rhodecode.authentication.plugins.auth_pam:plugin_factory',
224 'pam=rhodecode.authentication.plugins.auth_pam:plugin_factory',
224 'rhodecode=rhodecode.authentication.plugins.auth_rhodecode:plugin_factory',
225 'rhodecode=rhodecode.authentication.plugins.auth_rhodecode:plugin_factory',
225 'token=rhodecode.authentication.plugins.auth_token:plugin_factory',
226 'token=rhodecode.authentication.plugins.auth_token:plugin_factory',
226 ],
227 ],
227 'paste.app_factory': [
228 'paste.app_factory': [
228 'main=rhodecode.config.middleware:make_pyramid_app',
229 'main=rhodecode.config.middleware:make_pyramid_app',
229 'pylons=rhodecode.config.middleware:make_app',
230 'pylons=rhodecode.config.middleware:make_app',
230 ],
231 ],
231 'paste.app_install': [
232 'paste.app_install': [
232 'main=pylons.util:PylonsInstaller',
233 'main=pylons.util:PylonsInstaller',
233 'pylons=pylons.util:PylonsInstaller',
234 'pylons=pylons.util:PylonsInstaller',
234 ],
235 ],
235 'paste.global_paster_command': [
236 'paste.global_paster_command': [
236 'make-config=rhodecode.lib.paster_commands.make_config:Command',
237 'make-config=rhodecode.lib.paster_commands.make_config:Command',
237 'setup-rhodecode=rhodecode.lib.paster_commands.setup_rhodecode:Command',
238 'setup-rhodecode=rhodecode.lib.paster_commands.setup_rhodecode:Command',
238 'ishell=rhodecode.lib.paster_commands.ishell:Command',
239 'ishell=rhodecode.lib.paster_commands.ishell:Command',
239 'upgrade-db=rhodecode.lib.dbmigrate:UpgradeDb',
240 'upgrade-db=rhodecode.lib.dbmigrate:UpgradeDb',
240 'celeryd=rhodecode.lib.celerypylons.commands:CeleryDaemonCommand',
241 'celeryd=rhodecode.lib.celerypylons.commands:CeleryDaemonCommand',
241 ],
242 ],
242 'pytest11': [
243 'pytest11': [
243 'pylons=rhodecode.tests.pylons_plugin',
244 'pylons=rhodecode.tests.pylons_plugin',
244 'enterprise=rhodecode.tests.plugin',
245 'enterprise=rhodecode.tests.plugin',
245 ],
246 ],
246 'console_scripts': [
247 'console_scripts': [
247 'rcserver=rhodecode.rcserver:main',
248 'rcserver=rhodecode.rcserver:main',
248 ],
249 ],
249 'beaker.backends': [
250 'beaker.backends': [
250 'memorylru_base=rhodecode.lib.memory_lru_debug:MemoryLRUNamespaceManagerBase',
251 'memorylru_base=rhodecode.lib.memory_lru_debug:MemoryLRUNamespaceManagerBase',
251 'memorylru_debug=rhodecode.lib.memory_lru_debug:MemoryLRUNamespaceManagerDebug'
252 'memorylru_debug=rhodecode.lib.memory_lru_debug:MemoryLRUNamespaceManagerDebug'
252 ]
253 ]
253 },
254 },
254 )
255 )
General Comments 0
You need to be logged in to leave comments. Login now