From 44c1d2c7144b17375765890463a99c5d47928e09 Mon Sep 17 00:00:00 2001 From: Sebastian Lohff Date: Sat, 21 Jan 2012 15:31:31 +0100 Subject: [PATCH] OLD API: Removed deprecated api --- k4ever/api/__init__.py | 0 k4ever/api/models.py | 3 -- k4ever/api/tests.py | 23 -------------- k4ever/api/urls.py | 9 ------ k4ever/api/views.py | 68 ------------------------------------------ k4ever/urls.py | 1 - 6 files changed, 104 deletions(-) delete mode 100644 k4ever/api/__init__.py delete mode 100644 k4ever/api/models.py delete mode 100644 k4ever/api/tests.py delete mode 100644 k4ever/api/urls.py delete mode 100644 k4ever/api/views.py diff --git a/k4ever/api/__init__.py b/k4ever/api/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/k4ever/api/models.py b/k4ever/api/models.py deleted file mode 100644 index 71a8362..0000000 --- a/k4ever/api/models.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.db import models - -# Create your models here. diff --git a/k4ever/api/tests.py b/k4ever/api/tests.py deleted file mode 100644 index 2247054..0000000 --- a/k4ever/api/tests.py +++ /dev/null @@ -1,23 +0,0 @@ -""" -This file demonstrates two different styles of tests (one doctest and one -unittest). These will both pass when you run "manage.py test". - -Replace these with more appropriate tests for your application. -""" - -from django.test import TestCase - -class SimpleTest(TestCase): - def test_basic_addition(self): - """ - Tests that 1 + 1 always equals 2. - """ - self.failUnlessEqual(1 + 1, 2) - -__test__ = {"doctest": """ -Another way to test that 1 + 1 is equal to 2. - ->>> 1 + 1 == 2 -True -"""} - diff --git a/k4ever/api/urls.py b/k4ever/api/urls.py deleted file mode 100644 index 5434be8..0000000 --- a/k4ever/api/urls.py +++ /dev/null @@ -1,9 +0,0 @@ -from django.conf.urls.defaults import * - -#/api/ -urlpatterns = patterns('', - (r'^store/$', 'api.views.showItems'), - (r'^store/show/(\d+)/$', 'api.views.showItem'), - (r'^store/buy/(\d+)/(|with/deposit|only/deposit)/?$', 'api.views.buyItem'), - (r'^store/history/?$', 'api.views.history'), -) diff --git a/k4ever/api/views.py b/k4ever/api/views.py deleted file mode 100644 index 5ff32e9..0000000 --- a/k4ever/api/views.py +++ /dev/null @@ -1,68 +0,0 @@ -# -*- coding: utf-8 -*- -from django.contrib.auth.decorators import login_required -from django.http import HttpResponse - -import datetime -from buyable.models import Buyable, Purchase, Order -from django.core import serializers - - -@login_required -def showItems(request): - # FIXME: Implement pagination here - items = Buyable.objects.all() - - #return json-container - container = serializers.serialize('json', items) - return HttpResponse(container,'application/json') - -@login_required -def showItem(request, itemid): - try: - item = Buyable.objects.get(id=itemid) - except Buyable.DoesNotExist: - # baww, kein item mit der id :( (oder mutax trollt rum) - return HttpResponse(status=400) - - #return json-container - container = serializers.serialize('json', [item]) - return HttpResponse(container,'application/json') - - -@login_required -def buyItem(request, itemid, buymode=""): - user = request.user - try: - item = Buyable.objects.get(id=itemid) - except Buyable.DoesNotExist: - # oh no! kein item mit der id :( mutax trollt rum) - return HttpResponseRedirect("/store/buy/") - """ tristate variable buymode: - "" only item - "with/deposit" item and deposit - "only/deposit" only deposit - """ - order = Order(user=request.user) - order.save() # for the id! - if buymode == "" or buymode == "with/deposit": - p = Purchase(order=order, buyable=item, isDeposit=False) - p.save(saveOrder=False) - # TANNEK! if buymode == "with/dopsit" or buymode == "only/deposit": - if buymode == "with/deposit" or buymode == "only/deposit": - p = Purchase(order=order, buyable=item, isDeposit=True) - p.save(saveOrder=False) - order.save() - - #return json-container - #container = serializers.serialize('json', items) - #return HttpResponse(container,'application/json') - return HttpResponse(status=200) - #return HttpResponseRedirect("/store/bought/%s/" % (order.id)) - -@login_required -def history(request): - hist = Order.objects.filter(user=request.user.id).order_by("-dateTime") - #return json-container - container = serializers.serialize('json', [hist]) - return HttpResponse(container,'application/json') - diff --git a/k4ever/urls.py b/k4ever/urls.py index 9d27fdf..bd0e7e7 100644 --- a/k4ever/urls.py +++ b/k4ever/urls.py @@ -18,7 +18,6 @@ urlpatterns = patterns('', # (r'^admin/doc/', include('django.contrib.admindocs.urls')), # user stuff? go to main (r'^$', 'main.views.startpage'), - (r'^api/', include('api.urls')), (r'^api2/', include('api2.urls')), (r'^user/', include('main.urls')), (r'^transaction/', include('transaction.urls')),