##// END OF EJS Templates
exported get_repos_as_dict for new grids
marcink -
r4147:2f1114af default
parent child Browse files
Show More
@@ -43,13 +43,12 b' from rhodecode.lib.utils2 import ('
43 43 from rhodecode.lib.vcs.backends import get_backend
44 44 from rhodecode.model import BaseModel
45 45 from rhodecode.model.db import (
46 _hash_key, joinedload, or_, Repository, UserRepoToPerm, UserGroupRepoToPerm,
46 _hash_key, func, case, joinedload, or_, in_filter_generator,
47 Session, Repository, UserRepoToPerm, UserGroupRepoToPerm,
47 48 UserRepoGroupToPerm, UserGroupRepoGroupToPerm, User, Permission,
48 49 Statistics, UserGroup, RepoGroup, RepositoryField, UserLog)
49
50 50 from rhodecode.model.settings import VcsSettingsModel
51 51
52
53 52 log = logging.getLogger(__name__)
54 53
55 54
@@ -249,26 +248,29 b' class RepoModel(BaseModel):'
249 248
250 249 repos_data = []
251 250 for repo in repo_list:
252 cs_cache = repo.changeset_cache
251 # NOTE(marcink): because we use only raw column we need to load it like that
252 changeset_cache = Repository._load_changeset_cache(
253 repo.repo_id, repo._changeset_cache)
254 last_commit_change = Repository._load_commit_change(changeset_cache)
255
253 256 row = {
254 257 "menu": quick_menu(repo.repo_name),
255 258
256 259 "name": repo_lnk(repo.repo_name, repo.repo_type, repo.repo_state,
257 260 repo.private, repo.archived, repo.fork),
258 261 "name_raw": repo.repo_name.lower(),
262 "desc": desc(repo.description),
259 263
260 "last_change": last_change(repo.last_commit_change),
261 "last_change_raw": datetime_to_time(repo.last_commit_change),
264 "last_change": last_change(last_commit_change),
265 "last_change_raw": datetime_to_time(last_commit_change),
262 266
263 "last_changeset": last_rev(repo.repo_name, cs_cache),
264 "last_changeset_raw": cs_cache.get('revision'),
267 "last_changeset": last_rev(repo.repo_name, changeset_cache),
268 "last_changeset_raw": changeset_cache.get('revision'),
265 269
266 "desc": desc(repo.description_safe),
267 "owner": user_profile(repo.user.username),
270 "owner": user_profile(repo.User.username),
268 271
269 272 "state": state(repo.repo_state),
270 273 "rss": rss_lnk(repo.repo_name),
271
272 274 "atom": atom_lnk(repo.repo_name),
273 275 }
274 276 if admin:
@@ -36,8 +36,8 b' from zope.cachedescriptors.property impo'
36 36
37 37 from rhodecode import events
38 38 from rhodecode.model import BaseModel
39 from rhodecode.model.db import (_hash_key,
40 RepoGroup, UserRepoGroupToPerm, User, Permission, UserGroupRepoGroupToPerm,
39 from rhodecode.model.db import (_hash_key, func, or_, in_filter_generator,
40 Session, RepoGroup, UserRepoGroupToPerm, User, Permission, UserGroupRepoGroupToPerm,
41 41 UserGroup, Repository)
42 42 from rhodecode.model.settings import VcsSettingsModel, SettingsModel
43 43 from rhodecode.lib.caching_query import FromCache
@@ -698,6 +698,8 b' class RepoGroupModel(BaseModel):'
698 698 for repo_group in repo_groups:
699 699 repo_group.update_commit_cache()
700 700
701
702
701 703 def get_repo_groups_as_dict(self, repo_group_list=None, admin=False,
702 704 super_user_actions=False):
703 705
@@ -721,11 +723,6 b' class RepoGroupModel(BaseModel):'
721 723 last_change = last_change + datetime.timedelta(seconds=utc_offset)
722 724 return _render("last_change", last_change)
723 725
724 def last_rev(repo_name, cs_cache):
725 return _render('revision', repo_name, cs_cache.get('revision'),
726 cs_cache.get('raw_id'), cs_cache.get('author'),
727 cs_cache.get('message'), cs_cache.get('date'))
728
729 726 def desc(desc, personal):
730 727 return _render(
731 728 'repo_group_desc', desc, personal, c.visual.stylify_metatags)
@@ -742,22 +739,24 b' class RepoGroupModel(BaseModel):'
742 739
743 740 repo_group_data = []
744 741 for group in repo_group_list:
745 cs_cache = group.changeset_cache
746 last_repo_name = cs_cache.get('source_repo_name')
747
742 # NOTE(marcink): because we use only raw column we need to load it like that
743 changeset_cache = RepoGroup._load_changeset_cache(
744 '', group._changeset_cache)
745 last_commit_change = RepoGroup._load_commit_change(changeset_cache)
748 746 row = {
749 747 "menu": quick_menu(group.group_name),
750 748 "name": repo_group_lnk(group.group_name),
751 749 "name_raw": group.group_name,
752 "last_change": last_change(group.last_commit_change),
753 "last_change_raw": datetime_to_time(group.last_commit_change),
750
751 "last_change": last_change(last_commit_change),
752 "last_change_raw": datetime_to_time(last_commit_change),
754 753
755 754 "last_changeset": "",
756 755 "last_changeset_raw": "",
757 756
758 "desc": desc(group.description_safe, group.personal),
757 "desc": desc(group.group_description, group.personal),
759 758 "top_level_repos": 0,
760 "owner": user_profile(group.user.username)
759 "owner": user_profile(group.User.username)
761 760 }
762 761 if admin:
763 762 repo_count = group.repositories.count()
General Comments 0
You need to be logged in to leave comments. Login now