Show More
@@ -93,8 +93,6 b' def _run(argv):' | |||||
93 | print parser.print_help() |
|
93 | print parser.print_help() | |
94 | sys.exit(0) |
|
94 | sys.exit(0) | |
95 | # defaults that can be overwritten by arguments |
|
95 | # defaults that can be overwritten by arguments | |
96 | from rhodecode.model.license import LicenseModel |
|
|||
97 | license_token = LicenseModel.generate_license_token() |
|
|||
98 | tmpl_stored_args = { |
|
96 | tmpl_stored_args = { | |
99 | 'http_server': 'waitress', |
|
97 | 'http_server': 'waitress', | |
100 | 'lang': 'en', |
|
98 | 'lang': 'en', | |
@@ -102,7 +100,6 b' def _run(argv):' | |||||
102 | 'host': '127.0.0.1', |
|
100 | 'host': '127.0.0.1', | |
103 | 'port': 5000, |
|
101 | 'port': 5000, | |
104 | 'error_aggregation_service': None, |
|
102 | 'error_aggregation_service': None, | |
105 | 'license_token': license_token |
|
|||
106 | } |
|
103 | } | |
107 | if other: |
|
104 | if other: | |
108 | # parse arguments, we assume only first is correct |
|
105 | # parse arguments, we assume only first is correct |
@@ -346,11 +346,6 b' def make_map(config):' | |||||
346 | m.connect("admin_settings_system_update", "/settings/system/updates", |
|
346 | m.connect("admin_settings_system_update", "/settings/system/updates", | |
347 | action="settings_system_update", conditions=dict(method=["GET"])) |
|
347 | action="settings_system_update", conditions=dict(method=["GET"])) | |
348 |
|
348 | |||
349 | m.connect("admin_settings_license", "/settings/license", |
|
|||
350 | action="settings_license", conditions=dict(method=["POST"])) |
|
|||
351 | m.connect("admin_settings_license", "/settings/license", |
|
|||
352 | action="settings_license", conditions=dict(method=["GET"])) |
|
|||
353 |
|
||||
354 | #ADMIN MY ACCOUNT |
|
349 | #ADMIN MY ACCOUNT | |
355 | with rmap.submapper(path_prefix=ADMIN_PREFIX, |
|
350 | with rmap.submapper(path_prefix=ADMIN_PREFIX, | |
356 | controller='admin/my_account') as m: |
|
351 | controller='admin/my_account') as m: |
@@ -42,7 +42,6 b' from rhodecode.lib.utils import repo2db_' | |||||
42 | from rhodecode.model.db import RhodeCodeUi, Repository, RhodeCodeSetting |
|
42 | from rhodecode.model.db import RhodeCodeUi, Repository, RhodeCodeSetting | |
43 | from rhodecode.model.forms import ApplicationSettingsForm, \ |
|
43 | from rhodecode.model.forms import ApplicationSettingsForm, \ | |
44 | ApplicationUiSettingsForm, ApplicationVisualisationForm |
|
44 | ApplicationUiSettingsForm, ApplicationVisualisationForm | |
45 | from rhodecode.model.license import LicenseModel |
|
|||
46 | from rhodecode.model.scm import ScmModel |
|
45 | from rhodecode.model.scm import ScmModel | |
47 | from rhodecode.model.notification import EmailNotificationModel |
|
46 | from rhodecode.model.notification import EmailNotificationModel | |
48 | from rhodecode.model.meta import Session |
|
47 | from rhodecode.model.meta import Session | |
@@ -517,63 +516,3 b' class SettingsController(BaseController)' | |||||
517 | c.important_notices = latest['general'] |
|
516 | c.important_notices = latest['general'] | |
518 |
|
517 | |||
519 | return render('admin/settings/settings_system_update.html'), |
|
518 | return render('admin/settings/settings_system_update.html'), | |
520 |
|
||||
521 | @HasPermissionAllDecorator('hg.admin') |
|
|||
522 | def settings_license(self): |
|
|||
523 | """GET /admin/settings/hooks: All items in the collection""" |
|
|||
524 | # url('admin_settings_license') |
|
|||
525 | c.active = 'license' |
|
|||
526 | if request.POST: |
|
|||
527 | form_result = request.POST |
|
|||
528 | try: |
|
|||
529 | sett1 = RhodeCodeSetting.create_or_update('license_key', |
|
|||
530 | form_result['rhodecode_license_key'], |
|
|||
531 | 'unicode') |
|
|||
532 | Session().add(sett1) |
|
|||
533 | Session().commit() |
|
|||
534 | set_rhodecode_config(config) |
|
|||
535 | h.flash(_('Updated license information'), |
|
|||
536 | category='success') |
|
|||
537 |
|
||||
538 | except Exception: |
|
|||
539 | log.error(traceback.format_exc()) |
|
|||
540 | h.flash(_('Error occurred during updating license info'), |
|
|||
541 | category='error') |
|
|||
542 |
|
||||
543 | return redirect(url('admin_settings_license')) |
|
|||
544 |
|
||||
545 | defaults = RhodeCodeSetting.get_app_settings() |
|
|||
546 | defaults.update(self._get_hg_ui_settings()) |
|
|||
547 |
|
||||
548 | import rhodecode |
|
|||
549 | c.rhodecode_ini = rhodecode.CONFIG |
|
|||
550 | c.license_token = c.rhodecode_ini.get('license_token') |
|
|||
551 | c.generated_license_token = LicenseModel.generate_license_token() |
|
|||
552 | c.license_info = {} |
|
|||
553 | c.license_loaded = False |
|
|||
554 | # try to read info about license |
|
|||
555 | try: |
|
|||
556 | license_key = defaults.get('rhodecode_license_key') |
|
|||
557 | if c.license_token and license_key: |
|
|||
558 | c.license_info = json.loads( |
|
|||
559 | LicenseModel(key=c.license_token).decrypt(license_key)) |
|
|||
560 | expires = h.fmt_date(h.time_to_datetime(c.license_info['valid_till'])) |
|
|||
561 | now = time.time() |
|
|||
562 | if 0 < (c.license_info['valid_till'] - now) < 60*60*24*7: |
|
|||
563 | h.flash(_('Your license will expire on %s, please contact ' |
|
|||
564 | 'support to extend your license.' % expires), category='warning') |
|
|||
565 | if c.license_info['valid_till'] - now < 0: |
|
|||
566 | h.flash(_('Your license has expired on %s, please contact ' |
|
|||
567 | 'support to extend your license.' % expires), category='error') |
|
|||
568 | c.license_loaded = True |
|
|||
569 | except Exception, e: |
|
|||
570 | log.error(traceback.format_exc()) |
|
|||
571 | h.flash(_('Unexpected error while reading license key. Please ' |
|
|||
572 | 'make sure your license token and key are correct'), |
|
|||
573 | category='error') |
|
|||
574 |
|
||||
575 | return htmlfill.render( |
|
|||
576 | render('admin/settings/settings.html'), |
|
|||
577 | defaults=defaults, |
|
|||
578 | encoding="UTF-8", |
|
|||
579 | force_defaults=False) |
|
@@ -258,30 +258,6 b' def check_allowed_create_user(user_dict,' | |||||
258 | if not allowed: |
|
258 | if not allowed: | |
259 | raise UserCreationError(reason) |
|
259 | raise UserCreationError(reason) | |
260 |
|
260 | |||
261 | # license limit hook |
|
|||
262 | import rhodecode |
|
|||
263 | from rhodecode.model.license import LicenseModel |
|
|||
264 | license_token = rhodecode.CONFIG.get('license_token') |
|
|||
265 | license_key = LicenseModel.get_license_key() |
|
|||
266 | license_info = LicenseModel.get_license_info( |
|
|||
267 | license_token=license_token, enc_license_key=license_key, |
|
|||
268 | fill_defaults=True) |
|
|||
269 | expiration_check = False |
|
|||
270 | if expiration_check: |
|
|||
271 | now = time.time() |
|
|||
272 | #check expiration |
|
|||
273 | if now > license_info['valid_till']: |
|
|||
274 | reason = ('Your license has expired, ' |
|
|||
275 | 'please contact support to extend your license.') |
|
|||
276 | raise UserCreationError(reason) |
|
|||
277 | # user count check |
|
|||
278 | cur_user_count = User.query().count() |
|
|||
279 | if cur_user_count > int(license_info['users']) > 0: |
|
|||
280 | reason = ('You have reached the maximum number of users (%s), ' |
|
|||
281 | 'please contact support to extend your license.' |
|
|||
282 | % license_info['users']) |
|
|||
283 | raise UserCreationError(reason) |
|
|||
284 |
|
||||
285 |
|
261 | |||
286 | def log_create_user(user_dict, created_by, **kwargs): |
|
262 | def log_create_user(user_dict, created_by, **kwargs): | |
287 | """ |
|
263 | """ |
@@ -45,8 +45,6 b'' | |||||
45 | <li class="${'active' if c.active=='hooks' else ''}"><a href="${h.url('admin_settings_hooks')}">${_('Hooks')}</a></li> |
|
45 | <li class="${'active' if c.active=='hooks' else ''}"><a href="${h.url('admin_settings_hooks')}">${_('Hooks')}</a></li> | |
46 | <li class="${'active' if c.active=='search' else ''}"><a href="${h.url('admin_settings_search')}">${_('Full text search')}</a></li> |
|
46 | <li class="${'active' if c.active=='search' else ''}"><a href="${h.url('admin_settings_search')}">${_('Full text search')}</a></li> | |
47 | <li class="${'active' if c.active=='system' else ''}"><a href="${h.url('admin_settings_system')}">${_('System Info')}</a></li> |
|
47 | <li class="${'active' if c.active=='system' else ''}"><a href="${h.url('admin_settings_system')}">${_('System Info')}</a></li> | |
48 | <li class="${'active' if c.active=='license' else ''}"><a href="${h.url('admin_settings_license')}">${_('License')}</a></li> |
|
|||
49 |
|
||||
50 | </ul> |
|
48 | </ul> | |
51 | </div> |
|
49 | </div> | |
52 |
|
50 |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now