Skip to content

Commit

Permalink
Closes #8
Browse files Browse the repository at this point in the history
Modificadas las tuplas por entidades propias
  • Loading branch information
ChmlGr committed Jan 5, 2016
1 parent 180c189 commit 0d775ce
Show file tree
Hide file tree
Showing 10 changed files with 174 additions and 40 deletions.
1 change: 1 addition & 0 deletions eventoL/activity/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
admin.site.register(models.Talk)
admin.site.register(models.TalkProposal)
admin.site.register(models.TalkType)
admin.site.register(models.TalkLevel)
37 changes: 37 additions & 0 deletions eventoL/activity/migrations/0002_auto_20160105_2110.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9 on 2016-01-05 21:10
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('activity', '0001_initial'),
]

operations = [
migrations.CreateModel(
name='TalkLevel',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('description', models.CharField(help_text='Talk level i.e. Begginer, Expert', max_length=50, verbose_name='Description')),
],
options={
'verbose_name': 'Talk Level',
'verbose_name_plural': 'Talk Levels',
},
),
migrations.AlterField(
model_name='comment',
name='created',
field=models.DateTimeField(),
),
migrations.AlterField(
model_name='talkproposal',
name='level',
field=models.ForeignKey(help_text="The talk's Technical level", on_delete=django.db.models.deletion.CASCADE, to='activity.TalkLevel', verbose_name='Level'),
),
]
21 changes: 13 additions & 8 deletions eventoL/activity/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from user.models import InstalationAttendee, Installer
from django.utils.translation import ugettext_lazy as _, ugettext_noop as _noop


class Activity(models.Model):
event = models.ForeignKey(Event, verbose_name=_noop('Event'))
title = models.CharField(_('Title'), max_length=50, blank=True, null=True)
Expand Down Expand Up @@ -35,13 +34,20 @@ class Meta:
verbose_name = _('Talk Type')
verbose_name_plural = _('Talk Types')

class TalkLevel(models.Model):
"""
Level of the talk. For example: Begginer, Expert
"""
description = models.CharField(_('Description'), max_length=50, help_text=_('Talk level i.e. Begginer, Expert'))

def __unicode__(self):
return self.description

class Meta:
verbose_name = _('Talk Level')
verbose_name_plural = _('Talk Levels')

class TalkProposal(models.Model):
level_choices = (
('1', _('Beginner')),
('2', _('Medium')),
('3', _('Advanced')),
)
activity = models.ForeignKey(Activity, verbose_name=_noop('Activity'))
type = models.ForeignKey(TalkType, verbose_name=_('Type'))
speakers_names = models.CharField(_('Speakers Names'), max_length=600,
Expand All @@ -52,8 +58,7 @@ class TalkProposal(models.Model):
help_text=_('Comma separated tags. i.e. Linux, Free Software, Debian'))
presentation = models.FileField(_('Presentation'), upload_to='talks', blank=True, null=True, help_text=_(
'Any material you are going to use for the talk (optional, but recommended)'))
level = models.CharField(_('Level'), choices=level_choices, max_length=100,
help_text=_("The talk's Technical level"), default='Beginner')
level = models.ForeignKey(TalkLevel, verbose_name=_('Level'), help_text=_("The talk's Technical level"))

def __unicode__(self):
return u"%s: %s" % (self.activity.event, self.activity.title)
Expand Down
3 changes: 3 additions & 0 deletions eventoL/api/rest/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

# Activity Model
router.register(r'talktype', ViewSetBuilder(activity_model.TalkType).build())
router.register(r'talklevel', ViewSetBuilder(activity_model.TalkLevel).build())
router.register(r'talkproposal', ViewSetBuilder(activity_model.TalkProposal).build())
router.register(r'room', ViewSetBuilder(activity_model.Room).build())
router.register(r'activity', ViewSetBuilder(activity_model.Activity).build())
Expand All @@ -45,4 +46,6 @@
# Device Model
router.register(r'hardware', ViewSetBuilder(device_model.Hardware).build())
router.register(r'hardwaremanufacturer', ViewSetBuilder(device_model.HardwareManufacturer).build())
router.register(r'softwarechoices', ViewSetBuilder(device_model.SoftwareChoices).build())
router.register(r'hardwarechoices', ViewSetBuilder(device_model.HardwareChoices).build())
router.register(r'software', ViewSetBuilder(device_model.Software).build())
25 changes: 19 additions & 6 deletions eventoL/api/tests/test_api_for_activity_models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import datetime
import unittest
from activity.models import Activity, Comment, TalkProposal, Talk, TalkType, Room, Installation
from activity.models import Activity, Comment, TalkProposal, Talk, TalkType, Room, Installation, TalkLevel
from api.tests.test_api import api_test


Expand All @@ -20,7 +20,8 @@ class TestApiActivity():

@api_test()
class TestApiComment():
fk_models = ['auth.User', 'event.Adress', 'event.Event', 'activity.Activity']
fk_models = ['auth.User', 'event.Adress',
'event.Event', 'activity.Activity']
str_model = 'activity.Comment'
model = Comment
url_base = '/api/comment/'
Expand All @@ -32,7 +33,8 @@ class TestApiComment():

@api_test()
class TestApiTalkProposal():
fk_models = ['event.Adress', 'event.Event', 'activity.Activity', 'activity.TalkType']
fk_models = ['event.Adress', 'event.Event', 'activity.Activity',
'activity.TalkType', 'activity.TalkLevel']
str_model = 'activity.TalkProposal'
model = TalkProposal
url_base = '/api/talkproposal/'
Expand All @@ -41,12 +43,12 @@ class TestApiTalkProposal():
'speakers_email': 'pepe@pepemail.com',
'labels': 'python,django'
}
# TODO check level: Beginner


@api_test()
class TestApiTalk():
fk_models = ['event.Adress', 'event.Event', 'activity.Activity', 'activity.TalkType', 'activity.TalkProposal', 'activity.Room']
fk_models = ['event.Adress', 'event.Event', 'activity.Activity', 'activity.TalkType',
'activity.TalkLevel', 'activity.TalkProposal', 'activity.Room']
str_model = 'activity.Talk'
model = Talk
url_base = '/api/talk/'
Expand All @@ -66,6 +68,16 @@ class TestApiTalkType():
}


@api_test()
class TestApiTalkLevel():
str_model = 'activity.TalkLevel'
model = TalkLevel
url_base = '/api/talklevel/'
example = {
'description': 'Begginer'
}


@api_test()
class TestApiRoom():
fk_models = ['event.Adress', 'event.Event', 'activity.TalkType']
Expand All @@ -79,7 +91,8 @@ class TestApiRoom():

@api_test()
class TestApiInstallation():
fk_models = ['device.HardwareManufacturer', 'device.Hardware', 'device.Software', 'auth.User', 'event.Adress', 'event.Event', 'user.EventoLUser', 'user.InstalationAttendee','user.Installer']
fk_models = ['device.HardwareManufacturer', 'device.HardwareChoices', 'device.SoftwareChoices', 'device.Hardware', 'device.Software', 'auth.User',
'event.Adress', 'event.Event', 'user.EventoLUser', 'user.InstalationAttendee', 'user.Installer']
str_model = 'activity.Installation'
model = Installation
url_base = '/api/installation/'
Expand Down
26 changes: 20 additions & 6 deletions eventoL/api/tests/test_api_for_device_models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import unittest
from device.models import HardwareManufacturer, Software, Hardware
from device.models import HardwareManufacturer, Software, Hardware, SoftwareChoices, HardwareChoices
from api.tests.test_api import api_test


Expand All @@ -13,31 +13,45 @@ class TestApiHardwareManufacturer():
'name': 'Manufacturer'
}

@api_test()
class TestApiHardwareChoices():
str_model = 'device.HardwareChoices'
model = SoftwareChoices
url_base = '/api/hardwarechoices/'
example = {
'description': 'Desktop'
}

@api_test()
class TestApiSoftwareChoices():
str_model = 'device.SoftwareChoices'
model = SoftwareChoices
url_base = '/api/softwarechoices/'
example = {
'description': 'Operative System'
}

@api_test()
class TestApiSoftware():
fk_models = ['device.SoftwareChoices']
str_model = 'device.Software'
model = Software
url_base = '/api/software/'
example = {
'name': 'eventoL',
'version': 'v2.0'
}
# TODO View 'type': 'Other'


