diff --git a/passbook/__init__.py b/passbook/__init__.py index 983cf4de7..fa6a13305 100644 --- a/passbook/__init__.py +++ b/passbook/__init__.py @@ -1 +1 @@ -__version__ = '0.0.1-alpha' \ No newline at end of file +__version__ = '0.0.1-alpha' diff --git a/passbook/admin/api/__init__.py b/passbook/admin/api/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/passbook/admin/api/v1/__init__.py b/passbook/admin/api/v1/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/passbook/admin/api/v1/routers.py b/passbook/admin/api/v1/routers.py new file mode 100644 index 000000000..328c9cb2a --- /dev/null +++ b/passbook/admin/api/v1/routers.py @@ -0,0 +1,8 @@ +# from django.conf.urls import url, include + +# # Add this! +# from passbook.admin.api.v1.source import SourceResource + +# urlpatterns = [ +# url(r'source/', include(SourceResource.urls())), +# ] diff --git a/passbook/admin/api/v1/source.py b/passbook/admin/api/v1/source.py new file mode 100644 index 000000000..cd34721a2 --- /dev/null +++ b/passbook/admin/api/v1/source.py @@ -0,0 +1,26 @@ +# from rest_framework.serializers import HyperlinkedModelSerializer +# from passbook.admin.api.v1.utils import LookupSerializer +# from passbook.core.models import Source +# from passbook.oauth_client.models import OAuthSource + +# from rest_framework.viewsets import ModelViewSet + +# class LookupSourceSerializer(HyperlinkedModelSerializer): + +# def to_representation(self, instance): +# if isinstance(instance, Source): +# return SourceSerializer(instance=instance).data +# elif isinstance(instance, OAuthSource): +# return OAuthSourceSerializer(instance=instance).data +# else: +# return LookupSourceSerializer(instance=instance).data + +# class Meta: +# model = Source +# fields = '__all__' + + +# class SourceViewSet(ModelViewSet): + +# serializer_class = LookupSourceSerializer +# queryset = Source.objects.select_subclasses() diff --git a/passbook/admin/api/v1/utils.py b/passbook/admin/api/v1/utils.py new file mode 100644 index 000000000..31133e466 --- /dev/null +++ b/passbook/admin/api/v1/utils.py @@ -0,0 +1,17 @@ +from django.db.models import Model +from rest_framework.serializers import ModelSerializer + + +class LookupSerializer(ModelSerializer): + + mapping = {} + + def to_representation(self, instance): + for __model, __serializer in self.mapping.items(): + if isinstance(instance, __model): + return __serializer(instance=instance).to_representation(instance) + raise KeyError(instance.__class__.__name__) + + class Meta: + model = Model + fields = '__all__' diff --git a/passbook/admin/mixins.py b/passbook/admin/mixins.py new file mode 100644 index 000000000..186d81ae0 --- /dev/null +++ b/passbook/admin/mixins.py @@ -0,0 +1,9 @@ + +from django.contrib.auth.mixins import UserPassesTestMixin + + +class AdminRequiredMixin(UserPassesTestMixin): + """Make sure user is administrator""" + + def test_func(self): + return self.request.user.is_superuser diff --git a/passbook/admin/requirements.txt b/passbook/admin/requirements.txt new file mode 100644 index 000000000..44f4d7ce3 --- /dev/null +++ b/passbook/admin/requirements.txt @@ -0,0 +1 @@ +django-crispy-forms \ No newline at end of file diff --git a/passbook/admin/templates/administration/application/list.html b/passbook/admin/templates/administration/application/list.html new file mode 100644 index 000000000..7bd108b2d --- /dev/null +++ b/passbook/admin/templates/administration/application/list.html @@ -0,0 +1,647 @@ +{% extends "administration/base.html" %} + +{% block content %} + +
+
+
+
+ +
+
+ + +
+ +
+
+
+ + + + +
+
+
+ +
+ +
+ 1 of 3 + + + +
+
+
+
+
+
+
+ +
+
+ 0 of 0 selected +
+
+
+
+ + + + + + + + + + + + + + +
Rendering EngineBrowserPlatform(s)Engine VersionCSS GradeActions
+ +
+
+ + per page +
+
+ 1-15 of 75 + + + + of 5 + +
+
+ + + +{% endblock %} + +{% block scripts %} + + + +{% endblock %} \ No newline at end of file diff --git a/passbook/admin/templates/administration/base.html b/passbook/admin/templates/administration/base.html index 14265e20e..3044f244f 100644 --- a/passbook/admin/templates/administration/base.html +++ b/passbook/admin/templates/administration/base.html @@ -5,11 +5,14 @@ {% block nav_secondary %} -