예제 #1
0
    def get_description(self):
        # TODO: Optimize this SEM algorithm
        description = self.object.description

        description = strip_html(description)
        description = truncate_words(description, 40, '')
        return description
예제 #2
0
def striphtml(value):
    """Strips all [X]HTML tags and entities."""
    return strip_html(value)
예제 #3
0
 def prepare_description(self, obj):
     return strip_html(obj.description)
예제 #4
0
 def prepare_body(self, obj):
     return strip_html(obj.body)
예제 #5
0
 def prepare_answer(self, obj):
     return strip_html(obj.answer)
예제 #6
0
 def prepare_content(self, obj):
     return strip_html(obj.content)
예제 #7
0
 def prepare_response(self, obj):
     return strip_html(obj.response)
예제 #8
0
 def prepare_intro(self, obj):
     return strip_html(obj.intro)
예제 #9
0
def add(request, form_class=MakePaymentForm, template_name="make_payments/add.html"):
    if request.method == "POST":
        form = form_class(request.user, request.POST)

        if form.is_valid():
            mp = form.save(commit=False)
            # we might need to create a user record if not exist
            if request.user.is_authenticated:
                user = request.user
            else:
                try:
                    user = User.objects.get(email=mp.email)
                except:
                    user = request.user

            if not user.is_anonymous:
                mp.user = user
                mp.creator = user
                mp.creator_username = user.username
            mp.save(user)

            # create invoice
            invoice = make_payment_inv_add(user, mp)

            EventLog.objects.log(instance=invoice)

            # updated the invoice_id for mp, so save again
            mp.save(user)

            EventLog.objects.log(instance=mp)

            # send notification to administrators
            # get admin notice recipients
            recipients = get_notice_recipients('module', 'payments', 'paymentrecipients')
            if recipients:
                if notification:
                    extra_context = {
                        'mp': mp,
                        'invoice': invoice,
                        'request': request,
                    }
                    notification.send_emails(recipients,'make_payment_added', extra_context)

            # email to user
            email_receipt = form.cleaned_data['email_receipt']
            if email_receipt:
                make_payment_email_user(request, mp, invoice)

            # redirect to online payment or confirmation page
            if mp.payment_method == 'cc' or mp.payment_method == 'credit card':
                return HttpResponseRedirect(reverse('payment.pay_online', args=[invoice.id, invoice.guid]))
            else:
                return HttpResponseRedirect(reverse('make_payment.add_confirm', args=[mp.id]))
    else:
        form = form_class(request.user)

        # check for initial payment_amount and clean up
        payment_amount = request.GET.get('payment_amount', 0)
        try:
            payment_amount = float(payment_amount)
        except:
            payment_amount = 0
        if payment_amount > 0:
            form.fields['payment_amount'].initial = payment_amount

        # check for initial comment and clean up
        comments = request.GET.get('comments','')
        if comments:
            comments = strip_html(comments)
            form.fields['comments'].initial = comments

    currency_symbol = get_setting("site", "global", "currencysymbol")
    if not currency_symbol: currency_symbol = "$"

    return render_to_resp(request=request, template_name=template_name,
        context={'form':form, 'currency_symbol': currency_symbol})
예제 #10
0
def striphtml(value):
    """Strips all [X]HTML tags and entities."""
    return strip_html(value)
예제 #11
0
 def prepare_caption(self, obj):
     return strip_html(obj.caption)