@api_test()
class TestApiHardware():
fk_models = ['device.HardwareManufacturer']
fk_models = ['device.HardwareManufacturer', 'device.HardwareChoices']
str_model = 'device.Hardware'
model = Hardware
url_base = '/api/hardware/'
example = {
'model': 'model',
'serial': '19827398172ASDF'
}
# TODO View 'type': 'Other'

if __name__ == '__main__':
unittest.main()

7 changes: 4 additions & 3 deletions eventoL/api/tests/test_api_for_user_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ class TestApiInstaller():
str_model = 'user.Installer'
model = Installer
url_base = '/api/installer/'
example = {}
# TODO check level: Beginner
example = {
'level':'1'
}

if __name__ == '__main__':
unittest.main()
unittest.main()
3 changes: 2 additions & 1 deletion eventoL/device/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@

admin.site.register(models.Hardware)
admin.site.register(models.HardwareManufacturer)
admin.site.register(models.SoftwareChoices)
admin.site.register(models.HardwareChoices)
admin.site.register(models.Software)

48 changes: 48 additions & 0 deletions eventoL/device/migrations/0002_auto_20160105_2110.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9 on 2016-01-05 21:10
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('device', '0001_initial'),
]

operations = [
migrations.CreateModel(
name='HardwareChoices',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('description', models.CharField(max_length=200, verbose_name='Description')),
],
options={
'verbose_name': 'Hardware Choice',
'verbose_name_plural': 'Hardware Choices',
},
),
migrations.CreateModel(
name='SoftwareChoices',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('description', models.CharField(max_length=200, verbose_name='Description')),
],
options={
'verbose_name': 'Software Choice',
'verbose_name_plural': 'Software Choices',
},
),
migrations.AlterField(
model_name='hardware',
name='type',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='device.HardwareChoices', verbose_name='Type'),
),
migrations.AlterField(
model_name='software',
name='type',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='device.SoftwareChoices', verbose_name='Type'),
),
]
43 changes: 27 additions & 16 deletions eventoL/device/models.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,36 @@
from django.db import models
from django.utils.translation import ugettext_lazy as _

class SoftwareChoices(models.Model):
"""
Options for Software Installations
"""
description = models.CharField(_('Description'), max_length=200)

def __unicode__(self):
return self.description

class Meta:
verbose_name = _('Software Choice')
verbose_name_plural = _('Software Choices')

class HardwareChoices(models.Model):
"""
Options for Hardware Installations
"""
description = models.CharField(_('Description'), max_length=200)

def __unicode__(self):
return self.description

class Meta:
verbose_name = _('Hardware Choice')
verbose_name_plural = _('Hardware Choices')

class Software(models.Model):
software_choices = (
('OS', _('Operative System')),
('AP', _('Application')),
('SU', _('Support and Problem Fixing')),
('OT', _('Other'))
)
name = models.CharField(_('Name'), max_length=200)
version = models.CharField(_('Version'), max_length=200)
type = models.CharField(_('Type'), choices=software_choices, max_length=200)
type = models.ForeignKey(SoftwareChoices, verbose_name=_('Type'))

def __unicode__(self):
return u"%s - %s v.%s" % (self.type, self.name, self.version)
Expand All @@ -29,15 +48,7 @@ class Meta:


class Hardware(models.Model):
hardware_choices = (
('MOB', _('Mobile')),
('NOTE', _('Notebook')),
('NET', _('Netbook')),
('TAB', _('Tablet')),
('DES', _('Desktop')),
('OTH', _('Other'))
)
type = models.CharField(_('Type'), choices=hardware_choices, max_length=200)
type = models.ForeignKey(HardwareChoices, verbose_name=_('Type'))
manufacturer = models.ForeignKey(HardwareManufacturer, verbose_name=_('Manufacturer'), blank=True, null=True)
model = models.CharField(_('Model'), max_length=200, blank=True, null=True)
serial = models.CharField(_('Serial'), max_length=200, blank=True, null=True)
Expand Down

0 comments on commit 0d775ce

Please sign in to comment.