Commit ca20590a authored by Romain Loth's avatar Romain Loth

[FIX] correction import oublié dans annotations.views.NgramCreate

parent 90bbffd7
...@@ -2,9 +2,15 @@ from django.conf.urls import patterns, url ...@@ -2,9 +2,15 @@ from django.conf.urls import patterns, url
from annotations import views from annotations import views
# /!\ urls patterns here are *without* the trailing slash
urlpatterns = patterns('', urlpatterns = patterns('',
# json:title,id,authors,journal,
# publication_date
# abstract_text,full_text
url(r'^document/(?P<doc_id>[0-9]+)$', views.Document.as_view()), # document view url(r'^document/(?P<doc_id>[0-9]+)$', views.Document.as_view()), # document view
url(r'^corpus/(?P<corpus_id>[0-9]+)/document/(?P<doc_id>[0-9]+)$', views.NgramList.as_view()), # the list associated with an ngram url(r'^corpus/(?P<corpus_id>[0-9]+)/document/(?P<doc_id>[0-9]+)$', views.NgramList.as_view()), # the list associated with an ngram
url(r'^lists/(?P<list_id>[0-9]+)/ngrams/(?P<ngram_ids>[0-9,\+]+)+$', views.NgramEdit.as_view()), url(r'^lists/(?P<list_id>[0-9]+)/ngrams/(?P<ngram_ids>[0-9,\+]+)+$', views.NgramEdit.as_view()),
# POST (fixed 2015-12-16)
url(r'^lists/(?P<list_id>[0-9]+)/ngrams/create$', views.NgramCreate.as_view()), # url(r'^lists/(?P<list_id>[0-9]+)/ngrams/create$', views.NgramCreate.as_view()), #
) )
...@@ -13,7 +13,7 @@ from rest_framework.exceptions import APIException ...@@ -13,7 +13,7 @@ from rest_framework.exceptions import APIException
from rest_framework.authentication import SessionAuthentication, BasicAuthentication from rest_framework.authentication import SessionAuthentication, BasicAuthentication
from node.models import Node from node.models import Node
from gargantext_web.db import session, cache, Node, NodeNgram from gargantext_web.db import session, cache, Node, NodeNgram, Ngram
from ngram.lists import listIds, listNgramIds from ngram.lists import listIds, listNgramIds
from gargantext_web.db import get_or_create_node from gargantext_web.db import get_or_create_node
...@@ -138,6 +138,8 @@ class NgramCreate(APIView): ...@@ -138,6 +138,8 @@ class NgramCreate(APIView):
def post(self, request, list_id): def post(self, request, list_id):
""" """
create NGram in a given list create NGram in a given list
example: request.data = {'text': 'phylogeny'}
""" """
list_id = int(list_id) list_id = int(list_id)
# format the ngram's text # format the ngram's text
...@@ -161,6 +163,7 @@ class NgramCreate(APIView): ...@@ -161,6 +163,7 @@ class NgramCreate(APIView):
ngram_id = ngram.id ngram_id = ngram.id
# create the new node_ngram relation # create the new node_ngram relation
# TODO check existing Node_Ngram ? # TODO check existing Node_Ngram ?
# £TODO ici indexation
node_ngram = NodeNgram(node_id=list_id, ngram_id=ngram_id, weight=1.0) node_ngram = NodeNgram(node_id=list_id, ngram_id=ngram_id, weight=1.0)
session.add(node_ngram) session.add(node_ngram)
session.commit() session.commit()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment