mirror of
https://github.com/pinry/pinry.git
synced 2026-03-02 10:11:19 +01:00
Make PinResource orderable by id
Update JavaScript so it orders pins, Fixes #69
This commit is contained in:
@@ -80,8 +80,8 @@ class PinResource(ModelResource):
|
||||
|
||||
class Meta:
|
||||
fields = ['id', 'url', 'description']
|
||||
ordering = ['id']
|
||||
queryset = Pin.objects.all()
|
||||
resource_name = 'pin'
|
||||
include_resource_uri = False
|
||||
authorization = DjangoAuthorization()
|
||||
ordering = '-published'
|
||||
|
||||
@@ -85,6 +85,12 @@ class PinResourceTest(ResourceTestCase):
|
||||
self.assertEqual(Pin.objects.count(), 3)
|
||||
self.assertEquals(Tag.objects.count(), 4)
|
||||
|
||||
def test_get_list_json_ordered(self):
|
||||
pin = Pin.objects.latest('id')
|
||||
response = self.api_client.get('/api/v1/pin/', format='json', data={'order_by': '-id'})
|
||||
self.assertValidJSONResponse(response)
|
||||
self.assertEqual(self.deserialize(response)['objects'][0]['id'], pin.id)
|
||||
|
||||
def test_get_list_json(self):
|
||||
user = User.objects.get(pk=1)
|
||||
image = Image.objects.get(pk=1)
|
||||
|
||||
@@ -67,7 +67,7 @@ $(window).load(function() {
|
||||
$('.spinner').css('display', 'block');
|
||||
|
||||
// Fetch our pins from the api using our current offset
|
||||
var apiUrl = '/api/v1/pin/?format=json&ordering=-id&offset='+String(offset);
|
||||
var apiUrl = '/api/v1/pin/?format=json&order_by=-id&offset='+String(offset);
|
||||
if (tagFilter) apiUrl = apiUrl + '&tag=' + tagFilter;
|
||||
$.get(apiUrl, function(pins) {
|
||||
// Set which items are editable by the current user
|
||||
|
||||
Reference in New Issue
Block a user