Changeset - 2c2bdaeca912
[Not reviewed]
codereview
0 6 0
Marcin Kuzminski - 14 years ago 2012-04-30 12:32:29
marcin@python-works.com
Transplanted from: 3317fdf9283c
code-review initial
6 files changed with 75 insertions and 2 deletions:
0 comments (0 inline, 0 general)
rhodecode/controllers/changelog.py
Show inline comments
 
@@ -84,7 +84,7 @@ class ChangelogController(BaseRepoContro
 
            collection = list(c.pagination)
 
            page_revisions = [x.raw_id for x in collection]
 
            c.comments = c.rhodecode_db_repo.comments(page_revisions)
 

	
 
            c.statuses = c.rhodecode_db_repo.statuses(page_revisions)
 
        except (RepositoryError, ChangesetDoesNotExistError, Exception), e:
 
            log.error(traceback.format_exc())
 
            h.flash(str(e), category='warning')
rhodecode/controllers/changeset.py
Show inline comments
 
@@ -203,10 +203,16 @@ class ChangesetController(BaseRepoContro
 
        c.cut_off = False  # defines if cut off limit is reached
 

	
 
        c.comments = []
 
        c.statuses = []
 
        c.inline_comments = []
 
        c.inline_cnt = 0
 
        # Iterate over ranges (default changeset view is always one changeset)
 
        for changeset in c.cs_ranges:
 

	
 
            c.statuses.extend(ChangesetStatusModel()\
 
                              .get_status(c.rhodecode_db_repo.repo_id,
 
                                          changeset.raw_id))
 

	
 
            c.comments.extend(ChangesetCommentsModel()\
 
                              .get_comments(c.rhodecode_db_repo.repo_id,
 
                                            changeset.raw_id))
rhodecode/lib/profiler.py
Show inline comments
 
from __future__ import with_statement
 

	
 
import gc
 
import objgraph
 
import cProfile
 
import pstats
 
import cgi
 
@@ -26,7 +28,7 @@ class ProfilingMiddleware(object):
 
            profiler.snapshot_stats()
 

	
 
            stats = pstats.Stats(profiler)
 
            stats.sort_stats('cumulative')
 
            stats.sort_stats('calls') #cummulative
 

	
 
            # Redirect output
 
            out = StringIO()
 
@@ -44,6 +46,11 @@ class ProfilingMiddleware(object):
 
                         'border-top: 4px dashed red; padding: 1em;">')
 
                resp += cgi.escape(out.getvalue(), True)
 

	
 
                ct = objgraph.show_most_common_types()
 
                print ct
 

	
 
                resp += ct if ct else '---'
 

	
 
                output = StringIO()
 
                pprint.pprint(environ, output, depth=3)
 

	
rhodecode/model/db.py
Show inline comments
 
@@ -34,6 +34,8 @@ from sqlalchemy.ext.hybrid import hybrid
 
from sqlalchemy.orm import relationship, joinedload, class_mapper, validates
 
from beaker.cache import cache_region, region_invalidate
 

	
 
_ = lambda s: s
 

	
 
from rhodecode.lib.vcs import get_backend
 
from rhodecode.lib.vcs.utils.helpers import get_scm
 
from rhodecode.lib.vcs.exceptions import VCSError
 
@@ -675,6 +677,23 @@ class Repository(Base, BaseModel):
 
            grouped[cmt.revision].append(cmt)
 
        return grouped
 

	
 
    def statuses(self, revisions=None):
 
        """
 
        Returns statuses for this repository
 
        :param revisions: list of revisions to get statuses for
 
        :type revisions: list
 
        """
 

	
 
        statuses = ChangesetStatus.query()\
 
            .filter(ChangesetStatus.repo == self)
 
        if revisions:
 
            statuses = statuses.filter(ChangesetStatus.revision.in_(revisions))
 
        grouped = defaultdict(list)
 
        for stat in statuses.all():
 
            grouped[statuses.revision].append(stat)
 
        return grouped
 

	
 
        
 
    #==========================================================================
 
    # SCM CACHE INSTANCE
 
    #==========================================================================
 
@@ -1207,6 +1226,44 @@ class ChangesetComment(Base, BaseModel):
 
                .join(ChangesetComment.author).all()
 

	
 

	
 
class ChangesetStatus(Base, BaseModel):
 
    __tablename__ = 'changeset_statuses'
 
    __table_args__ = (
 
        {'extend_existing': True, 'mysql_engine': 'InnoDB',
 
         'mysql_charset': 'utf8'}
 
    )
 

	
 
    STATUSES = [
 
        ('not_reviewed', _("Not Reviewed")),  # (no icon) and default
 
        ('approved', _("Approved")),
 
        ('rejected', _("Rejected")),
 
        ('under_review', _("Under Review")),
 
    ]
 

	
 
    changeset_status_id = Column('changeset_status_id', Integer(), nullable=False, primary_key=True)
 
    repo_id = Column('repo_id', Integer(), ForeignKey('repositories.repo_id'), nullable=False)
 
    user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=None)
 
    revision = Column('revision', String(40), nullable=False)
 
    status = Column('status', String(128), nullable=False, default=STATUSES[0][0])
 
    modified_at = Column('modified_at', DateTime(), nullable=False, default=datetime.datetime.now)
 

	
 
    author = relationship('User', lazy='joined')
 
    repo = relationship('Repository')
 

	
 

	
 
class ChangesetStatusHistory(Base, BaseModel):
 
    __tablename__ = 'changeset_statuses_history'
 
    __table_args__ = (
 
        {'extend_existing': True, 'mysql_engine': 'InnoDB',
 
         'mysql_charset': 'utf8'}
 
    )
 
    #TODO: check if sqla has a nice history table implementation
 
    changeset_status_id = Column('changeset_status_id', Integer(), ForeignKey('changeset_statuses.changeset_status_id'), nullable=False, primary_key=True)
 
    user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=None)
 
    status = Column('status', String(128), nullable=False)
 
    modified_at = Column('modified_at', DateTime(), nullable=False, default=datetime.datetime.now)
 

	
 

	
 
class Notification(Base, BaseModel):
 
    __tablename__ = 'notifications'
 
    __table_args__ = (
rhodecode/templates/changelog/changelog.html
Show inline comments
 
@@ -65,6 +65,7 @@ ${c.repo_name} ${_('Changelog')} - ${c.r
 
						<div class="right">
 
									<div id="${cs.raw_id}_changes_info" class="changes">
 
                                        <div id="${cs.raw_id}"  style="float:right;" class="changed_total tooltip" title="${_('Affected number of files, click to show more details')}">${len(cs.affected_files)}</div>
 
                                        <div class="changeset-status-container">${c.statuses.get(cs.raw_id)}</div>
 
                                        <div class="comments-container">
 
                                        %if len(c.comments.get(cs.raw_id,[])) > 0:
 
                                            <div class="comments-cnt" title="${('comments')}">
rhodecode/templates/changelog/changelog_details.html
Show inline comments
 
## small box that displays changed/added/removed details fetched by AJAX
 

	
 
% if len(c.cs.affected_files) <= c.affected_files_cut_off:
 
<span class="removed tooltip" title="<b>${_('removed')}</b>${h.changed_tooltip(c.cs.removed)}">${len(c.cs.removed)}</span>
 
<span class="changed tooltip" title="<b>${_('changed')}</b>${h.changed_tooltip(c.cs.changed)}">${len(c.cs.changed)}</span>
0 comments (0 inline, 0 general)