Skip to content

Commit

Permalink
remove old Donation/Bid processing pages and related files
Browse files Browse the repository at this point in the history
[#182383857]
  • Loading branch information
uraniumanchor committed Jun 6, 2022
1 parent 844192b commit c9d25b8
Show file tree
Hide file tree
Showing 21 changed files with 6 additions and 27,778 deletions.
82 changes: 0 additions & 82 deletions tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,58 +32,6 @@ def test_get_loads(self):
self.assertContains(response, 'Select which donor to use as the template')


class ProcessDonationsTest(TestCase):
def setUp(self):
self.rand = random.Random(None)
self.superuser = User.objects.create_superuser(
'superuser', '[email protected]', 'password',
)
self.processor = User.objects.create(username='processor', is_staff=True)
self.processor.user_permissions.add(
Permission.objects.get(name='Can change donor'),
Permission.objects.get(name='Can change donation'),
)
self.head_processor = User.objects.create(
username='head_processor', is_staff=True
)
self.head_processor.user_permissions.add(
Permission.objects.get(name='Can change donor'),
Permission.objects.get(name='Can change donation'),
Permission.objects.get(name='Can send donations to the reader'),
)
self.event = randgen.build_random_event(self.rand)
self.session = self.client.session
self.session.save()

def test_one_step_screening(self):
self.client.force_login(self.processor)
response = self.client.get(
reverse('admin:process_donations', args=(self.event.short,))
)
self.assertEqual(response.context['user_can_approve'], True)
self.assertEqual(response.status_code, 200)

def test_two_step_screening_non_head(self):
self.event.use_one_step_screening = False
self.event.save()
self.client.force_login(self.processor)
response = self.client.get(
reverse('admin:process_donations', args=(self.event.short,))
)
self.assertEqual(response.context['user_can_approve'], False)
self.assertEqual(response.status_code, 200)

def test_two_step_screening_with_head(self):
self.event.use_one_step_screening = False
self.event.save()
self.client.force_login(self.head_processor)
response = self.client.get(
reverse('admin:process_donations', args=(self.event.short,))
)
self.assertEqual(response.context['user_can_approve'], True)
self.assertEqual(response.status_code, 200)


class ProcessDonationsBrowserTest(TrackerSeleniumTestCase):
def setUp(self):
self.rand = random.Random(None)
Expand Down Expand Up @@ -179,26 +127,6 @@ def setUp(self):
self.session = self.client.session
self.session.save()

def test_read_donations(self):
self.client.force_login(self.superuser)
response = self.client.get(reverse('admin:read_donations'))
self.assertEqual(response.status_code, 200)

response = self.client.get(
reverse('admin:read_donations', args=(self.event.short,))
)
self.assertEqual(response.status_code, 200)

def test_process_donations(self):
self.client.force_login(self.superuser)
response = self.client.get(reverse('admin:process_donations'))
self.assertEqual(response.status_code, 200)

response = self.client.get(
reverse('admin:process_donations', args=(self.event.short,))
)
self.assertEqual(response.status_code, 200)

def test_merge_bids(self):
self.client.force_login(self.superuser)
randgen.generate_runs(self.rand, self.event, 5)
Expand All @@ -210,16 +138,6 @@ def test_merge_bids(self):
self.assertEqual(response.status_code, 200)
self.assertContains(response, 'Select which bid to use as the template')

def test_process_pending_bids(self):
self.client.force_login(self.superuser)
response = self.client.get(reverse('admin:process_pending_bids'))
self.assertEqual(response.status_code, 200)

response = self.client.get(
reverse('admin:process_pending_bids', args=(self.event.short,))
)
self.assertEqual(response.status_code, 200)

def test_automail_prize_contributors(self):
self.client.force_login(self.superuser)
response = self.client.get(reverse('admin:automail_prize_contributors'))
Expand Down
39 changes: 1 addition & 38 deletions tracker/admin/bid.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import json

from django.contrib import messages
from django.contrib.admin import register
from django.contrib.auth.decorators import permission_required
Expand All @@ -12,10 +10,7 @@
from .filters import BidListFilter, BidParentFilter
from .forms import DonationBidForm, BidForm
from .inlines import BidOptionInline, BidDependentsInline
from .util import (
CustomModelAdmin,
api_urls,
)
from .util import CustomModelAdmin


@register(models.Bid)
Expand Down Expand Up @@ -207,45 +202,13 @@ def merge_bids_view(request, *args, **kwargs):
form = forms.MergeObjectsForm(model=models.Bid, objects=objects)
return render(request, 'admin/tracker/merge_bids.html', {'form': form})

@staticmethod
@permission_required('tracker.change_bid')
def process_pending_bids(request, event=None):
event = viewutil.get_event(event)

if not event.id:
return render(
request,
'tracker/eventlist.html',
{
'events': models.Event.objects.all(),
'pattern': 'admin:process_pending_bids',
'subheading': 'Process Pending Bids',
},
)

return render(
request,
'admin/tracker/process_pending_bids.html',
{'currentEvent': event, 'apiUrls': mark_safe(json.dumps(api_urls())),},
)

def get_urls(self):
return super(BidAdmin, self).get_urls() + [
path(
'merge_bids',
self.admin_site.admin_view(self.merge_bids_view),
name='merge_bids',
),
path(
'process_pending_bids',
self.admin_site.admin_view(self.process_pending_bids),
name='process_pending_bids',
),
path(
'process_pending_bids/<slug:event>',
self.admin_site.admin_view(self.process_pending_bids),
name='process_pending_bids',
),
]

def get_actions(self, request):
Expand Down
86 changes: 1 addition & 85 deletions tracker/admin/donation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import json
from datetime import datetime, timedelta

from django.conf import settings
Expand All @@ -7,9 +6,8 @@
from django.contrib.auth.decorators import permission_required
from django.http import HttpResponseRedirect
from django.shortcuts import render
from django.urls import reverse, path
from django.urls import reverse
from django.utils.html import format_html
from django.utils.safestring import mark_safe

from tracker import search_filters, forms, logutil, viewutil, models
from .filters import DonationListFilter
Expand All @@ -18,7 +16,6 @@
from .util import (
CustomModelAdmin,
mass_assign_action,
api_urls,
)


Expand Down Expand Up @@ -207,87 +204,6 @@ def get_queryset(self, request):
params['feed'] = 'all'
return search_filters.run_model_query('donation', params, user=request.user)

def get_urls(self):
return super(DonationAdmin, self).get_urls() + [
path(
'process_donations',
self.admin_site.admin_view(self.process_donations),
name='process_donations',
),
path(
'process_donations/<slug:event>',
self.admin_site.admin_view(self.process_donations),
name='process_donations',
),
path(
'read_donations',
self.admin_site.admin_view(self.read_donations),
name='read_donations',
),
path(
'read_donations/<slug:event>',
self.admin_site.admin_view(self.read_donations),
name='read_donations',
),
]

@staticmethod
@permission_required(('tracker.change_donation',))
def process_donations(request, event=None):
event = viewutil.get_event(event)

if not event.id:
return render(
request,
'tracker/eventlist.html',
{
'events': models.Event.objects.all(),
'pattern': 'admin:process_donations',
'subheading': 'Process Pending Bids',
},
)

user_can_approve = (
event and event.use_one_step_screening
) or request.user.has_perm('tracker.send_to_reader')
user_can_edit_donors = request.user.has_perm('tracker.change_donor')
return render(
request,
'admin/tracker/process_donations.html',
{
'user_can_approve': user_can_approve,
'user_can_edit_donors': user_can_edit_donors,
'currentEvent': event,
'apiUrls': mark_safe(json.dumps(api_urls())),
},
)

@staticmethod
@permission_required(('tracker.change_donation',))
def read_donations(request, event=None):
event = viewutil.get_event(event)

if not event.id:
return render(
request,
'tracker/eventlist.html',
{
'events': models.Event.objects.all(),
'pattern': 'admin:process_pending_bids',
'subheading': 'Process Pending Bids',
},
)
user_can_edit_donors = request.user.has_perm('tracker.change_donor')
return render(
request,
'admin/tracker/read_donations.html',
{
'user_can_edit_donors': user_can_edit_donors,
'currentEvent': event,
'apiUrls': mark_safe(json.dumps(api_urls())),
},
)

actions = [
set_readstate_ready,
set_readstate_ignored,
Expand Down
21 changes: 2 additions & 19 deletions tracker/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,6 @@ def __init__(self, event=None, *args, **kwargs):
min_value=minDonationAmount,
max_value=Decimal('100000'),
label='Donation Amount (min ${0})'.format(minDonationAmount),
widget=tracker.widgets.NumberInput(
attrs={
'id': 'iDonationAmount',
'min': str(minDonationAmount),
'step': '0.01',
}
),
required=True,
)
self.fields['comment'] = forms.CharField(widget=forms.Textarea, required=False)
Expand Down Expand Up @@ -134,24 +127,14 @@ def clean(self):


class DonationBidForm(forms.Form):
bid = forms.fields.IntegerField(
label='',
required=True,
widget=tracker.widgets.MegaFilterWidget(model='bidtarget'),
)
bid = forms.fields.IntegerField(label='', required=True,)
customoptionname = forms.fields.CharField(
max_length=models.Bid._meta.get_field('name').max_length,
label='New Option Name:',
required=False,
)
amount = forms.DecimalField(
decimal_places=2,
max_digits=20,
required=True,
validators=[positive, nonzero],
widget=tracker.widgets.NumberInput(
attrs={'class': 'cdonationbidamount', 'step': '0.01'}
),
decimal_places=2, max_digits=20, required=True, validators=[positive, nonzero],
)

def clean_bid(self):
Expand Down
Empty file removed tracker/static/ProcessingNode.js
Empty file.
Loading

0 comments on commit c9d25b8

Please sign in to comment.