Commit 8009e70d authored by Florent Chehab's avatar Florent Chehab
Browse files

Currency model added

parent dbc7ffa4
Pipeline #26316 passed with stages
in 1 minute and 25 seconds
# Generated by Django 2.0.3 on 2018-08-20 14:54
import django.core.validators
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('rex', '0002_universityscholarship'),
operations = [
('code', models.CharField(max_length=15, primary_key=True, serialize=False)),
('name', models.CharField(max_length=100)),
('symbol', models.CharField(max_length=5)),
('one_USD_in_this_currency', models.DecimalField(decimal_places=6, max_digits=20, validators=[django.core.validators.MinValueValidator(0)])),
from .module import Module # noqa: F401
from .basicModule import BasicModule # noqa: F401
from .scholarship import Scholarship # noqa: F401
from .currency import Currency, CurrencyViewSet, CurrencySerializer # noqa: F401
from django.db import models
from rest_framework import serializers, viewsets, permissions
from django.core.validators import MinValueValidator
class Currency(models.Model):
code = models.CharField(primary_key=True, max_length=15)
name = models.CharField(max_length=100)
symbol = models.CharField(max_length=5)
one_USD_in_this_currency = models.DecimalField(
class CurrencySerializer(serializers.ModelSerializer):
class Meta:
model = Currency
fields = ('code', 'name', 'symbol', 'one_USD_in_this_currency')
class CurrencyViewSet(viewsets.ModelViewSet):
permission_classes = (permissions.DjangoModelPermissions,)
queryset = Currency.objects.all() # pylint: disable=E1101
serializer_class = CurrencySerializer
......@@ -3,6 +3,7 @@ from rex import views
from rest_framework import routers
from rex.models.location import CountryViewSet, CityViewSet
from import CampusViewSet, UniversityViewSet, UniversityScholarshipViewSet
from rex.models.module import CurrencyViewSet
from rest_framework.documentation import include_docs_urls
......@@ -18,5 +19,6 @@ router.register(r'city', CityViewSet)
router.register(r'campus', CampusViewSet)
router.register(r'university', UniversityViewSet)
router.register(r'university_scholarship', UniversityScholarshipViewSet)
router.register(r'currency', CurrencyViewSet)
urlpatterns += [url(r'^api/', include(router.urls))]
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