parent
2e983bc3ca
commit
6020d4982c
15 changed files with 255 additions and 120 deletions
@ -1,13 +1,20 @@ |
|||||||
from rest_framework import routers |
from rest_framework import routers |
||||||
|
|
||||||
from .views import ProjectViewSet, SpecializationViewSet, UserViewSet, LocationViewSet |
from .views import ( |
||||||
|
LocationViewSet, |
||||||
|
ProjectViewSet, |
||||||
|
RealtyViewSet, |
||||||
|
SpecializationViewSet, |
||||||
|
UserViewSet, |
||||||
|
) |
||||||
|
|
||||||
|
|
||||||
router = routers.DefaultRouter() |
router = routers.DefaultRouter() |
||||||
|
|
||||||
|
router.register(r'locations', LocationViewSet) |
||||||
router.register(r'projects', ProjectViewSet) |
router.register(r'projects', ProjectViewSet) |
||||||
|
router.register(r'realties', RealtyViewSet) |
||||||
router.register(r'specializations', SpecializationViewSet) |
router.register(r'specializations', SpecializationViewSet) |
||||||
router.register(r'users', UserViewSet) |
router.register(r'users', UserViewSet) |
||||||
router.register(r'location', LocationViewSet) |
|
||||||
|
|
||||||
urlpatterns = router.urls |
urlpatterns = router.urls |
||||||
|
|||||||
@ -1,12 +1,55 @@ |
|||||||
from rest_framework_filters import FilterSet, RelatedFilter, AllLookupsFilter |
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): |
class ProjectFilterSet(FilterSet): |
||||||
|
budget = AllLookupsFilter() |
||||||
|
budget_by_agreement = AllLookupsFilter() |
||||||
|
created = AllLookupsFilter() |
||||||
|
cro = AllLookupsFilter() |
||||||
|
currency = AllLookupsFilter() |
||||||
|
deal_type = AllLookupsFilter() |
||||||
name = AllLookupsFilter() |
name = AllLookupsFilter() |
||||||
price = AllLookupsFilter() |
price_and_term_required = AllLookupsFilter() |
||||||
|
state = AllLookupsFilter() |
||||||
|
term = AllLookupsFilter() |
||||||
|
term_type = AllLookupsFilter() |
||||||
text = AllLookupsFilter() |
text = AllLookupsFilter() |
||||||
# user = RelatedFilter('users.filters.UserFilterSet') |
work_type = AllLookupsFilter() |
||||||
# specialization = RelatedFilter('specializations.filters.SpecializationFilterSet') |
|
||||||
|
customer = RelatedFilter('users.filters.UserFilterSet') |
||||||
|
realty = RelatedFilter('projects.filters.RealtyFilterSet') |
||||||
|
specialization = RelatedFilter('specializations.filters.SpecializationFilterSet') |
||||||
|
|
||||||
class Meta: |
class Meta: |
||||||
model = Project |
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 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 specializations.serializers import SpecializationSerializer |
||||||
from users.serializers import UserSerializer |
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): |
class ProjectSerializer(ModelSerializer): |
||||||
|
customer = UserSerializer() |
||||||
specialization = SpecializationSerializer() |
specialization = SpecializationSerializer() |
||||||
user = UserSerializer() |
realty = RealtySerializer() |
||||||
|
|
||||||
class Meta: |
class Meta: |
||||||
model = Project |
model = Project |
||||||
|
|
||||||
fields = ( |
fields = ( |
||||||
|
'budget', |
||||||
|
'budget_by_agreement', |
||||||
|
'created', |
||||||
|
'cro', |
||||||
|
'currency', |
||||||
|
'customer', |
||||||
|
'deal_type', |
||||||
'id', |
'id', |
||||||
'name', |
'name', |
||||||
'price', |
'price_and_term_required', |
||||||
|
'realty', |
||||||
'specialization', |
'specialization', |
||||||
|
'state', |
||||||
|
'term', |
||||||
|
'term_type', |
||||||
'text', |
'text', |
||||||
'user', |
'work_type', |
||||||
) |
) |
||||||
|
|||||||
Loading…
Reference in new issue