# HG changeset patch # User durandn # Date 1471338095 -7200 # Node ID b5aa7e6f6a018c94d60e9e1fc69798e67d030d20 # Parent c8a1216fd28f4fbe151ae247e312caba70fd1cce updated apps in dev.py.tmpl and deleted unused code diff -r c8a1216fd28f -r b5aa7e6f6a01 src/iconolab/models.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) diff -r c8a1216fd28f -r b5aa7e6f6a01 src/iconolab/settings/__init__.py --- 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', diff -r c8a1216fd28f -r b5aa7e6f6a01 src/iconolab/settings/dev.py.tmpl --- 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' diff -r c8a1216fd28f -r b5aa7e6f6a01 src/iconolab/urls.py --- 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[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"), diff -r c8a1216fd28f -r b5aa7e6f6a01 src/restapi/__init__.py diff -r c8a1216fd28f -r b5aa7e6f6a01 src/restapi/apps.py --- 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' diff -r c8a1216fd28f -r b5aa7e6f6a01 src/restapi/models.py --- 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 diff -r c8a1216fd28f -r b5aa7e6f6a01 src/restapi/serializers.py --- 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 diff -r c8a1216fd28f -r b5aa7e6f6a01 src/restapi/tests.py --- 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. diff -r c8a1216fd28f -r b5aa7e6f6a01 src/restapi/urls.py --- 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[0-9]+)/$', views.get) -] \ No newline at end of file diff -r c8a1216fd28f -r b5aa7e6f6a01 src/restapi/views.py --- 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('

You better know ...

') - -@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)