##// END OF EJS Templates
repository-groups: introduce last change for repository groups.
marcink -
r1940:04fca2a9 default
parent child Browse files
Show More
@@ -0,0 +1,35 b''
1 import logging
2 import datetime
3
4 from sqlalchemy import *
5 from rhodecode.model import meta
6 from rhodecode.lib.dbmigrate.versions import _reset_base, notify
7
8 log = logging.getLogger(__name__)
9
10
11 def upgrade(migrate_engine):
12 """
13 Upgrade operations go here.
14 Don't create your own engine; bind migrate_engine to your metadata
15 """
16 _reset_base(migrate_engine)
17 from rhodecode.lib.dbmigrate.schema import db_4_7_0_1 as db
18
19 repo_group_table = db.RepoGroup.__table__
20
21 updated_on = Column(
22 'updated_on', DateTime(timezone=False), nullable=True, unique=None,
23 default=datetime.datetime.now)
24 updated_on.create(table=repo_group_table)
25
26 fixups(db, meta.Session)
27
28
29 def downgrade(migrate_engine):
30 meta = MetaData()
31 meta.bind = migrate_engine
32
33
34 def fixups(models, _SESSION):
35 pass
@@ -51,7 +51,7 b' PYRAMID_SETTINGS = {}'
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__ = 78 # defines current db version for migrations
54 __dbversion__ = 79 # 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'
@@ -2213,6 +2213,7 b' class RepoGroup(Base, BaseModel):'
2213 enable_locking = Column("enable_locking", Boolean(), nullable=False, unique=None, default=False)
2213 enable_locking = Column("enable_locking", Boolean(), nullable=False, unique=None, default=False)
2214 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=False, default=None)
2214 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=False, default=None)
2215 created_on = Column('created_on', DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
2215 created_on = Column('created_on', DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
2216 updated_on = Column('updated_on', DateTime(timezone=False), nullable=True, unique=None, default=datetime.datetime.now)
2216 personal = Column('personal', Boolean(), nullable=True, unique=None, default=None)
2217 personal = Column('personal', Boolean(), nullable=True, unique=None, default=None)
2217
2218
2218 repo_group_to_perm = relationship('UserRepoGroupToPerm', cascade='all', order_by='UserRepoGroupToPerm.group_to_perm_id')
2219 repo_group_to_perm = relationship('UserRepoGroupToPerm', cascade='all', order_by='UserRepoGroupToPerm.group_to_perm_id')
@@ -2325,6 +2326,10 b' class RepoGroup(Base, BaseModel):'
2325 return groups
2326 return groups
2326
2327
2327 @property
2328 @property
2329 def last_db_change(self):
2330 return self.updated_on
2331
2332 @property
2328 def children(self):
2333 def children(self):
2329 return RepoGroup.query().filter(RepoGroup.parent_group == self)
2334 return RepoGroup.query().filter(RepoGroup.parent_group == self)
2330
2335
@@ -28,7 +28,7 b' import re'
28 import shutil
28 import shutil
29 import time
29 import time
30 import traceback
30 import traceback
31 from datetime import datetime, timedelta
31 import datetime
32
32
33 from pyramid.threadlocal import get_current_request
33 from pyramid.threadlocal import get_current_request
34 from zope.cachedescriptors.property import Lazy as LazyProperty
34 from zope.cachedescriptors.property import Lazy as LazyProperty
@@ -207,9 +207,9 b' class RepoModel(BaseModel):'
207 short_name=not admin, admin=False)
207 short_name=not admin, admin=False)
208
208
209 def last_change(last_change):
209 def last_change(last_change):
210 if admin and isinstance(last_change, datetime) and not last_change.tzinfo:
210 if admin and isinstance(last_change, datetime.datetime) and not last_change.tzinfo:
211 last_change = last_change + timedelta(seconds=
211 last_change = last_change + datetime.timedelta(seconds=
212 (datetime.now() - datetime.utcnow()).seconds)
212 (datetime.datetime.now() - datetime.datetime.utcnow()).seconds)
213 return _render("last_change", last_change)
213 return _render("last_change", last_change)
214
214
215 def rss_lnk(repo_name):
215 def rss_lnk(repo_name):
@@ -374,6 +374,7 b' class RepoModel(BaseModel):'
374 if ex_field:
374 if ex_field:
375 ex_field.field_value = kwargs[field]
375 ex_field.field_value = kwargs[field]
376 self.sa.add(ex_field)
376 self.sa.add(ex_field)
377 cur_repo.updated_on = datetime.datetime.now()
377 self.sa.add(cur_repo)
378 self.sa.add(cur_repo)
378
379
379 if source_repo_name != new_name:
380 if source_repo_name != new_name:
@@ -899,7 +900,7 b' class RepoModel(BaseModel):'
899 if os.path.exists(vcs_path):
900 if os.path.exists(vcs_path):
900 shutil.move(vcs_path, os.path.join(rm_path, 'rm__.%s' % alias))
901 shutil.move(vcs_path, os.path.join(rm_path, 'rm__.%s' % alias))
901
902
902 _now = datetime.now()
903 _now = datetime.datetime.now()
903 _ms = str(_now.microsecond).rjust(6, '0')
904 _ms = str(_now.microsecond).rjust(6, '0')
904 _d = 'rm__%s__%s' % (_now.strftime('%Y%m%d_%H%M%S_' + _ms),
905 _d = 'rm__%s__%s' % (_now.strftime('%Y%m%d_%H%M%S_' + _ms),
905 repo.just_name)
906 repo.just_name)
@@ -40,7 +40,7 b' from rhodecode.model.db import (_hash_ke'
40 UserGroup, Repository)
40 UserGroup, Repository)
41 from rhodecode.model.settings import VcsSettingsModel, SettingsModel
41 from rhodecode.model.settings import VcsSettingsModel, SettingsModel
42 from rhodecode.lib.caching_query import FromCache
42 from rhodecode.lib.caching_query import FromCache
43 from rhodecode.lib.utils2 import action_logger_generic
43 from rhodecode.lib.utils2 import action_logger_generic, datetime_to_time
44
44
45 log = logging.getLogger(__name__)
45 log = logging.getLogger(__name__)
46
46
@@ -501,7 +501,7 b' class RepoGroupModel(BaseModel):'
501
501
502 if 'user' in form_data:
502 if 'user' in form_data:
503 repo_group.user = User.get_by_username(form_data['user'])
503 repo_group.user = User.get_by_username(form_data['user'])
504
504 repo_group.updated_on = datetime.datetime.now()
505 self.sa.add(repo_group)
505 self.sa.add(repo_group)
506
506
507 # iterate over all members of this groups and do fixes
507 # iterate over all members of this groups and do fixes
@@ -518,6 +518,7 b' class RepoGroupModel(BaseModel):'
518 log.debug('Fixing group %s to new name %s',
518 log.debug('Fixing group %s to new name %s',
519 obj.group_name, new_name)
519 obj.group_name, new_name)
520 obj.group_name = new_name
520 obj.group_name = new_name
521 obj.updated_on = datetime.datetime.now()
521 elif isinstance(obj, Repository):
522 elif isinstance(obj, Repository):
522 # we need to get all repositories from this new group and
523 # we need to get all repositories from this new group and
523 # rename them accordingly to new group path
524 # rename them accordingly to new group path
@@ -525,6 +526,7 b' class RepoGroupModel(BaseModel):'
525 log.debug('Fixing repo %s to new name %s',
526 log.debug('Fixing repo %s to new name %s',
526 obj.repo_name, new_name)
527 obj.repo_name, new_name)
527 obj.repo_name = new_name
528 obj.repo_name = new_name
529 obj.updated_on = datetime.datetime.now()
528 self.sa.add(obj)
530 self.sa.add(obj)
529
531
530 self._rename_group(old_path, new_path)
532 self._rename_group(old_path, new_path)
@@ -685,6 +687,12 b' class RepoGroupModel(BaseModel):'
685 def repo_group_lnk(repo_group_name):
687 def repo_group_lnk(repo_group_name):
686 return _render('repo_group_name', repo_group_name)
688 return _render('repo_group_name', repo_group_name)
687
689
690 def last_change(last_change):
691 if admin and isinstance(last_change, datetime.datetime) and not last_change.tzinfo:
692 last_change = last_change + datetime.timedelta(seconds=
693 (datetime.datetime.now() - datetime.datetime.utcnow()).seconds)
694 return _render("last_change", last_change)
695
688 def desc(desc, personal):
696 def desc(desc, personal):
689 prefix = h.escaped_stylize(u'[personal] ') if personal else ''
697 prefix = h.escaped_stylize(u'[personal] ') if personal else ''
690
698
@@ -712,6 +720,8 b' class RepoGroupModel(BaseModel):'
712 "menu": quick_menu(group.group_name),
720 "menu": quick_menu(group.group_name),
713 "name": repo_group_lnk(group.group_name),
721 "name": repo_group_lnk(group.group_name),
714 "name_raw": group.group_name,
722 "name_raw": group.group_name,
723 "last_change": last_change(group.last_db_change),
724 "last_change_raw": datetime_to_time(group.last_db_change),
715 "desc": desc(group.description_safe, group.personal),
725 "desc": desc(group.description_safe, group.personal),
716 "top_level_repos": 0,
726 "top_level_repos": 0,
717 "owner": user_profile(group.user.username)
727 "owner": user_profile(group.user.username)
@@ -54,6 +54,9 b''
54 { data: 'menu', "bSortable": false, className: "quick_repo_menu" },
54 { data: 'menu', "bSortable": false, className: "quick_repo_menu" },
55 { data: {"_": "desc",
55 { data: {"_": "desc",
56 "sort": "desc"}, title: "${_('Description')}", className: "td-description" },
56 "sort": "desc"}, title: "${_('Description')}", className: "td-description" },
57 { data: {"_": "last_change",
58 "sort": "last_change_raw",
59 "type": Number}, title: "${_('Last Change')}", className: "td-time" },
57 { data: {"_": "top_level_repos",
60 { data: {"_": "top_level_repos",
58 "sort": "top_level_repos"}, title: "${_('Number of top level repositories')}" },
61 "sort": "top_level_repos"}, title: "${_('Number of top level repositories')}" },
59 { data: {"_": "owner",
62 { data: {"_": "owner",
@@ -98,6 +98,9 b''
98 { data: 'menu', "bSortable": false, className: "quick_repo_menu" },
98 { data: 'menu', "bSortable": false, className: "quick_repo_menu" },
99 { data: {"_": "desc",
99 { data: {"_": "desc",
100 "sort": "desc"}, title: "${_('Description')}", className: "td-description" },
100 "sort": "desc"}, title: "${_('Description')}", className: "td-description" },
101 { data: {"_": "last_change",
102 "sort": "last_change_raw",
103 "type": Number}, title: "${_('Last Change')}", className: "td-time" },
101 { data: {"_": "owner",
104 { data: {"_": "owner",
102 "sort": "owner"}, title: "${_('Owner')}", className: "td-user" }
105 "sort": "owner"}, title: "${_('Owner')}", className: "td-user" }
103 ],
106 ],
General Comments 0
You need to be logged in to leave comments. Login now