Esempio n. 1
0
    def get(self, request, pk=None):

        current_theme = request.website.theme.split('/')[0]
        try:
            current_style = request.website.theme.split('/')[1]
        except:
            current_style = None
        # Render HTML

        if not pk:
            pk = current_theme
        theme = themes_info(pk)[0]

        html = render_to_string('administration/design/styles_list.html', {
            'theme': theme,
            'current_theme': current_theme,
            'current_style': current_style
        },
                                context_instance=RequestContext(request))

        response = Response(status.HTTP_200_OK, {
            "html": html,
            'current': current_theme
        })
        return self.render(response)
Esempio n. 2
0
def get_list_design(request):
    """
        Return a list of all design available
        
        [{slug: 'design1', data:{author: 'ionyse', 'thumbnail': '', ...}},
         {slug: 'design1', data:{author: 'ionyse', 'thumbnail': '', ...}}, etc ...]
    """
    return themes_info()
Esempio n. 3
0
def get_list_design(request):
    """
        Return a list of all design available
        
        [{slug: 'design1', data:{author: 'ionyse', 'thumbnail': '', ...}},
         {slug: 'design1', data:{author: 'ionyse', 'thumbnail': '', ...}}, etc ...]
    """
    return themes_info()
Esempio n. 4
0
    def get(self, request):
        """
        Managements of the Themes List
        """

        list_themes = sorted(themes_info(), key=lambda theme: theme['title'].lower())

        html = render_to_string('administration/manifest/themes-list.html',
                                {'list_themes': list_themes,
                                 'current': request.website.theme},
                                context_instance = RequestContext(request))
        
        response = Response(status.HTTP_200_OK, {"html": html})

        return self.render(response)
Esempio n. 5
0
    def __init__(self, *args, **kwargs):
        super(PageWAForm, self).__init__(*args, **kwargs)
        self.fields['app_page_type'].choices = content_type_choices(LIMIT_CHOICES_TO)
        # Need to hide 'default_template' by default
        hide_default_tpl_field = True
        # Only if edition mode
        if hasattr(self.instance, 'pk'):
            if self.instance.pk:
                # Add help_text
                self.fields['app_page_type'].help_text = _(u"Be careful : if you change the app type, "
                                                           u"the current app will be deleted.")
                # Hide the slug field if we edit the homepage
                if self.instance.is_homepage:
                    self.fields['slug'].widget = forms.HiddenInput()

                # Initialization of templates theme
                theme_infos = themes_info(self.instance.website.theme.split('/')[0])[0]
                if 'templates' in theme_infos:
                    # Theme has many templates
                    # we set the choices with those values
                    choices_default_templates = []
                    for template in theme_infos['templates']:
                        if template['file'] == settings.TEMPLATE_THEME_FILE_DEFAULT:
                            file_value = ""
                        else:
                            file_value = template['file']
                        choices_default_templates.append((
                                file_value,
                                ({'title': template['title'], 'preview': template['preview']}),
                                ))
                    self.fields['default_template'].choices = choices_default_templates
                    # We don't hide the field
                    hide_default_tpl_field = False

        if hide_default_tpl_field:
            # The theme defines only one template,
            # so we hide the field and we add the current value of template page
            # in choices to avoid error validation
            self.fields['default_template'].choices = [(self.instance.default_template, '')]
            self.fields['default_template'].widget = forms.HiddenInput()
Esempio n. 6
0
 def get(self, request, pk=None):
     
    
     current_theme = request.website.theme.split('/')[0]
     try:
         current_style = request.website.theme.split('/')[1]
     except:
         current_style = None
     # Render HTML
     
     if not pk:
         pk = current_theme
     theme = themes_info(pk)[0]
     
     html = render_to_string('administration/design/styles_list.html',
                             {'theme': theme,
                              'current_theme': current_theme,
                              'current_style': current_style},
                             context_instance = RequestContext(request))
     
     response = Response(status.HTTP_200_OK, {"html": html, 'current': current_theme})
     return self.render(response)