forked from MsuLab/TextumBB
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finally built REST architecture. Changed a few names in models so tha…
…t models on server and client had same set of fields. RIGHT NOW IMAGES ARE DELETED BY CLICKING ON THEM. IT SHOULD BE CHANGED.
- Loading branch information
1 parent
10f7742
commit 987f191
Showing
14 changed files
with
113 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.DS_Store | ||
*~ | ||
|
||
bower_components | ||
*.db | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,7 @@ | |
|
||
Django==1.5.1 | ||
beautifulsoup4==4.3.2 | ||
pillow | ||
pillow | ||
python-mimeparse | ||
python-dateutil | ||
django-tastypie |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# myapp/api.py | ||
from tastypie.resources import ModelResource | ||
from tastypie.authorization import Authorization | ||
from tastypie import fields | ||
|
||
from textum.textedit.models import TImage | ||
|
||
|
||
# https://stackoverflow.com/questions/15263964/django-tasypie-image-upload-example-with-jquery | ||
|
||
|
||
class MultipartResource(object): | ||
def deserialize(self, request, data, format=None): | ||
if not format: | ||
format = request.META.get('CONTENT_TYPE', 'application/json') | ||
if format == 'application/x-www-form-urlencoded': | ||
return request.POST | ||
if format.startswith('multipart'): | ||
data = request.POST.copy() | ||
data.update(request.FILES) | ||
return data | ||
return super(MultipartResource, self).deserialize(request, data, format) | ||
|
||
|
||
class TImageResource(MultipartResource, ModelResource): | ||
|
||
file = fields.FileField(attribute="file", null=True, blank=True) | ||
class Meta: | ||
always_return_data=True | ||
queryset = TImage.objects.all() | ||
authorization = Authorization() | ||
|
||
def obj_create(self, bundle, **kwargs): | ||
print "create" | ||
bundle.data["page_num"] = 0 | ||
return super(TImageResource, self).obj_create(bundle, **kwargs) | ||
|
||
def alter_list_data_to_serialize(self, request, data): | ||
return data["objects"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters