diff --git a/core/admin.py b/core/admin.py index ce69f50..86b8199 100644 --- a/core/admin.py +++ b/core/admin.py @@ -1,7 +1,9 @@ from django.contrib import admin + from models import Job, Category class CategoryAdmin(admin.ModelAdmin): prepopulated_fields = {"slug": ("name",)} + admin.site.register(Job) admin.site.register(Category, CategoryAdmin) diff --git a/core/api.py b/core/api.py new file mode 100644 index 0000000..1218b9d --- /dev/null +++ b/core/api.py @@ -0,0 +1,7 @@ +from tastypie.resources import ModelResource +from core.models import Job + +class JobResource(ModelResource): + class Meta: + queryset = Job.objects.all() + resource_name = "job" diff --git a/core/forms.py b/core/forms.py index 7cefb0b..e72f446 100644 --- a/core/forms.py +++ b/core/forms.py @@ -1,4 +1,5 @@ # Formularios +from django.conf import settings from django import forms from models import Job diff --git a/core/models.py b/core/models.py index 14ba263..c3c9db2 100644 --- a/core/models.py +++ b/core/models.py @@ -2,9 +2,14 @@ # -*- coding: utf-8 -*- # Los modelos creados! -from django.template.defaultfilters import slugify + +from __future__ import unicode_literals + from django.db import models +from django.template.defaultfilters import slugify +from django.utils.encoding import python_2_unicode_compatible +from tinymce.models import HTMLField class Category(models.Model): class Meta: @@ -23,35 +28,21 @@ def __unicode__(self): def get_absolute_url(self): return ("category/%s" % self.slug) +@python_2_unicode_compatible class Job(models.Model): name = models.CharField(max_length=200, verbose_name="nombre del trabajo") category = models.ForeignKey(Category, verbose_name="categoría") place = models.CharField(max_length=200, verbose_name="lugar") - description = models.TextField(verbose_name="Perfil de puesto") - application = models.TextField(verbose_name="Como aplicar?") + description = HTMLField(verbose_name="Perfil de puesto") + application = HTMLField(verbose_name="Como aplicar?") pub_date = models.DateTimeField(auto_now_add=True) company_name = models.CharField(max_length=200, verbose_name="nombre de compañía") url = models.URLField(blank=True, null=True) email = models.EmailField() logo = models.ImageField(upload_to="images/logos", blank=True, null=True) - def __unicode__(self): + def __str__(self): return self.name def get_absolute_url(self): return ("/job/%i/" % self.id) - - -#class Company(models.Model): -# name = models.CharField(max_length=200, verbose_name="nombre de compañía") -# slug = models.SlugField(max_length=200) -# url = models.URLField() -# email = models.EmailField() -# logo = models.ImageField(upload_to="images/logos") - -# def __unicode__(self): -# return self.name - - - - diff --git a/core/templates/base.html b/core/templates/base.html index ae78fc6..c18defc 100644 --- a/core/templates/base.html +++ b/core/templates/base.html @@ -4,8 +4,11 @@ Emplea.do - {% block title %} {% endblock title %} + + + {% block external %} {% endblock external %} diff --git a/core/templates/jobs/job_form.html b/core/templates/jobs/job_form.html index f0cd464..4731e71 100644 --- a/core/templates/jobs/job_form.html +++ b/core/templates/jobs/job_form.html @@ -1,5 +1,8 @@ {% extends "base.html"%} -{% block title %} {% endblock title %} +{% block title %} Nuevo Trabajo {% endblock title %} + + + {% block content %}
{% csrf_token %} {% for field in form %} @@ -10,5 +13,13 @@ {% endfor %}
+ + {% endblock content %} diff --git a/emplea_do/settings.py b/emplea_do/settings.py index 35e0352..ac0ecd5 100644 --- a/emplea_do/settings.py +++ b/emplea_do/settings.py @@ -36,7 +36,9 @@ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'tinymce', 'core', + 'tastypie', ) MIDDLEWARE_CLASSES = ( @@ -79,8 +81,12 @@ # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.6/howto/static-files/ -STATICFILES_DIRS = ( - os.path.join(BASE_DIR, "static"), -) +STATIC_ROOT = os.path.join(BASE_DIR, "static") + STATIC_URL = '/static/' + +#STATICFILES_DIRS = ( +# os.path.join(BASE_DIR, "static"), +#) + diff --git a/emplea_do/urls.py b/emplea_do/urls.py index 9539254..b6ad5c4 100644 --- a/emplea_do/urls.py +++ b/emplea_do/urls.py @@ -1,7 +1,12 @@ from django.conf.urls import patterns, include, url from django.contrib import admin +from tastypie.api import Api from core.views import JobList, JobDetail, JobCreate +from core.api import JobResource + +v1_api = Api(api_name='v1') +v1_api.register(JobResource()) admin.autodiscover() @@ -13,4 +18,6 @@ url(r'^job/new/$', JobCreate.as_view()), url(r'^job/(?P\d+)/$', JobDetail.as_view()), url(r'^admin/', include(admin.site.urls)), + url(r'^tinymce/', include('tinymce.urls')), + url(r'^api/', include(v1_api.urls)), ) diff --git a/requirements.txt b/requirements.txt index 46c7397..9b3784c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,4 +2,16 @@ Django==1.6.5 Pillow==2.4.0 argparse==1.2.1 distribute==0.6.24 +dj-database-url==0.3.0 +dj-static==0.0.5 +django-tastypie==0.11.1 +django-tinymce==1.5.2 +django-toolbelt==0.0.1 +gunicorn==18.0 +psycopg2==2.5.3 +pystache==0.5.4 +python-dateutil==2.2 +python-mimeparse==0.1.4 +six==1.7.2 +static==1.0.2 wsgiref==0.1.2