parent
2e983bc3ca
commit
6020d4982c
15 changed files with 255 additions and 120 deletions
@ -1,13 +1,20 @@ |
||||
from rest_framework import routers |
||||
|
||||
from .views import ProjectViewSet, SpecializationViewSet, UserViewSet, LocationViewSet |
||||
from .views import ( |
||||
LocationViewSet, |
||||
ProjectViewSet, |
||||
RealtyViewSet, |
||||
SpecializationViewSet, |
||||
UserViewSet, |
||||
) |
||||
|
||||
|
||||
router = routers.DefaultRouter() |
||||
|
||||
router.register(r'locations', LocationViewSet) |
||||
router.register(r'projects', ProjectViewSet) |
||||
router.register(r'realties', RealtyViewSet) |
||||
router.register(r'specializations', SpecializationViewSet) |
||||
router.register(r'users', UserViewSet) |
||||
router.register(r'location', LocationViewSet) |
||||
|
||||
urlpatterns = router.urls |
||||
|
||||
@ -1,12 +1,55 @@ |
||||
from rest_framework_filters import FilterSet, RelatedFilter, AllLookupsFilter |
||||
from .models import Project |
||||
|
||||
from .models import Project, Realty, BuildingClassfication, ConstructionType |
||||
|
||||
|
||||
class BuildingClassficationFilterSet(FilterSet): |
||||
id = AllLookupsFilter() |
||||
name = AllLookupsFilter() |
||||
|
||||
class Meta: |
||||
model = BuildingClassfication |
||||
|
||||
|
||||
class ConstructionTypeFilterSet(FilterSet): |
||||
id = AllLookupsFilter() |
||||
name = AllLookupsFilter() |
||||
|
||||
class Meta: |
||||
model = ConstructionType |
||||
|
||||
|
||||
class ProjectFilterSet(FilterSet): |
||||
budget = AllLookupsFilter() |
||||
budget_by_agreement = AllLookupsFilter() |
||||
created = AllLookupsFilter() |
||||
cro = AllLookupsFilter() |
||||
currency = AllLookupsFilter() |
||||
deal_type = AllLookupsFilter() |
||||
name = AllLookupsFilter() |
||||
price = AllLookupsFilter() |
||||
price_and_term_required = AllLookupsFilter() |
||||
state = AllLookupsFilter() |
||||
term = AllLookupsFilter() |
||||
term_type = AllLookupsFilter() |
||||
text = AllLookupsFilter() |
||||
# user = RelatedFilter('users.filters.UserFilterSet') |
||||
# specialization = RelatedFilter('specializations.filters.SpecializationFilterSet') |
||||
work_type = AllLookupsFilter() |
||||
|
||||
customer = RelatedFilter('users.filters.UserFilterSet') |
||||
realty = RelatedFilter('projects.filters.RealtyFilterSet') |
||||
specialization = RelatedFilter('specializations.filters.SpecializationFilterSet') |
||||
|
||||
class Meta: |
||||
model = Project |
||||
|
||||
|
||||
class RealtyFilterSet(FilterSet): |
||||
id = AllLookupsFilter() |
||||
name = AllLookupsFilter() |
||||
|
||||
building_classification = RelatedFilter('projects.filters.BuildingClassficationFilterSet') |
||||
construction_type = RelatedFilter('projects.filters.ConstructionTypeFilterSet') |
||||
location = RelatedFilter('common.filters.LocationFilterSet') |
||||
user = RelatedFilter('users.filters.UserFilterSet') |
||||
|
||||
class Meta: |
||||
model = Realty |
||||
|
||||
@ -0,0 +1,20 @@ |
||||
# -*- coding: utf-8 -*- |
||||
# Generated by Django 1.9.6 on 2016-06-22 09:00 |
||||
from __future__ import unicode_literals |
||||
|
||||
from django.db import migrations, models |
||||
|
||||
|
||||
class Migration(migrations.Migration): |
||||
|
||||
dependencies = [ |
||||
('projects', '0033_auto_20160621_1057'), |
||||
] |
||||
|
||||
operations = [ |
||||
migrations.AlterField( |
||||
model_name='project', |
||||
name='work_type', |
||||
field=models.IntegerField(choices=[('1', 'Проектирование'), ('2', 'Техническое сопровождение')], default=1, max_length=20), |
||||
), |
||||
] |
||||
@ -1,21 +1,74 @@ |
||||
from rest_framework.serializers import ModelSerializer |
||||
|
||||
from .models import Project |
||||
from .models import Project, Realty, BuildingClassfication, ConstructionType |
||||
from common.serializers import LocationSerializer |
||||
from specializations.serializers import SpecializationSerializer |
||||
from users.serializers import UserSerializer |
||||
|
||||
|
||||
class BuildingClassficationSerializer(ModelSerializer): |
||||
class Meta: |
||||
model = BuildingClassfication |
||||
|
||||
fields = ( |
||||
'id', |
||||
'name', |
||||
) |
||||
|
||||
|
||||
class ConstructionTypeSerializer(ModelSerializer): |
||||
class Meta: |
||||
model = ConstructionType |
||||
|
||||
fields = ( |
||||
'id', |
||||
'name', |
||||
) |
||||
|
||||
|
||||
class RealtySerializer(ModelSerializer): |
||||
building_classification = BuildingClassficationSerializer() |
||||
construction_type = ConstructionTypeSerializer() |
||||
location = LocationSerializer() |
||||
user = UserSerializer() |
||||
|
||||
class Meta: |
||||
model = Realty |
||||
|
||||
fields = ( |
||||
'building_classification', |
||||
'construction_type', |
||||
'id', |
||||
'location', |
||||
'name', |
||||
'user', |
||||
) |
||||
|
||||
|
||||
class ProjectSerializer(ModelSerializer): |
||||
customer = UserSerializer() |
||||
specialization = SpecializationSerializer() |
||||
user = UserSerializer() |
||||
realty = RealtySerializer() |
||||
|
||||
class Meta: |
||||
model = Project |
||||
|
||||
fields = ( |
||||
'budget', |
||||
'budget_by_agreement', |
||||
'created', |
||||
'cro', |
||||
'currency', |
||||
'customer', |
||||
'deal_type', |
||||
'id', |
||||
'name', |
||||
'price', |
||||
'price_and_term_required', |
||||
'realty', |
||||
'specialization', |
||||
'state', |
||||
'term', |
||||
'term_type', |
||||
'text', |
||||
'user', |
||||
'work_type', |
||||
) |
||||
|
||||
Loading…
Reference in new issue