diff --git a/frontend/forms.py b/frontend/forms.py index 3019e965..4279182e 100644 --- a/frontend/forms.py +++ b/frontend/forms.py @@ -189,3 +189,6 @@ class GoodreadsShelfLoadingForm(forms.Form): class LibraryThingForm(forms.Form): lt_username = forms.CharField(max_length=30, required=True) + +class CampaignAdminForm(forms.Form): + pass diff --git a/frontend/templates/campaign_admin.html b/frontend/templates/campaign_admin.html new file mode 100644 index 00000000..2659ee8b --- /dev/null +++ b/frontend/templates/campaign_admin.html @@ -0,0 +1,31 @@ +{% extends "basedocumentation.html" %} +{% block base_js %}{% endblock %} +{% block extra_extra_head %} + +{{ form.media.css }} + + +{{ form.media.js }} +{% endblock %} + +{% block doccontent %} + +

Campaign Admin

+ +
+ {% csrf_token %} + {{ form.as_p }} + +
+ +{% if check_status_results %} +

Campaign checkstatus output:

+ + +{% endif %} + +{% endblock %} \ No newline at end of file diff --git a/frontend/urls.py b/frontend/urls.py index 2b9ae90b..b95f8771 100644 --- a/frontend/urls.py +++ b/frontend/urls.py @@ -21,7 +21,8 @@ urlpatterns = patterns( url(r"^rightsholders/$", "rh_tools", name="rightsholders"), url(r"^rightsholders/campaign/(?P\d+)/$", "manage_campaign", name="manage_campaign"), url(r"^rightsholders/claim/$", "claim", name="claim"), - url(r"^rh_admin/$", "rh_admin", name="rh_admin"), + url(r"^rh_admin/$", "rh_admin", name="rh_admin"), + url(r"^campaign_admin/$", "campaign_admin", name="campaign_admin"), url(r"^faq/$", TemplateView.as_view(template_name="faq.html"), name="faq"), url(r"^wishlist/$", "wishlist", name="wishlist"), diff --git a/frontend/views.py b/frontend/views.py index 73127471..02a45f3b 100755 --- a/frontend/views.py +++ b/frontend/views.py @@ -36,7 +36,7 @@ from regluit.core.search import gluejar_search from regluit.core.goodreads import GoodreadsClient from regluit.frontend.forms import UserData, ProfileForm, CampaignPledgeForm, GoodreadsShelfLoadingForm from regluit.frontend.forms import RightsHolderForm, UserClaimForm, LibraryThingForm, OpenCampaignForm -from regluit.frontend.forms import ManageCampaignForm, DonateForm +from regluit.frontend.forms import ManageCampaignForm, DonateForm, CampaignAdminForm from regluit.payment.manager import PaymentManager from regluit.payment.parameters import TARGET_TYPE_CAMPAIGN, TARGET_TYPE_DONATION from regluit.core import goodreads @@ -413,6 +413,34 @@ def rh_admin(request): } return render(request, "rights_holders.html", context) +def campaign_admin(request): + if not request.user.is_authenticated() : + return render(request, "admins_only.html") + if not request.user.is_staff : + return render(request, "admins_only.html") + + context = {} + + # first task: run PaymentManager.checkStatus() to update Campaign statuses + # does it return data to display? + + form = CampaignAdminForm() + + if request.method == 'GET': + check_status_results = None + elif request.method == 'POST': + try: + pm = PaymentManager() + check_status_results = pm.checkStatus() + except Exception, e: + check_status_results = e + + context.update({ + 'form': form, + 'check_status_results':check_status_results + }) + + return render(request, "campaign_admin.html", context) def supporter(request, supporter_username, template_name): supporter = get_object_or_404(User, username=supporter_username)