##// END OF EJS Templates
implemented #84 downloads can be enabled/disabled per each repository from now.
marcink -
r962:72f008ed beta
parent child Browse files
Show More
@@ -164,6 +164,10 b' class FilesController(BaseController):'
164 164
165 165 try:
166 166 repo = ScmModel().get_repo(repo_name)
167
168 if repo.dbrepo.enable_downloads is False:
169 return _('downloads disabled')
170
167 171 cs = repo.get_changeset(revision)
168 172 content_type = ARCHIVE_SPECS[fileformat][0]
169 173 except ChangesetDoesNotExistError:
@@ -142,7 +142,9 b' class SummaryController(BaseController):'
142 142 c.trending_languages = json.dumps({})
143 143 c.no_data = True
144 144
145 c.download_options = self._get_download_links(c.repo_info)
145 c.enable_downloads = c.repo_info.dbrepo.enable_downloads
146 if c.enable_downloads:
147 c.download_options = self._get_download_links(c.repo_info)
146 148
147 149 return render('summary/summary.html')
148 150
@@ -184,6 +184,7 b' class Repository(Base, BaseModel):'
184 184 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=False, default=None)
185 185 private = Column("private", Boolean(), nullable=True, unique=None, default=None)
186 186 enable_statistics = Column("statistics", Boolean(), nullable=True, unique=None, default=True)
187 enable_downloads = Column("downloads", Boolean(), nullable=True, unique=None, default=True)
187 188 description = Column("description", String(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
188 189 fork_id = Column("fork_id", Integer(), ForeignKey('repositories.repo_id'), nullable=True, unique=False, default=None)
189 190 group_id = Column("group_id", Integer(), ForeignKey('groups.group_id'), nullable=True, unique=False, default=None)
@@ -447,6 +447,7 b' def RepoForm(edit=False, old_data={}, su'
447 447 description = UnicodeString(strip=True, min=1, not_empty=True)
448 448 private = StringBoolean(if_missing=False)
449 449 enable_statistics = StringBoolean(if_missing=False)
450 enable_downloads = StringBoolean(if_missing=False)
450 451 repo_type = OneOf(supported_backends)
451 452 if edit:
452 453 user = All(Int(not_empty=True), ValidRepoUser)
@@ -67,7 +67,15 b''
67 67 <div class="checkboxes">
68 68 ${h.checkbox('enable_statistics',value="True")}
69 69 </div>
70 </div>
70 </div>
71 <div class="field">
72 <div class="label label-checkbox">
73 <label for="enable_downloads">${_('Enable downloads')}:</label>
74 </div>
75 <div class="checkboxes">
76 ${h.checkbox('enable_downloads',value="True")}
77 </div>
78 </div>
71 79 <div class="field">
72 80 <div class="label">
73 81 <label for="user">${_('Owner')}:</label>
@@ -130,6 +130,11 b''
130 130 <div class="input-short">
131 131 %if len(c.repo_info.revisions) == 0:
132 132 ${_('There are no downloads yet')}
133 %elif c.enable_downloads is False:
134 ${_('Downloads are disabled for this repository')}
135 %if h.HasPermissionAll('hg.admin')('enable stats on from summary'):
136 [${h.link_to(_('enable'),h.url('edit_repo',repo_name=c.repo_name))}]
137 %endif
133 138 %else:
134 139 ${h.select('download_options',c.repo_info.get_changeset().raw_id,c.download_options)}
135 140 %for cnt,archive in enumerate(c.repo_info._get_archives()):
General Comments 0
You need to be logged in to leave comments. Login now