Example #1
0
    def __init__(self, *args, **kwargs):
        super(DirectoryRenewForm, self).__init__(*args, **kwargs)

        if self.fields.has_key("payment_method"):
            self.fields["payment_method"].widget = forms.RadioSelect(choices=get_payment_method_choices(self.user))
        if self.fields.has_key("pricing"):
            self.fields["pricing"].choices = get_duration_choices(self.user)
Example #2
0
    def __init__(self, *args, **kwargs):
        super(DirectoryRenewForm, self).__init__(*args, **kwargs)

        if 'payment_method' in self.fields:
            self.fields['payment_method'].widget = forms.RadioSelect(choices=get_payment_method_choices(self.user))
        if 'pricing' in self.fields:
            self.fields['pricing'].choices = get_duration_choices(self.user)
Example #3
0
    def __init__(self, *args, **kwargs):
        super(DirectoryRenewForm, self).__init__(*args, **kwargs)

        if 'payment_method' in self.fields:
            self.fields['payment_method'].widget = forms.RadioSelect(choices=get_payment_method_choices(self.user))
        if 'pricing' in self.fields:
            self.fields['pricing'].choices = get_duration_choices(self.user)
Example #4
0
    def __init__(self, *args, **kwargs):
        super(DirectoryForm, self).__init__(*args, **kwargs)
        if self.instance.pk:
            self.fields["body"].widget.mce_attrs["app_instance_id"] = self.instance.pk
            if self.user.profile.is_superuser:
                self.fields["status_detail"].choices = (
                    ("active", _("Active")),
                    ("inactive", _("Inactive")),
                    ("pending", _("Pending")),
                    ("paid - pending approval", _("Paid - Pending Approval")),
                )
        else:
            self.fields["body"].widget.mce_attrs["app_instance_id"] = 0

        if self.instance.logo:
            self.initial["logo"] = self.instance.logo

        if not self.user.profile.is_superuser:
            if "status_detail" in self.fields:
                self.fields.pop("status_detail")

        if self.fields.has_key("payment_method"):
            self.fields["payment_method"].widget = forms.RadioSelect(choices=get_payment_method_choices(self.user))
        if self.fields.has_key("pricing"):
            self.fields["pricing"].choices = get_duration_choices(self.user)

        self.fields["timezone"].initial = settings.TIME_ZONE

        # expiration_dt = activation_dt + requested_duration
        fields_to_pop = ["expiration_dt"]
        if not self.user.profile.is_superuser:
            fields_to_pop += [
                "slug",
                "entity",
                "allow_anonymous_view",
                "user_perms",
                "member_perms",
                "group_perms",
                "post_dt",
                "activation_dt",
                "syndicate",
                "status_detail",
            ]

        for f in list(set(fields_to_pop)):
            if f in self.fields:
                self.fields.pop(f)
Example #5
0
    def __init__(self, *args, **kwargs):
        super(DirectoryForm, self).__init__(*args, **kwargs)
        if self.instance.pk:
            self.fields['body'].widget.mce_attrs['app_instance_id'] = self.instance.pk
            if self.user.profile.is_superuser:
                self.fields['status_detail'].choices = (('active',_('Active')),
                                                        ('inactive',_('Inactive')),
                                                        ('pending',_('Pending')),
                                                        ('paid - pending approval', _('Paid - Pending Approval')),)
        else:
            self.fields['body'].widget.mce_attrs['app_instance_id'] = 0

        if self.instance.logo:
            self.initial['logo'] = self.instance.logo

        if not self.user.profile.is_superuser:
            if 'status_detail' in self.fields: self.fields.pop('status_detail')

        if self.fields.has_key('payment_method'):
            self.fields['payment_method'].widget = forms.RadioSelect(choices=get_payment_method_choices(self.user))
        if self.fields.has_key('pricing'):
            self.fields['pricing'].choices = get_duration_choices(self.user)

        self.fields['timezone'].initial = settings.TIME_ZONE

        # expiration_dt = activation_dt + requested_duration
        fields_to_pop = ['expiration_dt']
        if not self.user.profile.is_superuser:
            fields_to_pop += [
                'slug',
                'entity',
                'allow_anonymous_view',
                'user_perms',
                'member_perms',
                'group_perms',
                'post_dt',
                'activation_dt',
                'syndicate',
                'status_detail'
            ]

        for f in list(set(fields_to_pop)):
            if f in self.fields:
                self.fields.pop(f)
