예제 #1
0
 def insert(self, index, text, created):
     new_rid = self._get_new_rid()
     task = TaskResource(rid=new_rid,
                         description=text,
                         card_rid=self.crid,
                         created=created)
     self._st.insert_task(self.crid, index, task)
     return new_rid
예제 #2
0
def create_task(token, task):
    url = urls['tasks']
    data = task.to_json()
    response = requests.post(
        url, headers={'Authorization': 'Token {}'.format(token)}, json=data)
    sc = response.status_code
    assert sc == 201, 'Unable to create task, got {} status code instead of 201'.format(
        sc)
    return TaskResource.from_json(json.loads(response.content))
예제 #3
0
 def add(self, text, created):
     # Should I set position of the task here ? Seems unnecessary though.
     new_rid = self._get_new_rid()
     task = TaskResource(rid=new_rid,
                         description=text,
                         card_rid=self.crid,
                         created=created)
     self._st.add_task(self.crid, task)
     return new_rid
예제 #4
0
def get_tasks(token):
    url = urls['tasks']
    response = requests.get(
        url, headers={'Authorization': 'Token {}'.format(token)})
    sc = response.status_code
    assert sc == 200, 'Unable to get tasks, got {} status code instead of 200'.format(
        sc)
    tasks_resource = json.loads(response.content)
    return [TaskResource.from_json(resource) for resource in tasks_resource]
예제 #5
0
 def load_from_file(self, f):
     data = json.load(f)
     self.cards = [CardResource.from_json(res) for res in data['cards']]
     self._tasks = {card.rid: [] for card in self.cards}
     for task_data in data['tasks']:
         task_res = TaskResource.from_json(task_data)
         self._tasks[task_res.card_rid].append(task_res)
         self.task_rids.add(task_res.rid)
     self.preferences = {}
     for resource in data['preferences']:
         pref = PreferenceResource.from_json(resource)
         self.preferences[pref.card_rid] = pref
         self.preference_rids.add(pref.rid)
     self.token = data['token']
예제 #6
0
파일: urls.py 프로젝트: retmas-dv/deftcore
__author__ = 'Dmitry Golubkov'

from django.conf.urls import include, url
from tastypie.api import Api
from api import views
from api.resources import InstanceResource, RequestResource, TaskResource, TRequestResource, TStepResource
from django.contrib import admin
from django.http import HttpResponseRedirect
from django.urls import reverse

admin.autodiscover()

default_api = Api(api_name='v1')
default_api.register(InstanceResource())
default_api.register(RequestResource())
default_api.register(TaskResource())
default_api.register(TRequestResource())
default_api.register(TStepResource())

urlpatterns = [
    url(
        r'^$', lambda r: HttpResponseRedirect(
            reverse('api_dispatch_list',
                    kwargs={
                        'resource_name': 'instance',
                        'api_name': 'v1'
                    }))),
    url(r'^test/', views.test_view),
    url(r'^admin/', admin.site.urls),
    url(r'^api/', include(default_api.urls)),
]
예제 #7
0
파일: urls.py 프로젝트: Ceasar/VeraCal
from django.conf.urls.defaults import *

from tastypie.api import Api

from api.resources import TaskResource, CalendarResource, UserResource
v1_api = Api(api_name='v1')
v1_api.register(CalendarResource())
v1_api.register(TaskResource())
v1_api.register(UserResource())
urlpatterns = patterns(
    '',
    (r'^calendar$', 'apps.calendar.views.calendar'),
    (r'^api/', include(v1_api.urls)),
)
예제 #8
0
파일: urls.py 프로젝트: embs/retodjango
"""slate URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/1.11/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.conf.urls import url, include
    2. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url, include
from django.contrib import admin

from api.resources import TaskResource

task_resource = TaskResource()

urlpatterns = [
    url(r'^', include(task_resource.urls)),
]