Example #1
0
    def __init__(self, *args, **kwargs):
        super(PageForm, self).__init__(*args, **kwargs)
        if self.instance.header_image:
            self.fields[
                'header_image'].help_text = '<input name="remove_photo" id="id_remove_photo" type="checkbox"/> %s: <a target="_blank" href="/files/%s/">%s</a>' % (
                    _('Remove current image'), self.instance.header_image.pk,
                    basename(self.instance.header_image.file.name))
        else:
            self.fields.pop('remove_photo')

        if self.instance.pk:
            self.fields['content'].widget.mce_attrs[
                'app_instance_id'] = self.instance.pk
        else:
            self.fields['content'].widget.mce_attrs['app_instance_id'] = 0

        template_choices = [('default.html', _('Default'))]
        template_choices += get_template_list()
        self.fields['template'].choices = template_choices
        self.fields['google_profile'].help_text = mark_safe(
            GOOGLE_PLUS_HELP_TEXT)

        if not self.user.profile.is_superuser:
            if 'syndicate' in self.fields: self.fields.pop('syndicate')
            if 'status_detail' in self.fields: self.fields.pop('status_detail')
Example #2
0
 def __init__(self, *args, **kwargs): 
     super(PageAdminForm, self).__init__(*args, **kwargs)
     if self.instance.pk:
         self.fields['content'].widget.mce_attrs['app_instance_id'] = self.instance.pk
     else:
         self.fields['content'].widget.mce_attrs['app_instance_id'] = 0
     
     template_choices = [('default.html','Default')]
     template_choices += get_template_list()
     self.fields['template'].choices = template_choices
Example #3
0
 def __init__(self, *args, **kwargs): 
     super(PageAdminForm, self).__init__(*args, **kwargs)
     if self.instance.pk:
         self.fields['content'].widget.mce_attrs['app_instance_id'] = self.instance.pk
     else:
         self.fields['content'].widget.mce_attrs['app_instance_id'] = 0
     
     template_choices = [('default.html','Default')]
     template_choices += get_template_list()
     self.fields['template'].choices = template_choices
Example #4
0
def create_new_template(request, form_class=AddTemplateForm):
    """
    Create a new blank template for a given template name
    """
    form = form_class(request.POST or None)
    ret_dict = {'created': False, 'err': ''}

    if form.is_valid():
        template_name = form.cleaned_data['template_name'].strip()
        template_full_name = 'default-%s.html' % template_name
        existing_templates = [t[0] for t in get_template_list()]
        if not template_full_name in existing_templates:
            # create a new template and assign default content
            use_s3_storage = getattr(settings, 'USE_S3_STORAGE', '')
            if use_s3_storage:
                theme_dir = settings.ORIGINAL_THEMES_DIR
            else:
                theme_dir = settings.THEMES_DIR
            template_dir = os.path.join(theme_dir,
                                get_setting('module', 'theme_editor', 'theme'),
                                'templates')
            template_full_path = os.path.join(template_dir,
                                template_full_name)
            # grab the content from the new-default-template.html
            # first check if there is a customized one on the site
            default_template_name = 'new-default-template.html'
            default_template_path = os.path.join(template_dir,
                                'theme_editor',
                                default_template_name)
            if not os.path.isfile(default_template_path):
                # no customized one found, use the default one
                default_template_path = os.path.join(
                    os.path.abspath(os.path.dirname(__file__)),
                    'templates/theme_editor',
                    default_template_name)
            if os.path.isfile(default_template_path):
                default_content = open(default_template_path).read()
            else:
                default_content = ''
            with open(template_full_path, 'w') as f:
                f.write(default_content)
            if use_s3_storage:
                # django default_storage not set for theme, that's why we cannot use it
                save_file_to_s3(template_full_path)

            ret_dict['created'] = True
            ret_dict['template_name'] = template_full_name
        else:
            ret_dict['err'] = 'Template "%s" already exists' % template_full_name
        

    return HttpResponse(json.dumps(ret_dict))
Example #5
0
def create_new_template(request, form_class=AddTemplateForm):
    """
    Create a new blank template for a given template name
    """
    form = form_class(request.POST or None)
    ret_dict = {'created': False, 'err': ''}

    if form.is_valid():
        template_name = form.cleaned_data['template_name'].strip()
        template_full_name = 'default-%s.html' % template_name
        existing_templates = [t[0] for t in get_template_list()]
        if not template_full_name in existing_templates:
            # create a new template and assign default content
            use_s3_storage = getattr(settings, 'USE_S3_STORAGE', '')
            if use_s3_storage:
                theme_dir = settings.ORIGINAL_THEMES_DIR
            else:
                theme_dir = settings.THEMES_DIR
            template_dir = os.path.join(theme_dir,
                                get_setting('module', 'theme_editor', 'theme'),
                                'templates')
            template_full_path = os.path.join(template_dir,
                                template_full_name)
            # grab the content from the new-default-template.html
            # first check if there is a customized one on the site
            default_template_name = 'new-default-template.html'
            default_template_path = os.path.join(template_dir,
                                'theme_editor',
                                default_template_name)
            if not os.path.isfile(default_template_path):
                # no customized one found, use the default one
                default_template_path = os.path.join(
                    os.path.abspath(os.path.dirname(__file__)),
                    'templates/theme_editor',
                    default_template_name)
            if os.path.isfile(default_template_path):
                default_content = open(default_template_path).read()
            else:
                default_content = ''
            with open(template_full_path, 'w') as f:
                f.write(default_content)
            if use_s3_storage:
                # django default_storage not set for theme, that's why we cannot use it
                save_file_to_s3(template_full_path)

            ret_dict['created'] = True
            ret_dict['template_name'] = template_full_name
        else:
            ret_dict['err'] = _('Template "%(name)s" already exists' % {'name':template_full_name})


    return HttpResponse(json.dumps(ret_dict))
Example #6
0
    def __init__(self, *args, **kwargs):
        super(PageAdminForm, self).__init__(*args, **kwargs)
        if self.instance.pk:
            self.fields['content'].widget.mce_attrs['app_instance_id'] = self.instance.pk
            if self.instance.meta:
                self.fields['meta_title'].initial = self.instance.meta.title
                self.fields['meta_description'].initial = self.instance.meta.description
                self.fields['meta_keywords'].initial = self.instance.meta.keywords
                self.fields['meta_canonical_url'].initial = self.instance.meta.canonical_url
        else:
            self.fields['content'].widget.mce_attrs['app_instance_id'] = 0

        template_choices = [('default.html',_('Default'))]
        template_choices += get_template_list()
        self.fields['template'].choices = template_choices
Example #7
0
 def __init__(self, *args, **kwargs): 
     super(PageAdminForm, self).__init__(*args, **kwargs)
     if self.instance.pk:
         self.fields['content'].widget.mce_attrs['app_instance_id'] = self.instance.pk
         if self.instance.meta:
             self.fields['meta_title'].initial = self.instance.meta.title
             self.fields['meta_description'].initial = self.instance.meta.description
             self.fields['meta_keywords'].initial = self.instance.meta.keywords
             self.fields['meta_canonical_url'].initial = self.instance.meta.canonical_url
     else:
         self.fields['content'].widget.mce_attrs['app_instance_id'] = 0
     
     template_choices = [('default.html','Default')]
     template_choices += get_template_list()
     self.fields['template'].choices = template_choices
Example #8
0
def create_new_template(request, form_class=AddTemplateForm):
    """
    Create a new blank template for a given template name
    """
    form = form_class(request.POST or None)
    ret_dict = {"created": False, "err": ""}

    if form.is_valid():
        template_name = form.cleaned_data["template_name"].strip()
        template_full_name = "default-%s.html" % template_name
        existing_templates = [t[0] for t in get_template_list()]
        if not template_full_name in existing_templates:
            # create a new template and assign default content
            use_s3_storage = getattr(settings, "USE_S3_STORAGE", "")
            if use_s3_storage:
                theme_dir = settings.ORIGINAL_THEMES_DIR
            else:
                theme_dir = settings.THEMES_DIR
            template_dir = os.path.join(theme_dir, get_setting("module", "theme_editor", "theme"), "templates")
            template_full_path = os.path.join(template_dir, template_full_name)
            # grab the content from the new-default-template.html
            # first check if there is a customized one on the site
            default_template_name = "new-default-template.html"
            default_template_path = os.path.join(template_dir, "theme_editor", default_template_name)
            if not os.path.isfile(default_template_path):
                # no customized one found, use the default one
                default_template_path = os.path.join(
                    os.path.abspath(os.path.dirname(__file__)), "templates/theme_editor", default_template_name
                )
            if os.path.isfile(default_template_path):
                default_content = open(default_template_path).read()
            else:
                default_content = ""
            with open(template_full_path, "w") as f:
                f.write(default_content)
            if use_s3_storage:
                # django default_storage not set for theme, that's why we cannot use it
                save_file_to_s3(template_full_path)

            ret_dict["created"] = True
            ret_dict["template_name"] = template_full_name
        else:
            ret_dict["err"] = _('Template "%(name)s" already exists' % {"name": template_full_name})

    return HttpResponse(json.dumps(ret_dict))
