Commit af6b285a authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

drf

parent 335dc600
Pipeline #1076 failed with stages
in 4 minutes and 12 seconds
......@@ -12,6 +12,7 @@ django-filter = "*"
"django-tables2" = "*"
requests = "*"
GitPython = "*"
djangorestframework = "*"
[requires]
python_version = "3.6"
......
{
"_meta": {
"hash": {
"sha256": "713eb318b9c6ee725a82c8583be41d5dd90d2d0c4afac1c34406eacd108fb9b2"
"sha256": "80cb0e469667c93e2ed5b06718c97e0fe10bfba3a193b8b3ec7d22ce27dfea7c"
},
"pipfile-spec": 6,
"requires": {
......@@ -40,10 +40,10 @@
},
"django-autoslug-iplweb": {
"hashes": [
"sha256:8cce63a74f6da8151b9cb424c3878fefa20136d5a87f211644d3fcea59c42d0a",
"sha256:c5a278681bd49bfd1a75f95efa396b99ec81b6eddfc8d45b9231d265d70a3b39"
"sha256:6ddec119072067e78cbdb53f7ba11ae8bee5a2f2f0fe1d90c6a4d3c0a91489d3",
"sha256:8a3ba49b18f082e29ac9cb17884d4b2149ad14988bd89e118b1c5ddf94fdea8e"
],
"version": "==1.9.4.dev0"
"version": "==1.9.4"
},
"django-bootstrap4": {
"hashes": [
......@@ -53,33 +53,41 @@
},
"django-filter": {
"hashes": [
"sha256:57c12c8ed40861e8ec7219ea65adcdd92ed0ea4c5b76a86f9ff9216a80dd5af7",
"sha256:57c5507b0011058a7f2d2227b7ef9fea27e69e53ef65da6d2fbd0b27cdaafed3"
"sha256:6f4e4bc1a11151178520567b50320e5c32f8edb552139d93ea3e30613b886f56",
"sha256:86c3925020c27d072cdae7b828aaa5d165c2032a629abbe3c3a1be1edae61c58"
],
"index": "pypi",
"version": "==2.0.0.dev1"
"version": "==2.0.0"
},
"django-tables2": {
"hashes": [
"sha256:d596002d9e2d023927cc06fd623c85abc0fa20c8fda79cb589e410314be2c83b"
"sha256:43b9af69933dd70afd26b5179987fa89a64221379d605a7be86686c4e30933b5"
],
"index": "pypi",
"version": "==2.0.0a3"
"version": "==2.0.0a5"
},
"djangorestframework": {
"hashes": [
"sha256:b6714c3e4b0f8d524f193c91ecf5f5450092c2145439ac2769711f7eba89a9d9",
"sha256:c375e4f95a3a64fccac412e36fb42ba36881e52313ec021ef410b40f67cddca4"
],
"index": "pypi",
"version": "==3.8.2"
},
"gitdb2": {
"hashes": [
"sha256:b60e29d4533e5e25bb50b7678bbc187c8f6bcff1344b4f293b2ba55c85795f09",
"sha256:cf9a4b68e8c4da8d42e48728c944ff7af2d8c9db303ac1ab32eac37aa4194b0e"
"sha256:87783b7f4a8f6b71c7fe81d32179b3c8781c1a7d6fa0c69bff2f315b00aff4f8",
"sha256:bb4c85b8a58531c51373c89f92163b92f30f81369605a67cd52d1fc21246c044"
],
"version": "==2.0.3"
"version": "==2.0.4"
},
"gitpython": {
"hashes": [
"sha256:1ec4c44846cf76a1e55769560673a97731849c9d05401e035e607495f10db959",
"sha256:b60b045cf64a321e5b620debb49890099fa6c7be6dfb7fb249027e5d34227301"
"sha256:563221e5a44369c6b79172f455584c9ebbb122a13368cc82cb4b5addff788f82",
"sha256:8237dc5bfd6f1366abeee5624111b9d6879393d84745a507de0fda86043b65a8"
],
"index": "pypi",
"version": "==2.1.10"
"version": "==2.1.11"
},
"idna": {
"hashes": [
......@@ -113,10 +121,10 @@
},
"smmap2": {
"hashes": [
"sha256:b78ee0f1f5772d69ff50b1cbdb01b8c6647a8354f02f23b488cf4b2cfc923956",
"sha256:c7530db63f15f09f8251094b22091298e82bf6c699a6b8344aaaef3f2e1276c3"
"sha256:0dd53d991af487f9b22774fa89451358da3607c02b9b886a54736c6a313ece0b",
"sha256:dc216005e529d57007ace27048eb336dcecb7fc413cfb3b2f402bb25972b69c6"
],
"version": "==2.0.3"
"version": "==2.0.4"
},
"urllib3": {
"hashes": [
......
......@@ -37,6 +37,7 @@ INSTALLED_APPS = [
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'rest_framework',
'django_tables2',
'django_filters',
'bootstrap4',
......
from rest_framework import serializers
from . import models
class NamespaceSerializer(serializers.ModelSerializer):
class Meta:
model = models.Namespace
fields = ('id', 'name', 'slug', 'group')
class LicenseSerializer(serializers.ModelSerializer):
class Meta:
model = models.License
fields = ('id', 'name', 'spdx_id', 'url')
class ForgeSerializer(serializers.ModelSerializer):
class Meta:
model = models.Forge
fields = ('id', 'name', 'slug', 'source', 'url')
class ProjectSerializer(serializers.ModelSerializer):
class Meta:
model = models.Project
fields = ('id', 'name', 'slug', 'public', 'main_namespace', 'main_forge', 'license', 'homepage', 'description',
'version', 'updated', 'tests', 'docs', 'debug', 'from_gepetto', 'created', 'updated')
class RepoSerializer(serializers.ModelSerializer):
class Meta:
model = models.Repo
fields = ('id', 'name', 'slug', 'forge', 'namespace', 'project', 'license', 'homepage', 'url',
'default_branch', 'open_issues', 'open_pr', 'repo_id', 'forked_from', 'clone_url', 'travis_id',
'description')
class BranchSerializer(serializers.ModelSerializer):
class Meta:
model = models.Branch
fields = ('id', 'name', 'project', 'ahead', 'behind', 'updated', 'repo', 'deleted', 'keep_doc', 'created',
'updated')
class TargetSerializer(serializers.ModelSerializer):
class Meta:
model = models.Target
fields = ('id', 'name', 'slug', 'active')
class RobotpkgSerializer(serializers.ModelSerializer):
class Meta:
model = models.Robotpkg
fields = ('id', 'name', 'slug', 'project', 'category', 'pkgbase', 'pkgversion', 'master_sites',
'master_repository', 'maintainer', 'comment', 'homepage', 'license', 'public', 'description',
'updated')
class ImageSerializer(serializers.ModelSerializer):
class Meta:
model = models.Image
fields = ('id', 'robotpkg', 'target', 'created', 'image', 'py3', 'debug')
class ContributorSerializer(serializers.ModelSerializer):
class Meta:
model = models.Contributor
fields = ('id', 'projects', 'agreement_signed')
class ContributorNameSerializer(serializers.ModelSerializer):
class Meta:
model = models.ContributorName
fields = ('id', 'contributor', 'name')
class ContributorMailSerializer(serializers.ModelSerializer):
class Meta:
model = models.ContributorMail
fields = ('id', 'contributor', 'mail', 'invalid')
class DependencySerializer(serializers.ModelSerializer):
class Meta:
model = models.Dependency
fields = ('id', 'project', 'library', 'robotpkg', 'cmake', 'ros')
from django.urls import path
from django.urls import path, include
from django.views.generic import RedirectView, TemplateView
from rest_framework import routers
from . import views
router = routers.DefaultRouter()
router.register(r'namespace', views.NamespaceViewSet)
router.register(r'license', views.LicenseViewSet)
router.register(r'forge', views.ForgeViewSet)
router.register(r'project', views.ProjectViewSet)
router.register(r'repo', views.RepoViewSet)
router.register(r'branch', views.BranchViewSet)
router.register(r'target', views.TargetViewSet)
router.register(r'robotpkg', views.RobotpkgViewSet)
router.register(r'image', views.ImageViewSet)
router.register(r'contributor', views.ContributorViewSet)
router.register(r'contributorName', views.ContributorNameViewSet)
router.register(r'contributorMail', views.ContributorMailViewSet)
router.register(r'dependency', views.DependencyViewSet)
app_name = 'rainboard'
urlpatterns = [
path('', RedirectView.as_view(pattern_name='rainboard:projects'), name='home'),
......@@ -21,4 +38,6 @@ urlpatterns = [
path('docker', views.docker, name='docker'),
path('graph.svg', views.graph_svg, name='graph_svg'),
path('graph', TemplateView.as_view(template_name='rainboard/graph.html'), name='graph'),
path('api/', include(router.urls)),
path('api-auth/', include('rest_framework.urls', namespace='rest_framework')),
]
......@@ -6,8 +6,9 @@ from django.views.generic import DetailView
from django_filters.views import FilterView
from django_tables2 import RequestConfig
from django_tables2.views import SingleTableMixin, SingleTableView
from rest_framework import permissions, viewsets
from . import filters, models, tables
from . import filters, models, serializers, tables
class ForgesView(SingleTableView):
......@@ -119,3 +120,81 @@ def graph_svg(request):
print('}', file=f)
svg = run(['dot', '/tmp/graph', '-Tsvg'], stdout=PIPE).stdout.decode()
return HttpResponse(svg, content_type='image/svg+xml')
class NamespaceViewSet(viewsets.ModelViewSet):
queryset = models.Namespace.objects.all()
serializer_class = serializers.NamespaceSerializer
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)
class LicenseViewSet(viewsets.ModelViewSet):
queryset = models.License.objects.all()
serializer_class = serializers.LicenseSerializer
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)
class ForgeViewSet(viewsets.ModelViewSet):
queryset = models.Forge.objects.all()
serializer_class = serializers.ForgeSerializer
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)
class ProjectViewSet(viewsets.ModelViewSet):
queryset = models.Project.objects.all()
serializer_class = serializers.ProjectSerializer
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)
class RepoViewSet(viewsets.ModelViewSet):
queryset = models.Repo.objects.all()
serializer_class = serializers.RepoSerializer
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)
class BranchViewSet(viewsets.ModelViewSet):
queryset = models.Branch.objects.all()
serializer_class = serializers.BranchSerializer
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)
class TargetViewSet(viewsets.ModelViewSet):
queryset = models.Target.objects.all()
serializer_class = serializers.TargetSerializer
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)
class RobotpkgViewSet(viewsets.ModelViewSet):
queryset = models.Robotpkg.objects.all()
serializer_class = serializers.RobotpkgSerializer
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)
class ImageViewSet(viewsets.ModelViewSet):
queryset = models.Image.objects.all()
serializer_class = serializers.ImageSerializer
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)
class ContributorViewSet(viewsets.ModelViewSet):
queryset = models.Contributor.objects.all()
serializer_class = serializers.ContributorSerializer
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)
class ContributorNameViewSet(viewsets.ModelViewSet):
queryset = models.ContributorName.objects.all()
serializer_class = serializers.ContributorNameSerializer
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)
class ContributorMailViewSet(viewsets.ModelViewSet):
queryset = models.ContributorMail.objects.all()
serializer_class = serializers.ContributorMailSerializer
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)
class DependencyViewSet(viewsets.ModelViewSet):
queryset = models.Dependency.objects.all()
serializer_class = serializers.DependencySerializer
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment