class MapBlock(Block): name = 'map' default_place = 'rightsidebar' help_text = _('Block that renders a google maps placed in a location') verbose_name = _('Maps Block') config_params = BaseBlock.config_params + [ params.Float( name="latitude", label=_("map latitude"), default=37.390925, ), params.Float( name="longitude", label=_("map longitude"), default=-5.994844, ), params.Integer( name="width", label=_("Map width"), default=200, ), params.Integer( name="height", label=_("Map height"), default=200, ), params.Integer( name="zoom", label=_("Map zoom"), default=4, ), params.Bool( name="render_ui", label=_("Render UI"), default=True, ), ] def render(self, request, place, context, *args, **kwargs): context = { 'zoom': self.get_config().get('zoom').get_value(), 'latitude': self.get_config().get('latitude').get_value(), 'longitude': self.get_config().get('longitude').get_value(), 'width': self.get_config().get('width').get_value(), 'height': self.get_config().get('height').get_value(), 'render_ui': self.get_config().get('render_ui').get_value(), 'MEDIA_URL': context.get('MEDIA_URL', settings.MEDIA_URL), 'GOOGLE_MAPS_API_KEY': context.get('GOOGLE_MAPS_API_KEY', ''), 'LANGUAGE_CODE': get_language(), 'reg_block': self.reg_item, 'request': context.get('request', None)} return self.render_block( request, template_name='maps/block_map.html', block_title=_('Map'), context=context, )
class SectionFilterItemProvider(object): config_params = [ params.Bool( name='filtering_section', label= _('If the collection is into a section, filter for the contents of this section' ), default=True, ), ]
class PluginConfig(Plugin): name = 'Feedback' description = 'Feedback plugin' version = '0.0.1' url_prefixes = (('feedback', 'plugins.feedback.urls'), ) config_params = [ params.Integer(name='number_of_comments', label=_('Number of comment for each content'), default=-1), params.Bool(name='show_children', label=_('Show children'), default=True), params.Bool(name='show_links', label=_('Show options bar'), default=True), ] def get_blocks(self): return [FeedbackBlock]
class LatestFilesBlock(BlockQuerySetItemProvider, Block): name = 'latestfiles' default_place = 'rightsidebar' verbose_name = _('Latest Files Block') help_text = _( 'Block that represents a list of recent files of the filebrowser') config_params = BaseBlock.config_params + BlockQuerySetItemProvider.config_params + [ params.PositiveInteger( name='limit', label=_('number of files for the "Latest Files" block'), default=3, ), params.Single( name='mainrepo', label=_('Name of the repository to show files from it'), default='', ), params.Bool( name='filtering_document', label= _('If the repository name is equal to document slug, filter for the files of this repository' ), default=False, ), ] default_caching_params = { 'enabled': False, 'timeout': 3600, 'only_anonymous': True, 'vary_on_user': False, 'vary_on_url': True, 'vary_on_language': True, } def get_contents(self, request=None, context=None, section=None): repos = Repository.objects.all() return repos def queryset(self, request=None, context=None, section=None): queryset = self.get_contents(request, context, section) content = context.get('content', None) document = isinstance(content, Document) and content if section and self.get_config().get('filtering_section', False).get_value(): queryset = queryset.filter(section=section) if self.get_config().get('filtering_document', False).get_value() and \ document and queryset.filter(name=document.slug): queryset = queryset.filter(name=document.slug) return queryset def render(self, request, place, context, *args, **kwargs): repolist = self.get_queryset(request, context) limit = self.get_config().get('limit').get_value() mainrepo = self.get_config().get('mainrepo').get_value() main = None if mainrepo: try: main = repolist.get(name=mainrepo) except Repository.DoesNotExist: pass if main: files = main.latest_files(limit) else: if not repolist: return '' files = [] for repo in repolist: files += repo.latest_files(limit) if not files: return '' files = sorted(files, key=lambda f: f.modificated, reverse=True)[:limit] return self.render_block( request, template_name='filebrowser/blocks/latestfiles.html', block_title=ugettext('Downloads'), context={ 'files': files, })
# Merengue is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with Merengue. If not, see <http://www.gnu.org/licenses/>. """ Tests for merengue.registry application """ from merengue.registry import params from merengue.registry.items import RegistrableItem config_params = [ params.Bool(name='is_human', default=True), params.Integer(name='age'), params.List(name='friends', choices=('Juan', 'Luis', 'Pepe')) ] class PersonItem(RegistrableItem): config_params = config_params class SingletonItem(RegistrableItem): singleton = True config_params = config_params __test__ = {