updated apps in dev.py.tmpl and deleted unused code
authordurandn
Tue, 16 Aug 2016 11:01:35 +0200
changeset 126 b5aa7e6f6a01
parent 123 c8a1216fd28f
child 127 270d165cd0d5
updated apps in dev.py.tmpl and deleted unused code
src/iconolab/models.py
src/iconolab/settings/__init__.py
src/iconolab/settings/dev.py.tmpl
src/iconolab/urls.py
src/restapi/__init__.py
src/restapi/apps.py
src/restapi/models.py
src/restapi/serializers.py
src/restapi/tests.py
src/restapi/urls.py
src/restapi/views.py
--- a/src/iconolab/models.py	Fri Aug 12 16:59:53 2016 +0200
+++ b/src/iconolab/models.py	Tue Aug 16 11:01:35 2016 +0200
@@ -30,7 +30,7 @@
 class Collection(models.Model):
     name = models.SlugField(max_length=50, unique=True)
     verbose_name = models.CharField(max_length=50, null=True, blank=True)
-    description = models.CharField(max_length=255)
+    description = models.TextField(null=True)
     image = models.ImageField(upload_to='uploads/', height_field='height', width_field='width', null=True, blank=True)
     height = models.IntegerField(null=True, blank=True)
     width = models.IntegerField(null=True, blank=True)
--- a/src/iconolab/settings/__init__.py	Fri Aug 12 16:59:53 2016 +0200
+++ b/src/iconolab/settings/__init__.py	Tue Aug 16 11:01:35 2016 +0200
@@ -46,7 +46,6 @@
 # Application definition
 
 INSTALLED_APPS = [
-    'restapi',
     'django.contrib.admin',
     'django.contrib.auth',
     'django.contrib.contenttypes',
--- a/src/iconolab/settings/dev.py.tmpl	Fri Aug 12 16:59:53 2016 +0200
+++ b/src/iconolab/settings/dev.py.tmpl	Tue Aug 16 11:01:35 2016 +0200
@@ -42,7 +42,6 @@
 # Application definition
 
 INSTALLED_APPS = [
-    'restapi',
     'django.contrib.admin',
     'django.contrib.auth',
     'django.contrib.contenttypes',
@@ -52,9 +51,7 @@
     'django.contrib.sites',
     'django_comments',
     'django_comments_xtd',
-    'notifications',
-    'reversion',
-    'reversion_compare',
+    'haystack',
     'iconolab.apps.IconolabApp',
     'sorl.thumbnail',
     'notifications'
--- a/src/iconolab/urls.py	Fri Aug 12 16:59:53 2016 +0200
+++ b/src/iconolab/urls.py	Tue Aug 16 11:01:35 2016 +0200
@@ -45,7 +45,6 @@
     url(r'^user/(?P<slug>[a-z0-9\-]+)/home/?$', views.iconolab.UserHomeView.as_view(), name="user_home"),
     url(r'^user/notifications/all/?$', login_required(views.iconolab.UserNotificationsView.as_view()), name="user_notifications"),
     url(r'^errors/404', views.iconolab.NotFoundErrorView.as_view(), name="404error"),
-    url(r'^rest', include('restapi.urls')),
     url(r'^account/', include('iconolab.auth.urls', namespace='account')),
     url(r'^comments/', include('django_comments_xtd.urls')),
     url(r'^comments/annotation/post', views.comments.post_comment_iconolab, name="post_comment"),
--- a/src/restapi/apps.py	Fri Aug 12 16:59:53 2016 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-from django.apps import AppConfig
-
-
-class RestapiConfig(AppConfig):
-    name = 'restapi'
--- a/src/restapi/models.py	Fri Aug 12 16:59:53 2016 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-from django.db import models
--- a/src/restapi/serializers.py	Fri Aug 12 16:59:53 2016 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-from rest_framework import serializers
-from iconolab.models import Annotation
-
-
-class AnnotationSerializer(serializers.ModelSerializer):
-	tags = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='get')
-	class Meta:
-		model = Annotation
-		fields = ('id', 'title', 'description', 'fragment', 'tags')
-		
-	def create(self, validated_data):
-		"""
-		Create a new Annotation
-		"""
-		return Annotation.create(**validated_data)
-
-	def update(self, instance, validated_data):
-		instance.title = validated_data.get('title', instance.title)
-		instance.description = validated_data.get('description', instance.description)
-		instance.fragment = validated_data.get('fragment', instance.fragment)
-		instance.save()
-		return instance
\ No newline at end of file
--- a/src/restapi/tests.py	Fri Aug 12 16:59:53 2016 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-from django.test import TestCase
-
-# Create your tests here.
--- a/src/restapi/urls.py	Fri Aug 12 16:59:53 2016 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-from django.conf.urls import url
-from . import views
-
-urlpatterns = [
-	url(r'^$', views.index, name='index'),
-	url(r'annotation$', views.annotation_list),
-	url(r'annotation/(?P<pk>[0-9]+)/$', views.get)
-]
\ No newline at end of file
--- a/src/restapi/views.py	Fri Aug 12 16:59:53 2016 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-from django.shortcuts import render, HttpResponse
-from pprint import pprint
-
-from django.views.decorators.csrf import csrf_exempt
-from rest_framework.renderers import JSONRenderer
-from rest_framework.parsers import JSONParser
-from iconolab.models import Annotation
-from .serializers import AnnotationSerializer
-
-class JSONResponse(HttpResponse):
-	def __init__(self, data, **kwargs):
-		content = JSONRenderer().render(data)
-		kwargs['content_type'] = 'application/json'
-		super(JSONResponse, self).__init__(content)
-
-
-# Create your views here.
-
-def index(r):
-	return HttpResponse('<p>You better know ... </p>')
-
-@csrf_exempt
-def annotation_list(request):
-	
-	if request.method == 'GET':
-		annotations = Annotation.objects.all()
-		serializer = AnnotationSerializer(annotations, many=True)
-		return JSONResponse(serializer.data)
-
-
-
-def get(request, pk):
-	if request.method == 'GET':
-		
-		try:
-			annotation = Annotation.objects.get(pk=pk)
-		except Annotation.DoesNotExist:
-			return HttpResponse(status=404)
-
-		serializer = AnnotationSerializer(annotation) 
-		return JSONResponse(serializer.data)