Changeset - 72f008ed9b18
[Not reviewed]
beta
0 6 0
Marcin Kuzminski - 15 years ago 2011-01-26 18:37:42
marcin@python-works.com
implemented #84 downloads can be enabled/disabled per each repository from now.
6 files changed with 23 insertions and 2 deletions:
0 comments (0 inline, 0 general)
rhodecode/controllers/files.py
Show inline comments
 
@@ -161,12 +161,16 @@ class FilesController(BaseController):
 
                fileformat = a_type or ext_data[1]
 
                revision = archive_spec[0]
 
                ext = ext_data[1]
 

	
 
        try:
 
            repo = ScmModel().get_repo(repo_name)
 

	
 
            if repo.dbrepo.enable_downloads is False:
 
                return _('downloads disabled')
 

	
 
            cs = repo.get_changeset(revision)
 
            content_type = ARCHIVE_SPECS[fileformat][0]
 
        except ChangesetDoesNotExistError:
 
            return _('Unknown revision %s') % revision
 
        except EmptyRepositoryError:
 
            return _('Empty repository')
rhodecode/controllers/summary.py
Show inline comments
 
@@ -139,13 +139,15 @@ class SummaryController(BaseController):
 
        else:
 
            c.commit_data = json.dumps({})
 
            c.overview_data = json.dumps([[ts_min_y, 0], [ts_max_y, 10] ])
 
            c.trending_languages = json.dumps({})
 
            c.no_data = True
 

	
 
        c.download_options = self._get_download_links(c.repo_info)
 
        c.enable_downloads = c.repo_info.dbrepo.enable_downloads
 
        if c.enable_downloads:
 
            c.download_options = self._get_download_links(c.repo_info)
 

	
 
        return render('summary/summary.html')
 

	
 

	
 

	
 
    def _get_download_links(self, repo):
rhodecode/model/db.py
Show inline comments
 
@@ -181,12 +181,13 @@ class Repository(Base, BaseModel):
 
    repo_id = Column("repo_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
 
    repo_name = Column("repo_name", String(length=None, convert_unicode=False, assert_unicode=None), nullable=False, unique=True, default=None)
 
    repo_type = Column("repo_type", String(length=None, convert_unicode=False, assert_unicode=None), nullable=False, unique=False, default='hg')
 
    user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=False, default=None)
 
    private = Column("private", Boolean(), nullable=True, unique=None, default=None)
 
    enable_statistics = Column("statistics", Boolean(), nullable=True, unique=None, default=True)
 
    enable_downloads = Column("downloads", Boolean(), nullable=True, unique=None, default=True)
 
    description = Column("description", String(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
 
    fork_id = Column("fork_id", Integer(), ForeignKey('repositories.repo_id'), nullable=True, unique=False, default=None)
 
    group_id = Column("group_id", Integer(), ForeignKey('groups.group_id'), nullable=True, unique=False, default=None)
 

	
 
    user = relation('User')
 
    fork = relation('Repository', remote_side=repo_id)
rhodecode/model/forms.py
Show inline comments
 
@@ -444,12 +444,13 @@ def RepoForm(edit=False, old_data={}, su
 
        filter_extra_fields = False
 
        repo_name = All(UnicodeString(strip=True, min=1, not_empty=True),
 
                        ValidRepoName(edit, old_data))
 
        description = UnicodeString(strip=True, min=1, not_empty=True)
 
        private = StringBoolean(if_missing=False)
 
        enable_statistics = StringBoolean(if_missing=False)
 
        enable_downloads = StringBoolean(if_missing=False)
 
        repo_type = OneOf(supported_backends)
 
        if edit:
 
            user = All(Int(not_empty=True), ValidRepoUser)
 

	
 
        chained_validators = [ValidPerms]
 
    return _RepoForm
rhodecode/templates/admin/repos/repo_edit.html
Show inline comments
 
@@ -64,13 +64,21 @@
 
                <div class="label label-checkbox">
 
                    <label for="enable_statistics">${_('Enable statistics')}:</label>
 
                </div>
 
                <div class="checkboxes">
 
                    ${h.checkbox('enable_statistics',value="True")}
 
                </div>
 
            </div>             
 
            </div>     
 
            <div class="field">
 
                <div class="label label-checkbox">
 
                    <label for="enable_downloads">${_('Enable downloads')}:</label>
 
                </div>
 
                <div class="checkboxes">
 
                    ${h.checkbox('enable_downloads',value="True")}
 
                </div>
 
            </div>                      
 
            <div class="field">
 
                <div class="label">
 
                    <label for="user">${_('Owner')}:</label>
 
                </div>
 
                <div class="input input-small ac">
 
                    <div class="perm_ac">
rhodecode/templates/summary/summary.html
Show inline comments
 
@@ -127,12 +127,17 @@
 
			  <div class="label">
 
			      <label>${_('Download')}:</label>
 
			  </div>
 
			  <div class="input-short">
 
		        %if len(c.repo_info.revisions) == 0:
 
		          ${_('There are no downloads yet')}
 
		        %elif c.enable_downloads is False:
 
		          ${_('Downloads are disabled for this repository')}
 
                    %if h.HasPermissionAll('hg.admin')('enable stats on from summary'):
 
                        [${h.link_to(_('enable'),h.url('edit_repo',repo_name=c.repo_name))}]
 
                    %endif  		          
 
		        %else:
 
			        ${h.select('download_options',c.repo_info.get_changeset().raw_id,c.download_options)}
 
			        %for cnt,archive in enumerate(c.repo_info._get_archives()):
 
			             %if cnt >=1:
 
			             |
 
			             %endif
0 comments (0 inline, 0 general)