Example #9
0
    def __init__(self, *args, **kwargs): 
        super(PageForm, self).__init__(*args, **kwargs)
        if self.instance.header_image:
            self.fields['header_image'].help_text = '<input name="remove_photo" id="id_remove_photo" type="checkbox"/> Remove current image: <a target="_blank" href="/files/%s/">%s</a>' % (self.instance.header_image.pk, basename(self.instance.header_image.file.name))
        else:
            self.fields.pop('remove_photo')

        if self.instance.pk:
            self.fields['content'].widget.mce_attrs['app_instance_id'] = self.instance.pk
        else:
            self.fields['content'].widget.mce_attrs['app_instance_id'] = 0
        
        template_choices = [('default.html','Default')]
        template_choices += get_template_list()
        self.fields['template'].choices = template_choices
        
        if not self.user.profile.is_superuser:
            if 'syndicate' in self.fields: self.fields.pop('syndicate')
            if 'status_detail' in self.fields: self.fields.pop('status_detail')
Example #10
0
from tendenci.core.payments.models import PaymentMethod
from tinymce.widgets import TinyMCE
from tendenci.core.perms.forms import TendenciBaseForm
from captcha.fields import CaptchaField
from tendenci.apps.user_groups.models import Group
from tendenci.core.base.utils import get_template_list, tcurrency
from tendenci.core.base.fields import EmailVerificationField, PriceField
from tendenci.core.base.utils import currency_check

from tendenci.addons.recurring_payments.fields import BillingCycleField
from tendenci.addons.recurring_payments.widgets import BillingCycleWidget, BillingDateSelectWidget
from tendenci.apps.forms_builder.forms.models import FormEntry, FieldEntry, Field, Form, Pricing
from tendenci.apps.forms_builder.forms.settings import FIELD_MAX_LENGTH, UPLOAD_ROOT

template_choices = [('default.html',_('Default'))]
template_choices += get_template_list()

#fs = FileSystemStorage(location=UPLOAD_ROOT)

FIELD_FNAME_LENGTH = 30
FIELD_LNAME_LENGTH = 30
FIELD_NAME_LENGTH = 50
FIELD_PHONE_LENGTH = 50
THIS_YEAR = datetime.today().year

class FormForForm(forms.ModelForm):

    class Meta:
        model = FormEntry
        exclude = ("form", "entry_time", "entry_path", "payment_method", "pricing", "creator")
Example #11
0
from os.path import splitext, basename

from tendenci.apps.pages.models import Page
from tendenci.core.perms.forms import TendenciBaseForm

from django.utils.safestring import mark_safe
from django import forms
from django.utils.translation import ugettext_lazy as _
from django.template.defaultfilters import filesizeformat

from tinymce.widgets import TinyMCE
from tendenci.core.base.utils import get_template_list
from tendenci.core.files.utils import get_max_file_upload_size

template_choices = [('default.html','Default')]
template_choices += get_template_list()

ALLOWED_IMG_EXT = (
    '.jpg',
    '.jpeg',
    '.gif',
    '.png' 
)
CONTRIBUTOR_CHOICES = (
    (Page.CONTRIBUTOR_AUTHOR, mark_safe('Author <i class="gauthor-info fa fa-lg fa-question-circle"></i>')),
    (Page.CONTRIBUTOR_PUBLISHER, mark_safe('Publisher <i class="gpub-info fa fa-lg fa-question-circle"></i>'))
)
GOOGLE_PLUS_HELP_TEXT = 'Additional Options for Authorship <i class="gauthor-help fa fa-lg fa-question-circle"></i><br>Additional Options for Publisher <i class="gpub-help fa fa-lg fa-question-circle"></i>'

class PageAdminForm(TendenciBaseForm):
    content = forms.CharField(required=False,