def updissstatus(request, id):
    """
    Change the status. This will advance the status by one.
    So, if an issue has been reported and we come into this
    function, then it will then get promoted to "ongoing".
    If it is ongoing and we come in here, then will be promoted
    to "fixed". This could have easily been combined with the
    upvote function, but did this for complete clarity.
    """
    i = get_object_or_404(Issue, pk=id)

    # This should not happen, but check to make sure that we are
    # not here for an item with the wrong status. Also, make
    # sure the record doesn't already have a closed status. Again,
    # it shouldn't happen, but let's be safe.
    if i.status >= FILTERS.get('issues_closed'):
        messages.add_message(request, messages.ERROR,
                             "Issue is already closed.")
    else:
        x = i.status + 1
        if x > FILTERS.get('issues_closed'):
            messages.add_message(request, messages.ERROR,
                                 "Action results in an invalid status.")
        else:
            i.status = x
            i.save()

    # Take user back to main page, but ensure we maintain the filter state
    return redirect(
        reverse('filters', args=(request.session['issue_filter'], )))
示例#2
0
    def test_filters_reported_issues_declined_features_GET(self):
        session = self.client.session
        session['issue_filter'] = FILTERS.get('issues_reported')
        session['feature_filter'] = FILTERS.get('features_declined')
        session.save()
        response = self.client.get(self.filters_url)

        self.assertEquals(response.status_code, 200)
        self.assertTemplateUsed(response, 'index.html')
示例#3
0
class Issue(models.Model):
    """ Issue (bug) model """
    id = models.AutoField(primary_key=True)
    entered_by = models.CharField(max_length=40, blank=True, default=None)
    entered_by_email = models.EmailField(max_length=80,
                                         blank=True,
                                         default=None)
    subj = models.CharField(max_length=80, blank=False)
    desc = models.TextField(blank=False)
    status = models.PositiveSmallIntegerField(
        default=FILTERS.get('issues_reported'))
    upvotes = models.PositiveIntegerField(default=0)
    date_closed = models.DateField(null=True, default=None, blank=True)
    date_modified = models.DateTimeField(auto_now=True)
    date_added = models.DateTimeField(auto_now_add=True)

    def __int__(self):
        return self.id
示例#4
0
class Feature(models.Model):
    """ Feature model """
    id = models.AutoField(primary_key=True)
    entered_by = models.CharField(max_length=40, blank=True, default=None)
    entered_by_email = models.EmailField(max_length=80, blank=False)
    feature = models.CharField(max_length=80, blank=False)
    desc = models.TextField(blank=False)
    status = models.PositiveSmallIntegerField(
        default=FILTERS.get('features_requested'))
    bid = models.DecimalField(max_digits=6, decimal_places=2)
    date_accept_or_deny = models.DateField(null=True, default=None, blank=True)
    date_paid = models.DateTimeField(null=True, default=None, blank=True)
    date_completed = models.DateField(null=True, default=None, blank=True)
    date_modified = models.DateTimeField(auto_now=True)
    date_added = models.DateTimeField(auto_now_add=True)

    def __int__(self):
        return self.id
def makepayment(request):
    """Make payment"""
    if request.method == 'POST':
        person_details_form = PersonDetailsForm(request.POST)
        cc_details_form = CCDetailsForm(request.POST)
        if person_details_form.is_valid() and cc_details_form.is_valid():
            feature = get_object_or_404(Feature,
                                        pk=request.session.get(
                                            'active_feature_id', {}))
            try:
                customer = stripe.Charge.create(
                    amount=int(feature.bid * 100),
                    currency=DEFAULT_CURRENCY,
                    description=feature.entered_by,
                    card=cc_details_form.cleaned_data['stripe_id'])
            except stripe.error.CardError:
                messages.add_message(request, messages.ERROR,
                                     "Your card was declined!")

            if customer.paid:
                # Advance feature status
                feature.date_paid = timezone.now()
                feature.status = FILTERS.get('features_working')
                feature.save()
                messages.add_message(
                    request, messages.SUCCESS,
                    "Your payment was accepted. Thank you! We will start working immediately."
                )
        else:
            if cc_details_form.is_valid() == False:
                print("cc details form failed")
                print("****************** Form Errors *******************")
                print(cc_details_form.errors)
                print("*************** Non Field Errors *****************")
                print(cc_details_form.non_field_errors)
            else:
                print("person details form failed")
                print("****************** Form Errors *******************")
                print(person_details_form.errors)
                print("*************** Non Field Errors *****************")
                print(person_details_form.non_field_errors)

    return redirect(reverse('index'))