Skip to content

Commit ca4210d

Browse files
Added private API to get all rooms for connected apps
1 parent b1e4581 commit ca4210d

File tree

15 files changed

+115
-3
lines changed

15 files changed

+115
-3
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
3+
4+
from django.db import migrations, models
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('application', '0006_historicalapplication'),
11+
]
12+
13+
operations = [
14+
migrations.AddField(
15+
model_name='application',
16+
name='private_scopes',
17+
field=models.CharField(help_text=b'Private API scopes', max_length=256, null=True, blank=True),
18+
),
19+
migrations.AddField(
20+
model_name='historicalapplication',
21+
name='private_scopes',
22+
field=models.CharField(help_text=b'Private API scopes', max_length=256, null=True, blank=True),
23+
),
24+
]

application/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class Application(AbstractApplication):
3737
required_scopes = models.CharField(max_length=256,
3838
help_text='Default non-tracking permissions. '
3939
'Valid only if application is anonymous', null=True, blank=True)
40+
private_scopes = models.CharField(max_length=256, help_text='Private API scopes', null=True, blank=True)
4041
website = models.URLField(null=True, blank=True)
4142
privacy_policy = models.URLField(null=True, blank=True, help_text='Link of privacy policy of application')
4243
created_on = models.DateTimeField(auto_now_add=True)

application/views.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ def form_valid(self, form):
3636
scopes = form.cleaned_data.get('scope', '')
3737
scopes = set(scopes.split(' '))
3838
scopes.update(set(get_default_scopes(application)))
39+
private_scopes = application.private_scopes
40+
private_scopes = set(private_scopes.split(' '))
41+
scopes.update(private_scopes)
3942
scopes = ' '.join(list(scopes))
4043
form.cleaned_data['scope'] = scopes
4144
return super(CustomAuthorizationView, self).form_valid(form)

core/pagination.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from rest_framework import pagination
2+
3+
4+
class DefaultLimitOffsetPagination(pagination.LimitOffsetPagination):
5+
6+
default_limit = 20
7+
max_limit = 500

resources/__init__.py

Whitespace-only changes.

resources/admin.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.contrib import admin
2+
3+
# Register your models here.

resources/migrations/__init__.py

Whitespace-only changes.

resources/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.db import models
2+
3+
# Create your models here.

resources/serializers.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from rest_framework import serializers
2+
3+
from user_resource.models import InstituteAddress
4+
5+
6+
class UserRoomSerializer(serializers.ModelSerializer):
7+
roll_number = serializers.CharField(source='user.userprofile.roll_number')
8+
9+
class Meta:
10+
model = InstituteAddress
11+
exclude = ['id', 'user']

resources/tests.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.test import TestCase
2+
3+
# Create your tests here.

0 commit comments

Comments
 (0)