Commit e879c0f0 authored by Gladys Forte's avatar Gladys Forte

delete branch endpoint

parent f4c3a009
from rest_framework import serializers
from app.entities.models import Branch
class BranchSerializer(serializers.ModelSerializer):
class Meta:
model = Branch
fields = '__all__'
from app.entities.models import Branch
from rest_framework import viewsets, status
from rest_framework.response import Response
from django_filters import rest_framework as filters
from app.applicationlayer.master.branch.serializer import BranchSerializer
from app.applicationlayer.utils import (CustomPagination,
status_message_response)
class BranchViewSet(viewsets.ModelViewSet):
queryset = Branch.objects.all()
serializer_class = BranchSerializer
pagination_class = CustomPagination
lookup_field = 'id'
# pagination.PageNumberPagination.page_size = 100
pagination_class.page_size = 100
def list(self, request, *args, **kwargs):
queryset = self.filter_queryset(self.get_queryset())
page = self.paginate_queryset(queryset)
if page is not None:
serializer = self.get_serializer(page, many=True)
message = status_message_response(
200,
'success',
'list of branches found',
serializer.data
)
return self.get_paginated_response(message)
serializer = self.get_serializer(queryset, many=True)
return Response(serializer.data)
......@@ -7,14 +7,12 @@ from app.applicationlayer.master.department.views import AdminDepartmentViewSet
from app.applicationlayer.master.user_type.views import UserTypeViewSet
from app.applicationlayer.master.attachment.views import MasterAttachmentViewSet
from app.applicationlayer.master.dashboard.views import RMSDashBoardViewSet
from app.applicationlayer.master.branch.views import BranchViewSet
router = routers.DefaultRouter()
router.register(r'users', AdminAccountViewSet)
router.register(r'companies', AdminCompanyViewSet)
router.register(r'departments', AdminDepartmentViewSet)
router.register(r'attachments', MasterAttachmentViewSet)
router.register(r'branches', BranchViewSet)
urlpatterns = [
path('', include(router.urls)),
......
# Generated by Django 2.2 on 2020-01-22 17:52
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('entities', '0006_branch'),
]
operations = [
migrations.DeleteModel(
name='Branch',
),
]
......@@ -1273,25 +1273,3 @@ class ChangeRequestSettings(models.Model):
self.code = code
self.created = datetime.now()
self.save()
\ No newline at end of file
# branches info
class Branch(models.Model):
enviroment = models.CharField(
max_length=255)
branch_name = models.CharField(
max_length=255)
repo_type = models.CharField(
max_length=50)
repository = models.CharField(
unique=True,
max_length=255)
created = models.DateTimeField(
auto_now_add=True)
class Meta:
db_table = 'branches'
def __str__(self):
return f'{self.branch_name}'
\ No newline at end of file
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