Example #6
0
    def __init__(self, *args, **kwargs):
        super(DirectoryForm, self).__init__(*args, **kwargs)
        if self.instance.pk:
            self.fields['body'].widget.mce_attrs[
                'app_instance_id'] = self.instance.pk
            if self.user.profile.is_superuser:
                self.fields['status_detail'].choices = (
                    ('active', _('Active')),
                    ('inactive', _('Inactive')),
                    ('pending', _('Pending')),
                    ('paid - pending approval', _('Paid - Pending Approval')),
                )
        else:
            self.fields['body'].widget.mce_attrs['app_instance_id'] = 0

        if self.instance.logo:
            self.initial['logo'] = self.instance.logo

        if not self.user.profile.is_superuser:
            if 'status_detail' in self.fields: self.fields.pop('status_detail')

        if 'payment_method' in self.fields:
            self.fields['payment_method'] = forms.ChoiceField(
                widget=forms.RadioSelect,
                choices=get_payment_method_choices(self.user))
        if 'pricing' in self.fields:
            self.fields['pricing'].choices = get_duration_choices(self.user)

        self.fields['timezone'].initial = settings.TIME_ZONE

        # cat and sub_cat
        if self.user.profile.is_superuser:
            self.fields['sub_cat'].help_text = mark_safe(
                '<a href="{0}">{1}</a>'.format(
                    reverse('admin:directories_category_changelist'),
                    _('Manage Categories'),
                ))
        if self.instance and self.instance.pk:
            self.fields['sub_cat'].queryset = DirectoryCategory.objects.filter(
                parent=self.instance.cat)
        if args:
            post_data = args[0]
        else:
            post_data = None
        if post_data:
            cat = post_data.get('cat', '0')
            if cat and cat != '0' and cat != u'':
                cat = DirectoryCategory.objects.get(pk=int(cat))
                self.fields[
                    'sub_cat'].queryset = DirectoryCategory.objects.filter(
                        parent=cat)

        # expiration_dt = activation_dt + requested_duration
        fields_to_pop = ['expiration_dt']
        if not self.user.profile.is_superuser:
            fields_to_pop += [
                'slug', 'entity', 'allow_anonymous_view', 'user_perms',
                'member_perms', 'group_perms', 'post_dt', 'activation_dt',
                'syndicate', 'status_detail'
            ]

        for f in list(set(fields_to_pop)):
            if f in self.fields:
                self.fields.pop(f)
Example #7
0
    def __init__(self, *args, **kwargs):
        super(DirectoryForm, self).__init__(*args, **kwargs)
        if self.instance.pk:
            self.fields['body'].widget.mce_attrs['app_instance_id'] = self.instance.pk
            if self.user.profile.is_superuser:
                self.fields['status_detail'].choices = (('active',_('Active')),
                                                        ('inactive',_('Inactive')),
                                                        ('pending',_('Pending')),
                                                        ('paid - pending approval', _('Paid - Pending Approval')),)
        else:
            self.fields['body'].widget.mce_attrs['app_instance_id'] = 0

        if self.instance.logo:
            self.initial['logo'] = self.instance.logo

        if not self.user.profile.is_superuser:
            if 'status_detail' in self.fields: self.fields.pop('status_detail')

        if 'payment_method' in self.fields:
            self.fields['payment_method'] = forms.ChoiceField(widget=forms.RadioSelect, choices=get_payment_method_choices(self.user))
        if 'pricing' in self.fields:
            self.fields['pricing'].choices = get_duration_choices(self.user)

        self.fields['timezone'].initial = settings.TIME_ZONE

        # cat and sub_cat
        if self.user.profile.is_superuser:
            self.fields['sub_cat'].help_text = mark_safe('<a href="{0}">{1}</a>'.format(
                                        reverse('admin:directories_category_changelist'),
                                        _('Manage Categories'),))
        if self.instance and self.instance.pk:
            self.fields['sub_cat'].queryset = DirectoryCategory.objects.filter(
                                                        parent=self.instance.cat)
        if args:
            post_data = args[0]
        else:
            post_data = None
        if post_data:
            cat = post_data.get('cat', '0')
            if cat and cat != '0' and cat != u'':
                cat = DirectoryCategory.objects.get(pk=int(cat))
                self.fields['sub_cat'].queryset = DirectoryCategory.objects.filter(parent=cat)

        # expiration_dt = activation_dt + requested_duration
        fields_to_pop = ['expiration_dt']
        if not self.user.profile.is_superuser:
            fields_to_pop += [
                'slug',
                'entity',
                'allow_anonymous_view',
                'user_perms',
                'member_perms',
                'group_perms',
                'post_dt',
                'activation_dt',
                'syndicate',
                'status_detail'
            ]

        for f in list(set(fields_to_pop)):
            if f in self.fields:
                self.fields.pop(f)
