git_resource.py 945 B

123456789101112131415161718192021222324252627282930
  1. # -*- coding: utf-8 -*-
  2. from __future__ import unicode_literals
  3. from django.conf.urls import url
  4. from django.conf import settings
  5. from tastypie.resources import Resource
  6. from tastypie.utils import trailing_slash
  7. from api.utils.jwt_authentication import JWTAuthentication
  8. from api.utils.git_api import get_odoo_modules_repos_names
  9. class GitResource(Resource):
  10. class Meta:
  11. resource_name = 'git'
  12. authentication = JWTAuthentication()
  13. '''
  14. '''
  15. def prepend_urls(self):
  16. return [
  17. url(r'^%s/repositories%s$' % (self._meta.resource_name, trailing_slash), self.wrap_view('get_repositories'), name="get_repositories"),
  18. ]
  19. '''
  20. '''
  21. def get_repositories(self, request, **kwargs):
  22. self.method_check(request, allowed='get')
  23. self.is_authenticated(request)
  24. return self.create_response(request, {
  25. 'repositories': get_odoo_modules_repos_names()
  26. })