# HG changeset patch # User Marcin Kuzminski # Date 1350584160 -7200 # Node ID 62e493c7f436088a7fa260ac1a904a22502140ce # Parent 20c0af65ac52a661e2f82c27fb239d8bc2347406 Added lightweight dashboard option. ref #500 diff -r 20c0af65ac52 -r 62e493c7f436 rhodecode/controllers/admin/settings.py --- a/rhodecode/controllers/admin/settings.py Thu Oct 18 02:14:30 2012 +0200 +++ b/rhodecode/controllers/admin/settings.py Thu Oct 18 20:16:00 2012 +0200 @@ -185,18 +185,23 @@ sett1 = RhodeCodeSetting.get_by_name_or_create('show_public_icon') sett1.app_settings_value = \ form_result['rhodecode_show_public_icon'] + Session().add(sett1) sett2 = RhodeCodeSetting.get_by_name_or_create('show_private_icon') sett2.app_settings_value = \ form_result['rhodecode_show_private_icon'] + Session().add(sett2) sett3 = RhodeCodeSetting.get_by_name_or_create('stylify_metatags') sett3.app_settings_value = \ form_result['rhodecode_stylify_metatags'] + Session().add(sett3) - Session().add(sett1) - Session().add(sett2) - Session().add(sett3) + sett4 = RhodeCodeSetting.get_by_name_or_create('lightweight_dashboard') + sett4.app_settings_value = \ + form_result['rhodecode_lightweight_dashboard'] + Session().add(sett4) + Session().commit() set_rhodecode_config(config) h.flash(_('Updated visualisation settings'), diff -r 20c0af65ac52 -r 62e493c7f436 rhodecode/controllers/home.py --- a/rhodecode/controllers/home.py Thu Oct 18 02:14:30 2012 +0200 +++ b/rhodecode/controllers/home.py Thu Oct 18 20:16:00 2012 +0200 @@ -26,11 +26,16 @@ import logging from pylons import tmpl_context as c, request +from pylons.i18n.translation import _ from webob.exc import HTTPBadRequest +import rhodecode +from rhodecode.lib import helpers as h +from rhodecode.lib.ext_json import json from rhodecode.lib.auth import LoginRequired from rhodecode.lib.base import BaseController, render from rhodecode.model.db import Repository +from sqlalchemy.sql.expression import func log = logging.getLogger(__name__) @@ -42,9 +47,55 @@ super(HomeController, self).__before__() def index(self): - c.repos_list = self.scm_model.get_repos() c.groups = self.scm_model.get_repos_groups() c.group = None + + if c.visual.lightweight_dashboard is False: + c.repos_list = self.scm_model.get_repos() + ## lightweight version of dashboard + else: + c.repos_list = Repository.query()\ + .filter(Repository.group_id == None)\ + .order_by(func.lower(Repository.repo_name))\ + .all() + repos_data = [] + total_records = len(c.repos_list) + + _tmpl_lookup = rhodecode.CONFIG['pylons.app_globals'].mako_lookup + template = _tmpl_lookup.get_template('data_table/_dt_elements.html') + + quick_menu = lambda repo_name: (template.get_def("quick_menu") + .render(repo_name, _=_, h=h, c=c)) + repo_lnk = lambda name, rtype, private, fork_of: ( + template.get_def("repo_name") + .render(name, rtype, private, fork_of, short_name=False, + admin=False, _=_, h=h, c=c)) + rss_lnk = lambda repo_name: (template.get_def("rss") + .render(repo_name, _=_, h=h, c=c)) + atom_lnk = lambda repo_name: (template.get_def("atom") + .render(repo_name, _=_, h=h, c=c)) + + for repo in c.repos_list: + repos_data.append({ + "menu": quick_menu(repo.repo_name), + "raw_name": repo.repo_name.lower(), + "name": repo_lnk(repo.repo_name, repo.repo_type, + repo.private, repo.fork), + "last_change": h.age(repo.last_db_change), + "desc": repo.description, + "owner": h.person(repo.user.username), + "rss": rss_lnk(repo.repo_name), + "atom": atom_lnk(repo.repo_name), + }) + + c.data = json.dumps({ + "totalRecords": total_records, + "startIndex": 0, + "sort": "name", + "dir": "asc", + "records": repos_data + }) + return render('/index.html') def repo_switcher(self): diff -r 20c0af65ac52 -r 62e493c7f436 rhodecode/lib/base.py --- a/rhodecode/lib/base.py Thu Oct 18 02:14:30 2012 +0200 +++ b/rhodecode/lib/base.py Thu Oct 18 20:16:00 2012 +0200 @@ -245,6 +245,7 @@ c.visual.show_public_icon = str2bool(config.get('rhodecode_show_public_icon')) c.visual.show_private_icon = str2bool(config.get('rhodecode_show_private_icon')) c.visual.stylify_metatags = str2bool(config.get('rhodecode_stylify_metatags')) + c.visual.lightweight_dashboard = str2bool(config.get('rhodecode_lightweight_dashboard')) c.repo_name = get_repo_slug(request) c.backends = BACKENDS.keys() diff -r 20c0af65ac52 -r 62e493c7f436 rhodecode/lib/helpers.py --- a/rhodecode/lib/helpers.py Thu Oct 18 02:14:30 2012 +0200 +++ b/rhodecode/lib/helpers.py Thu Oct 18 20:16:00 2012 +0200 @@ -42,7 +42,7 @@ from rhodecode.lib.annotate import annotate_highlight from rhodecode.lib.utils import repo_name_slug from rhodecode.lib.utils2 import str2bool, safe_unicode, safe_str, \ - get_changeset_safe, datetime_to_time, time_to_datetime + get_changeset_safe, datetime_to_time, time_to_datetime, AttributeDict from rhodecode.lib.markup_renderer import MarkupRenderer from rhodecode.lib.vcs.exceptions import ChangesetDoesNotExistError from rhodecode.lib.vcs.backends.base import BaseChangeset diff -r 20c0af65ac52 -r 62e493c7f436 rhodecode/model/db.py --- a/rhodecode/model/db.py Thu Oct 18 02:14:30 2012 +0200 +++ b/rhodecode/model/db.py Thu Oct 18 20:16:00 2012 +0200 @@ -856,6 +856,10 @@ Session().add(repo) Session().commit() + @property + def last_db_change(self): + return self.updated_on + #========================================================================== # SCM PROPERTIES #========================================================================== diff -r 20c0af65ac52 -r 62e493c7f436 rhodecode/model/forms.py --- a/rhodecode/model/forms.py Thu Oct 18 02:14:30 2012 +0200 +++ b/rhodecode/model/forms.py Thu Oct 18 20:16:00 2012 +0200 @@ -254,6 +254,8 @@ rhodecode_show_private_icon = v.StringBoolean(if_missing=False) rhodecode_stylify_metatags = v.StringBoolean(if_missing=False) + rhodecode_lightweight_dashboard = v.StringBoolean(if_missing=False) + return _ApplicationVisualisationForm diff -r 20c0af65ac52 -r 62e493c7f436 rhodecode/model/scm.py --- a/rhodecode/model/scm.py Thu Oct 18 02:14:30 2012 +0200 +++ b/rhodecode/model/scm.py Thu Oct 18 20:16:00 2012 +0200 @@ -115,6 +115,7 @@ tmp_d = {} tmp_d['name'] = dbr.repo_name tmp_d['name_sort'] = tmp_d['name'].lower() + tmp_d['raw_name'] = tmp_d['name'].lower() tmp_d['description'] = dbr.description tmp_d['description_sort'] = tmp_d['description'].lower() tmp_d['last_change'] = last_change @@ -149,6 +150,7 @@ tmp_d = {} tmp_d['name'] = dbr.repo_name tmp_d['name_sort'] = tmp_d['name'].lower() + tmp_d['raw_name'] = tmp_d['name'].lower() tmp_d['description'] = dbr.description tmp_d['description_sort'] = tmp_d['description'].lower() tmp_d['dbrepo'] = dbr.get_dict() diff -r 20c0af65ac52 -r 62e493c7f436 rhodecode/templates/admin/settings/settings.html --- a/rhodecode/templates/admin/settings/settings.html Thu Oct 18 02:14:30 2012 +0200 +++ b/rhodecode/templates/admin/settings/settings.html Thu Oct 18 20:16:00 2012 +0200 @@ -122,6 +122,17 @@
+
+
+ +
+
+
+ ${h.checkbox('rhodecode_lightweight_dashboard','True')} + +
+
+
diff -r 20c0af65ac52 -r 62e493c7f436 rhodecode/templates/data_table/_dt_elements.html --- a/rhodecode/templates/data_table/_dt_elements.html Thu Oct 18 02:14:30 2012 +0200 +++ b/rhodecode/templates/data_table/_dt_elements.html Thu Oct 18 20:16:00 2012 +0200 @@ -76,8 +76,8 @@ ${h.link_to(get_name(name),h.url('summary_home',repo_name=name),class_="repo_name")} %endif %if fork_of: - - ${_('fork')} + + ${_('fork')} %endif
@@ -94,6 +94,22 @@
+<%def name="rss(name)"> + %if c.rhodecode_user.username != 'default': + + %else: + + %endif + + +<%def name="atom(name)"> + %if c.rhodecode_user.username != 'default': + + %else: + + %endif + + <%def name="user_gravatar(email, size=24)">
gravatar
diff -r 20c0af65ac52 -r 62e493c7f436 rhodecode/templates/index_base.html --- a/rhodecode/templates/index_base.html Thu Oct 18 02:14:30 2012 +0200 +++ b/rhodecode/templates/index_base.html Thu Oct 18 20:16:00 2012 +0200 @@ -59,10 +59,11 @@ + <%cnt=0%> + <%namespace name="dt" file="/data_table/_dt_elements.html"/> + % if c.visual.lightweight_dashboard is False: + ## old full detailed version
- <%cnt=0%> - <%namespace name="dt" file="/data_table/_dt_elements.html"/> - @@ -85,7 +86,7 @@ ##REPO NAME AND ICONS ##DESCRIPTION %endfor
- ${dt.repo_name(repo['name'],repo['dbrepo']['repo_type'],repo['dbrepo']['private'],repo['dbrepo_fork'].get('repo_name'),pageargs.get('short_repo_names'))} + ${dt.repo_name(repo['name'],repo['dbrepo']['repo_type'],repo['dbrepo']['private'],h.AttributeDict(repo['dbrepo_fork']),pageargs.get('short_repo_names'))} @@ -106,38 +107,33 @@ ## ${h.person(repo['contact'])} - %if c.rhodecode_user.username != 'default': - - %else: - - %endif: + ${dt.rss(repo['name'])} - %if c.rhodecode_user.username != 'default': - - %else: - - %endif: + ${dt.atom(repo['name'])}
+ % else: + ## lightweight version +
+
+ % endif
+ % if c.visual.lightweight_dashboard is False: + % else: + + % endif + \ No newline at end of file