def get(self, id): if isinstance(id, basestring): id = re.search(r"\d*", id).group() if not id: abort(404) file = File.get(id) if file is None: abort(404) if file.parent is not None: redirect(file.url()) elif is_root(c.user): return self._get(file) else: c.login_form_url = url(controller='home', action='login', came_from=file.url()) deny(_('You have no right to download this file.'), 403)
def update(self, group): values = self.form_result group.title = values['title'] if values['year']: group.year = date(int(values['year']), 1, 1) group.description = values['description'] group.default_tab = values['default_tab'] group.admins_approve_members = ( self.form_result['approve_new_members'] == 'admin') group.forum_is_public = ( self.form_result['forum_visibility'] == 'public') group.mailinglist_moderated = ( self.form_result['mailinglist_moderated'] == 'moderated') group.mailinglist_enabled = True group.wants_to_watch_subjects = self.form_result['can_add_subjects'] group.has_file_area = self.form_result['file_storage'] if not group.mailinglist_enabled and not group.forum_categories: group.forum_categories.append(ForumCategory(_('General'), _('Discussions on anything and everything'))) # Fix default tab setting if needed. if group.default_tab == 'forum' \ or group.default_tab == 'mailinglist': group.default_tab = 'home' if group.default_tab == 'files' \ and not group.has_file_area: group.default_tab = 'home' if group.default_tab == 'subjects' \ and not group.wants_to_watch_subjects: group.default_tab == 'home' if values['logo_delete']: group.logo = None if values['logo_upload'] is not None: logo = values['logo_upload'] group.logo = logo.file.read() #check to see what kind of tags we have got tags = [tag.strip().lower() for tag in self.form_result.get('tagsitem', []) if len(tag.strip()) < 250 and tag.strip() != ''] if tags == []: tags = [tag.strip().lower() for tag in self.form_result.get('tags', '').split(',') if len(tag.strip()) < 250 and tag.strip() != ''] group.tags = [] for tag in tags: group.tags.append(SimpleTag.get(tag)) if not group.moderators or is_root(c.user): tag = values.get('location', None) group.location = tag if is_root(c.user): group.moderators = values['moderators'] meta.Session.commit() h.flash(_('Group information and settings updated.')) redirect(url(controller='group', action='home', id=group.group_id))