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 | 51 | EXTENSIONS = {} |
|
52 | 52 | |
|
53 | 53 | __version__ = ('.'.join((str(each) for each in VERSION[:3]))) |
|
54 |
__dbversion__ = 7 |
|
|
54 | __dbversion__ = 79 # defines current db version for migrations | |
|
55 | 55 | __platform__ = platform.system() |
|
56 | 56 | __license__ = 'AGPLv3, and Commercial License' |
|
57 | 57 | __author__ = 'RhodeCode GmbH' |
@@ -2213,6 +2213,7 b' class RepoGroup(Base, BaseModel):' | |||
|
2213 | 2213 | enable_locking = Column("enable_locking", Boolean(), nullable=False, unique=None, default=False) |
|
2214 | 2214 | user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=False, default=None) |
|
2215 | 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 | 2217 | personal = Column('personal', Boolean(), nullable=True, unique=None, default=None) |
|
2217 | 2218 | |
|
2218 | 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 | 2326 | return groups |
|
2326 | 2327 | |
|
2327 | 2328 | @property |
|
2329 | def last_db_change(self): | |
|
2330 | return self.updated_on | |
|
2331 | ||
|
2332 | @property | |
|
2328 | 2333 | def children(self): |
|
2329 | 2334 | return RepoGroup.query().filter(RepoGroup.parent_group == self) |
|
2330 | 2335 |
@@ -28,7 +28,7 b' import re' | |||
|
28 | 28 | import shutil |
|
29 | 29 | import time |
|
30 | 30 | import traceback |
|
31 | from datetime import datetime, timedelta | |
|
31 | import datetime | |
|
32 | 32 | |
|
33 | 33 | from pyramid.threadlocal import get_current_request |
|
34 | 34 | from zope.cachedescriptors.property import Lazy as LazyProperty |
@@ -207,9 +207,9 b' class RepoModel(BaseModel):' | |||
|
207 | 207 | short_name=not admin, admin=False) |
|
208 | 208 | |
|
209 | 209 | def last_change(last_change): |
|
210 | if admin and isinstance(last_change, datetime) and not last_change.tzinfo: | |
|
211 | last_change = last_change + timedelta(seconds= | |
|
212 | (datetime.now() - datetime.utcnow()).seconds) | |
|
210 | if admin and isinstance(last_change, datetime.datetime) and not last_change.tzinfo: | |
|
211 | last_change = last_change + datetime.timedelta(seconds= | |
|
212 | (datetime.datetime.now() - datetime.datetime.utcnow()).seconds) | |
|
213 | 213 | return _render("last_change", last_change) |
|
214 | 214 | |
|
215 | 215 | def rss_lnk(repo_name): |
@@ -374,6 +374,7 b' class RepoModel(BaseModel):' | |||
|
374 | 374 | if ex_field: |
|
375 | 375 | ex_field.field_value = kwargs[field] |
|
376 | 376 | self.sa.add(ex_field) |
|
377 | cur_repo.updated_on = datetime.datetime.now() | |
|
377 | 378 | self.sa.add(cur_repo) |
|
378 | 379 | |
|
379 | 380 | if source_repo_name != new_name: |
@@ -899,7 +900,7 b' class RepoModel(BaseModel):' | |||
|
899 | 900 | if os.path.exists(vcs_path): |
|
900 | 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 | 904 | _ms = str(_now.microsecond).rjust(6, '0') |
|
904 | 905 | _d = 'rm__%s__%s' % (_now.strftime('%Y%m%d_%H%M%S_' + _ms), |
|
905 | 906 | repo.just_name) |
@@ -40,7 +40,7 b' from rhodecode.model.db import (_hash_ke' | |||
|
40 | 40 | UserGroup, Repository) |
|
41 | 41 | from rhodecode.model.settings import VcsSettingsModel, SettingsModel |
|
42 | 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 | 45 | log = logging.getLogger(__name__) |
|
46 | 46 | |
@@ -501,7 +501,7 b' class RepoGroupModel(BaseModel):' | |||
|
501 | 501 | |
|
502 | 502 | if 'user' in form_data: |
|
503 | 503 | repo_group.user = User.get_by_username(form_data['user']) |
|
504 | ||
|
504 | repo_group.updated_on = datetime.datetime.now() | |
|
505 | 505 | self.sa.add(repo_group) |
|
506 | 506 | |
|
507 | 507 | # iterate over all members of this groups and do fixes |
@@ -518,6 +518,7 b' class RepoGroupModel(BaseModel):' | |||
|
518 | 518 | log.debug('Fixing group %s to new name %s', |
|
519 | 519 | obj.group_name, new_name) |
|
520 | 520 | obj.group_name = new_name |
|
521 | obj.updated_on = datetime.datetime.now() | |
|
521 | 522 | elif isinstance(obj, Repository): |
|
522 | 523 | # we need to get all repositories from this new group and |
|
523 | 524 | # rename them accordingly to new group path |
@@ -525,6 +526,7 b' class RepoGroupModel(BaseModel):' | |||
|
525 | 526 | log.debug('Fixing repo %s to new name %s', |
|
526 | 527 | obj.repo_name, new_name) |
|
527 | 528 | obj.repo_name = new_name |
|
529 | obj.updated_on = datetime.datetime.now() | |
|
528 | 530 | self.sa.add(obj) |
|
529 | 531 | |
|
530 | 532 | self._rename_group(old_path, new_path) |
@@ -685,6 +687,12 b' class RepoGroupModel(BaseModel):' | |||
|
685 | 687 | def repo_group_lnk(repo_group_name): |
|
686 | 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 | 696 | def desc(desc, personal): |
|
689 | 697 | prefix = h.escaped_stylize(u'[personal] ') if personal else '' |
|
690 | 698 | |
@@ -712,6 +720,8 b' class RepoGroupModel(BaseModel):' | |||
|
712 | 720 | "menu": quick_menu(group.group_name), |
|
713 | 721 | "name": repo_group_lnk(group.group_name), |
|
714 | 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 | 725 | "desc": desc(group.description_safe, group.personal), |
|
716 | 726 | "top_level_repos": 0, |
|
717 | 727 | "owner": user_profile(group.user.username) |
@@ -54,6 +54,9 b'' | |||
|
54 | 54 | { data: 'menu', "bSortable": false, className: "quick_repo_menu" }, |
|
55 | 55 | { data: {"_": "desc", |
|
56 | 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 | 60 | { data: {"_": "top_level_repos", |
|
58 | 61 | "sort": "top_level_repos"}, title: "${_('Number of top level repositories')}" }, |
|
59 | 62 | { data: {"_": "owner", |
@@ -98,6 +98,9 b'' | |||
|
98 | 98 | { data: 'menu', "bSortable": false, className: "quick_repo_menu" }, |
|
99 | 99 | { data: {"_": "desc", |
|
100 | 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 | 104 | { data: {"_": "owner", |
|
102 | 105 | "sort": "owner"}, title: "${_('Owner')}", className: "td-user" } |
|
103 | 106 | ], |
General Comments 0
You need to be logged in to leave comments.
Login now