Permalink
Browse files

Reorganizing code to work in the new adapter

  • Loading branch information...
1 parent e5480c4 commit 1fe4d50fff584e5ff365e64708df95ef249ae093 @escalant3 committed Oct 19, 2012
@@ -12,7 +12,7 @@
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
- 'NAME': 'visits.sqlite', # Or path to database file if using sqlite3.
+ 'NAME': 'tasks.sqlite', # Or path to database file if using sqlite3.
'USER': '', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
@@ -117,7 +117,7 @@
'django.contrib.staticfiles',
'django.contrib.admin',
'tastypie',
- 'visits',
+ 'tasks',
)
# A sample logging configuration. The only tangible logging
File renamed without changes.
@@ -0,0 +1,6 @@
+from django.contrib import admin
+
+from tasks.models import Person, Task
+
+admin.site.register(Person)
+admin.site.register(Task)
@@ -2,16 +2,19 @@
from tastypie.authorization import Authorization
from tastypie.resources import ModelResource
-from visits.models import Customer, VisitLog
+from tasks.models import Person, Task
-class CustomerResource(ModelResource):
+class PersonResource(ModelResource):
- visit_logs = fields.ToManyField('visits.api.VisitLogResource', 'visitlog_set')
+ #tags = fields.ToManyField('tasks.api.TagResource', 'tag_set')
class Meta:
- queryset = Customer.objects.all()
- resource_name = 'customer'
+ queryset = Person.objects.all()
+ resource_name = 'person'
+ filtering = {
+ 'name': ['exact']
+ }
# Authorization is needed for write methods
authorization = Authorization()
@@ -23,13 +26,13 @@ class Meta:
always_return_data = True
-class VisitLogResource(ModelResource):
+class TaskResource(ModelResource):
- customer_id = fields.ToOneField(CustomerResource, 'customer')
+ person_id = fields.ToOneField(PersonResource, 'person', null=True)
class Meta:
- queryset = VisitLog.objects.all()
- resource_name = 'visit_log'
+ queryset = Task.objects.all()
+ resource_name = 'task'
# Authorization is needed for write methods
authorization = Authorization()
@@ -0,0 +1,16 @@
+from django.db import models
+
+
+class Person(models.Model):
+ name = models.CharField(max_length=30)
+
+ def __unicode__(self):
+ return self.name
+
+
+class Task(models.Model):
+ name = models.CharField(max_length=30)
+ person = models.ForeignKey(Person, null=True)
+
+ def __unicode__(self):
+ return "%s - %s" % (self.name)
Oops, something went wrong. Retry.

0 comments on commit 1fe4d50

Please sign in to comment.