Example #8
0
    def __init__(self, *args, **kwargs):
        super(DirectoryForm, self).__init__(*args, **kwargs)
        self.fields['headline'].help_text = _('Company or Organization name')
        if self.instance.pk:
            self.fields['body'].widget.mce_attrs['app_instance_id'] = self.instance.pk
            if self.user.profile.is_superuser:
                self.fields['status_detail'].choices = (('active',_('Active')),
                                                        ('inactive',_('Inactive')),
                                                        ('pending',_('Pending')),
                                                        ('paid - pending approval', _('Paid - Pending Approval')),)
        else:
            self.fields['body'].widget.mce_attrs['app_instance_id'] = 0

        if self.instance.logo:
            self.initial['logo'] = self.instance.logo

        if not self.user.profile.is_superuser:
            if 'status_detail' in self.fields: self.fields.pop('status_detail')

        if 'payment_method' in self.fields:
            self.fields['payment_method'] = forms.ChoiceField(widget=forms.RadioSelect, choices=get_payment_method_choices(self.user))
        if 'pricing' in self.fields:
            self.fields['pricing'].choices = get_duration_choices(self.user)

        self.fields['timezone'].initial = settings.TIME_ZONE

        # cat and sub_cat
        self.fields['sub_cats'].queryset = DirectoryCategory.objects.exclude(parent=None)
        self.fields['sub_cats'].choices = _get_sub_cats_choices(directory=self.instance)
        
        if self.user.profile.is_superuser:
            self.fields['sub_cats'].help_text = mark_safe('<a href="{0}">{1}</a>'.format(
                                        reverse('admin:directories_category_changelist'),
                                        _('Manage Categories'),))
#         if self.instance and self.instance.pk:
#             self.fields['sub_cats'].queryset = DirectoryCategory.objects.filter(
#                                                         parent__in=self.instance.cats.all())
#         if args:
#             post_data = args[0]
#         else:
#             post_data = None
#         if post_data:
#             cats = post_data.get('cats', None)
#             if cats:
#                 cats = [int(cat) for cat in cats if cat.isdigit()]
#                 cats = DirectoryCategory.objects.filter(pk__in=cats)
#                 self.fields['sub_cats'].queryset = DirectoryCategory.objects.filter(parent__in=cats)

        # expiration_dt = activation_dt + requested_duration
        fields_to_pop = ['expiration_dt']
        if not self.user.profile.is_superuser:
            fields_to_pop += [
                'slug',
                'entity',
                'allow_anonymous_view',
                'user_perms',
                'member_perms',
                'group_perms',
                'post_dt',
                'activation_dt',
                'syndicate',
                'cats',
                'sub_cats',
                'status_detail'
            ]

        for f in list(set(fields_to_pop)):
            if f in self.fields:
                self.fields.pop(f)

        if 'sub_cats' in self.fields and get_setting('module', 'directories', 'disablesubcategories'):
            self.fields.pop('sub_cats')

        if 'sub_cats' not in self.fields:
            if self.user.profile.is_superuser:
                self.fields['cats'].help_text += mark_safe('<br /><a href="{0}">{1}</a>'.format(
                            reverse('admin:directories_category_changelist'),
                            _('Manage Categories'),))