-
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.
- Pagination moved to http Header - Merged Create/List group in one view - Changed Expense.member to Expense.user
- Loading branch information
Showing
8 changed files
with
197 additions
and
123 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
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,40 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import models, migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('MosesWebserviceApp', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Expense', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, verbose_name='ID', primary_key=True, serialize=False)), | ||
('amount', models.FloatField(null=True)), | ||
('relation', models.CharField(default='debtor', choices=[('debtor', 'debtor'), ('taker', 'taker')], max_length=10)), | ||
('status', models.CharField(default='not paid', choices=[('paid', 'Paid'), ('not paid', 'Not paid')], max_length=10)), | ||
('payed_date', models.DateTimeField(blank=True, null=True)), | ||
('bill', models.ForeignKey(to='MosesWebserviceApp.Bill', null=True, related_name='bill')), | ||
('member', models.ForeignKey(to='MosesWebserviceApp.User', related_name='member')), | ||
], | ||
options={ | ||
'ordering': ('member',), | ||
}, | ||
), | ||
migrations.RemoveField( | ||
model_name='userexpense', | ||
name='bill', | ||
), | ||
migrations.RemoveField( | ||
model_name='userexpense', | ||
name='member', | ||
), | ||
migrations.DeleteModel( | ||
name='UserExpense', | ||
), | ||
] |
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,33 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import models, migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('MosesWebserviceApp', '0002_auto_20150802_2048'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterModelOptions( | ||
name='expense', | ||
options={'ordering': ('user',)}, | ||
), | ||
migrations.RemoveField( | ||
model_name='expense', | ||
name='member', | ||
), | ||
migrations.AddField( | ||
model_name='expense', | ||
name='user', | ||
field=models.ForeignKey(to='MosesWebserviceApp.User', related_name='expense_user', default=-3), | ||
preserve_default=False, | ||
), | ||
migrations.AlterField( | ||
model_name='groupuser', | ||
name='user', | ||
field=models.ForeignKey(related_name='group_user', to='MosesWebserviceApp.User'), | ||
), | ||
] |
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,22 @@ | ||
from rest_framework import pagination | ||
from rest_framework.response import Response | ||
|
||
# Pagination | ||
class LinkHeaderPagination(pagination.PageNumberPagination): | ||
def get_paginated_response(self, data): | ||
next_url = self.get_next_link() | ||
previous_url = self.get_previous_link() | ||
|
||
if next_url is not None and previous_url is not None: | ||
link = '<{next_url}; rel="next">, <{previous_url}; rel="prev">' | ||
elif next_url is not None: | ||
link = '<{next_url}; rel="next">' | ||
elif previous_url is not None: | ||
link = '<{previous_url}; rel="prev">' | ||
else: | ||
link = '' | ||
|
||
link = link.format(next_url=next_url, previous_url=previous_url) | ||
headers = {'Link': link} if link else {} | ||
|
||
return Response(data, headers=headers) |
Oops, something went wrong.