From 638d402c67f112cf83d944a4dedb0fcf555e162d Mon Sep 17 00:00:00 2001 From: Felipe Prenholato Date: Fri, 3 Apr 2015 03:49:35 -0300 Subject: [PATCH 1/3] Integrate aldryn-categories into aldryn-jobs. --- aldryn_jobs/admin.py | 68 +++-- aldryn_jobs/forms.py | 13 +- aldryn_jobs/managers.py | 21 +- aldryn_jobs/menu.py | 11 +- .../migrations/0008_auto_20150403_0611.py | 44 +++ .../migrations/0009_auto_20150403_0611.py | 106 +++++++ .../migrations/0010_auto_20150403_0847.py | 51 ++++ aldryn_jobs/models.py | 55 ++-- ...n__del_unique_jobcategorytranslation_sl.py | 233 +++++++++++++++ ...igrate_jobcategory_to_aldryn_categories.py | 277 ++++++++++++++++++ ...n__del_unique_jobcategorytranslation_sl.py | 236 +++++++++++++++ aldryn_jobs/views.py | 19 +- 12 files changed, 1049 insertions(+), 85 deletions(-) create mode 100644 aldryn_jobs/migrations/0008_auto_20150403_0611.py create mode 100644 aldryn_jobs/migrations/0009_auto_20150403_0611.py create mode 100644 aldryn_jobs/migrations/0010_auto_20150403_0847.py create mode 100644 aldryn_jobs/south_migrations/0026_auto__del_jobcategorytranslation__del_unique_jobcategorytranslation_sl.py create mode 100644 aldryn_jobs/south_migrations/0027_data__migrate_jobcategory_to_aldryn_categories.py create mode 100644 aldryn_jobs/south_migrations/0028_auto__del_jobcategorytranslation__del_unique_jobcategorytranslation_sl.py diff --git a/aldryn_jobs/admin.py b/aldryn_jobs/admin.py index eccd31c..f9585c3 100644 --- a/aldryn_jobs/admin.py +++ b/aldryn_jobs/admin.py @@ -8,16 +8,18 @@ import cms from aldryn_apphooks_config.admin import BaseAppHookConfig +from aldryn_categories.admin import CategoryAdmin +from aldryn_categories.models import Category from cms.admin.placeholderadmin import PlaceholderAdmin from cms.admin.placeholderadmin import FrontendEditableAdmin from distutils.version import LooseVersion from emailit.api import send_mail from parler.admin import TranslatableAdmin -from .forms import JobCategoryAdminForm, JobOfferAdminForm +from .forms import JobOfferAdminForm from .models import ( - JobApplication, JobCategory, JobOffer, - JobsConfig, NewsletterSignup + JobApplication, JobOffer, + JobsConfig, NewsletterSignup, JobCategoryOpts ) @@ -123,28 +125,45 @@ def get_attachment_address(self, instance): get_attachment_address.short_description = _('Attachments') -class JobCategoryAdmin(TranslatableAdmin): - form = JobCategoryAdminForm - list_display = ['__unicode__', 'language_column', 'ordering'] - list_editable = ['ordering'] - filter_horizontal = ['supervisors'] +# class JobCategoryAdmin(TranslatableAdmin): +# form = JobCategoryAdminForm +# list_display = ['__unicode__', 'language_column', 'ordering'] +# list_editable = ['ordering'] +# filter_horizontal = ['supervisors'] + +# def get_fieldsets(self, request, obj=None): +# fieldsets = [ +# (_('Translatable fields'), { +# 'fields': ['name', 'slug'] +# }), +# (_('Supervisors'), { +# 'fields': ['supervisors'] +# }), +# (_('Options'), { +# 'fields': ['app_config'] +# }) +# ] +# return fieldsets + + +class JobCategoryOptsInline(admin.StackedInline): + extra = 1 + max_num = 1 + model = JobCategoryOpts + verbose_name = _("Aldryn Jobs option") + verbose_name_plural = _("Aldryn Jobs options") + + def has_delete_permission(self, *args, **kwargs): + return False - def get_fieldsets(self, request, obj=None): - fieldsets = [ - (_('Translatable fields'), { - 'fields': ['name', 'slug'] - }), - (_('Supervisors'), { - 'fields': ['supervisors'] - }), - (_('Options'), { - 'fields': ['app_config'] - }) - ] - return fieldsets + +class JobCategoryAdmin(CategoryAdmin): + list_display = ['__unicode__', 'language_column'] + inlines = [JobCategoryOptsInline] -class JobOfferAdmin(FrontendEditableAdmin, TranslatableAdmin, PlaceholderAdmin): +class JobOfferAdmin(FrontendEditableAdmin, TranslatableAdmin, + PlaceholderAdmin): form = JobOfferAdminForm list_display = ['__unicode__', 'language_column'] frontend_editable_fields = ('title', 'lead_in') @@ -156,7 +175,7 @@ def get_fieldsets(self, request, obj=None): 'fields': ['title', 'slug', 'lead_in'] }), (_('Options'), { - 'fields': ['category', 'is_active', 'can_apply', 'app_config'] + 'fields': ['category', 'category_new', 'is_active', 'can_apply', 'app_config'] }), (_('Publication period'), { 'fields': ['publication_start', 'publication_end'] @@ -207,7 +226,8 @@ class JobsConfigAdmin(BaseAppHookConfig): admin.site.register(JobApplication, JobApplicationAdmin) -admin.site.register(JobCategory, JobCategoryAdmin) +admin.site.unregister(Category) +admin.site.register(Category, JobCategoryAdmin) admin.site.register(JobOffer, JobOfferAdmin) admin.site.register(JobsConfig, JobsConfigAdmin) admin.site.register(NewsletterSignup, JobNewsletterSignupAdmin) diff --git a/aldryn_jobs/forms.py b/aldryn_jobs/forms.py index ed4045c..28d3346 100644 --- a/aldryn_jobs/forms.py +++ b/aldryn_jobs/forms.py @@ -17,10 +17,11 @@ from emailit.api import send_mail from multiupload.fields import MultiFileField from parler.forms import TranslatableModelForm +from treebeard.forms import MoveNodeForm from unidecode import unidecode from .models import ( - JobApplication, JobApplicationAttachment, JobCategory, JobOffer, + JobApplication, JobApplicationAttachment, JobOffer, NewsletterSignup, JobsConfig, JobListPlugin) @@ -106,16 +107,6 @@ def is_edit_action(self): return self.instance.pk is not None -class JobCategoryAdminForm(AutoSlugForm): - - slugified_field = 'name' - - class Meta: - model = JobCategory - fields = ['name', 'slug', 'supervisors', 'app_config'] - - - class JobOfferAdminForm(AutoSlugForm): slugified_field = 'title' diff --git a/aldryn_jobs/managers.py b/aldryn_jobs/managers.py index b053195..67ecd6f 100644 --- a/aldryn_jobs/managers.py +++ b/aldryn_jobs/managers.py @@ -1,16 +1,27 @@ # -*- coding: utf-8 -*- -from aldryn_apphooks_config.managers.parler import \ - AppHookConfigTranslatableManager, AppHookConfigTranslatableQueryset +from django.contrib.sites.models import get_current_site +from django.core.urlresolvers import reverse +from django.db import models from django.db.models import Q from django.utils import timezone -from django.db import models -from django.core.urlresolvers import reverse from django.utils.crypto import get_random_string -from django.contrib.sites.models import get_current_site + +from aldryn_apphooks_config.managers.parler import ( + AppHookConfigTranslatableManager, AppHookConfigTranslatableQueryset +) +from aldryn_categories.models import CategoryManager, CategoryQuerySet from emailit.api import send_mail +class JobCategoryQuerySet(AppHookConfigTranslatableQueryset, CategoryQuerySet): + pass + + +class JobCategoryManager(AppHookConfigTranslatableManager, CategoryManager): + queryset_class = JobCategoryQuerySet + + class JobOffersQuerySet(AppHookConfigTranslatableQueryset): def active(self): diff --git a/aldryn_jobs/menu.py b/aldryn_jobs/menu.py index f728311..44e2f44 100644 --- a/aldryn_jobs/menu.py +++ b/aldryn_jobs/menu.py @@ -9,7 +9,7 @@ from menus.base import NavigationNode from menus.menu_pool import menu_pool -from aldryn_jobs.models import JobCategory +from aldryn_categories.models import Category from aldryn_jobs.models import JobOffer @@ -22,14 +22,15 @@ def get_nodes(self, request): language = get_language_from_request(request) nodes = [] categories = ( - JobCategory.objects.namespace(app_namespace) - .language(language) - .translated(language) + Category.objects + .language(language) + .translated(language) + .filter(jobs_opts__app_config__namespace=app_namespace) ) for category in categories: try: node = NavigationNode(category.name, - category.get_absolute_url(), + category.jobs_opts.get_absolute_url(), category.slug) nodes.append(node) except NoReverseMatch: diff --git a/aldryn_jobs/migrations/0008_auto_20150403_0611.py b/aldryn_jobs/migrations/0008_auto_20150403_0611.py new file mode 100644 index 0000000..176cc34 --- /dev/null +++ b/aldryn_jobs/migrations/0008_auto_20150403_0611.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations +from django.conf import settings +import aldryn_categories.fields + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('aldryn_categories', '0003_auto_20150128_1359'), + ('aldryn_jobs', '0007_auto_20150330_0545'), + ] + + operations = [ + migrations.CreateModel( + name='JobCategoryOpts', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('app_config', models.ForeignKey(verbose_name='app_config', to='aldryn_jobs.JobsConfig', null=True)), + ('category', aldryn_categories.fields.CategoryOneToOneField(related_name='jobs_opts', to='aldryn_categories.Category')), + ('supervisors', models.ManyToManyField(help_text='Those people will be notified via e-mail when new application arrives.', related_name='job_categories_opts', verbose_name='Supervisors', to=settings.AUTH_USER_MODEL, blank=True)), + ], + options={ + 'verbose_name': 'Job category opts', + 'verbose_name_plural': 'Job categories opts', + }, + bases=(models.Model,), + ), + migrations.AddField( + model_name='joboffer', + name='category_new', + field=aldryn_categories.fields.CategoryForeignKey(related_name='job_offers', default=None, to='aldryn_categories.Category', null=True), + preserve_default=True, + ), + migrations.AlterField( + model_name='joboffer', + name='category', + field=models.ForeignKey(related_name='jobs', default=None, verbose_name='Category', to='aldryn_jobs.JobCategory', null=True), + preserve_default=True, + ), + ] diff --git a/aldryn_jobs/migrations/0009_auto_20150403_0611.py b/aldryn_jobs/migrations/0009_auto_20150403_0611.py new file mode 100644 index 0000000..ecc7dc3 --- /dev/null +++ b/aldryn_jobs/migrations/0009_auto_20150403_0611.py @@ -0,0 +1,106 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations +from aldryn_categories.models import Category as NoFrozenCategory + + +def forwards(apps, schema_editor): + "Write your forwards methods here." + # Note: Don't use "from appname.models import ModelName". + # Use orm.ModelName to refer to models in this application, + # and orm['appname.ModelName'] for models in other applications. + Category = apps.get_model('aldryn_categories.Category') + JobCategory = apps.get_model('aldryn_jobs.JobCategory') + JobCategoryOpts = apps.get_model('aldryn_jobs.JobCategoryOpts') + for old_category in JobCategory.objects.all(): + # This is maybe wrong but using the model out of 'orm' (not frozen) + # we can access add_root. Copy all the treebeard category creation + # into migration is a big overhead, but would be the perfect thing + # to do. + en_tr = old_category.translations.get(language_code='en') + new_category = NoFrozenCategory.add_root( + name=en_tr.name, + slug=en_tr.slug, + ) + new_category = Category.objects.get(pk=new_category.pk) + + # When creating default translation parler use as default 'en-us', + # so we fix it here because we use only 'en'. + en_tr = new_category.translations.get() + en_tr.language_code = 'en' + en_tr.save() + + # add other translations, we can't use create_translations + # in migrations. + for tr in old_category.translations.exclude(language_code='en'): + new_category.translations.create( + language_code=tr.language_code, + name=tr.name, + slug=tr.slug, + ) + + for job in old_category.jobs.all(): + job.category_new = new_category + job.category = None + job.save() + + job_opts = JobCategoryOpts.objects.create( + category_id=new_category.pk, + app_config=old_category.app_config, + # ordering isn't migrated since aldryn-categories provide a way + # to order categories already + ) + job_opts.supervisors = old_category.supervisors.all() + job_opts.save() + + old_category.delete() + + +def backwards(apps, schema_editor): + "Write your backwards methods here." + Category = apps.get_model('aldryn_categories.Category') + JobCategory = apps.get_model('aldryn_jobs.JobCategory') + JobCategoryOpts = apps.get_model('aldryn_jobs.JobCategoryOpts') + + for new_category in Category.objects.all(): + job_opt = JobCategoryOpts.objects.get(category=new_category) + # create the old category + old_category = JobCategory.objects.create( + app_config=job_opt.app_config + ) + old_category.supervisors = job_opt.supervisors.all() + + # create default translation + en_tr = new_category.translations.get(language_code='en') + old_category.translations.create( + language_code='en', + name=en_tr.name, + slug=en_tr.slug + ) + for tr in new_category.translations.exclude(language_code='en'): + # create another translations + old_category.translations.create( + language_code=tr.language_code, + name=tr.name, + slug=tr.slug, + ) + + for job in new_category.job_offers.all(): + job.category = old_category + job.category_new = None + job.save() + + old_category.save() + new_category.delete() + + +class Migration(migrations.Migration): + + dependencies = [ + ('aldryn_jobs', '0008_auto_20150403_0611'), + ] + + operations = [ + migrations.RunPython(forwards, backwards) + ] diff --git a/aldryn_jobs/migrations/0010_auto_20150403_0847.py b/aldryn_jobs/migrations/0010_auto_20150403_0847.py new file mode 100644 index 0000000..e5db602 --- /dev/null +++ b/aldryn_jobs/migrations/0010_auto_20150403_0847.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations +import aldryn_categories.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('aldryn_jobs', '0009_auto_20150403_0611'), + ] + + operations = [ + migrations.RemoveField( + model_name='jobcategory', + name='app_config', + ), + migrations.RemoveField( + model_name='jobcategory', + name='supervisors', + ), + migrations.AlterUniqueTogether( + name='jobcategorytranslation', + unique_together=None, + ), + migrations.RemoveField( + model_name='jobcategorytranslation', + name='master', + ), + migrations.DeleteModel( + name='JobCategoryTranslation', + ), + migrations.AlterModelOptions( + name='joboffer', + options={'ordering': ['category', '-created'], 'verbose_name': 'Job offer', 'verbose_name_plural': 'Job offers'}, + ), + migrations.RemoveField( + model_name='joboffer', + name='category', + ), + migrations.RenameField( + model_name='joboffer', + old_name='category_new', + new_name='category' + ), + + migrations.DeleteModel( + name='JobCategory', + ), + ] diff --git a/aldryn_jobs/models.py b/aldryn_jobs/models.py index 7d517b0..f67eb90 100644 --- a/aldryn_jobs/models.py +++ b/aldryn_jobs/models.py @@ -14,10 +14,12 @@ from djangocms_text_ckeditor.fields import HTMLField from aldryn_apphooks_config.models import AppHookConfig +from aldryn_apphooks_config.managers import AppHookConfigManager from aldryn_apphooks_config.managers.parler import ( AppHookConfigTranslatableManager ) - +from aldryn_categories.models import Category +from aldryn_categories.fields import CategoryOneToOneField, CategoryForeignKey from cms.models import CMSPlugin from cms.models.fields import PlaceholderField from cms.utils.i18n import force_language @@ -71,20 +73,11 @@ class JobsConfig(AppHookConfig): pass -class JobCategory(TranslatableModel): - translations = TranslatedFields( - name=models.CharField(_('Name'), max_length=255), - slug=models.SlugField( - _('Slug'), max_length=255, blank=True, - help_text=_('Auto-generated. Used in the URL. If changed, the URL' - ' will change. Clean it to have it re-created.') - ), - meta={'unique_together': [['slug', 'language_code']]} - ) - +class JobCategoryOpts(models.Model): + category = CategoryOneToOneField(Category, related_name='jobs_opts') supervisors = models.ManyToManyField( get_user_model_for_fields(), verbose_name=_('Supervisors'), - related_name='job_offer_categories', + related_name='job_categories_opts', help_text=_('Those people will be notified via e-mail when new ' 'application arrives.'), blank=True @@ -93,21 +86,19 @@ class JobCategory(TranslatableModel): JobsConfig, verbose_name=_('app_config'), null=True ) - ordering = models.IntegerField(_('Ordering'), default=0) - - objects = AppHookConfigTranslatableManager() + objects = AppHookConfigManager() class Meta: - verbose_name = _('Job category') - verbose_name_plural = _('Job categories') - ordering = ['ordering'] + verbose_name = _('Job category opts') + verbose_name_plural = _('Job categories opts') def __unicode__(self): - return self.safe_translation_getter('name', str(self.pk)) + return self.category.safe_translation_getter('name', str(self.pk)) def get_absolute_url(self, language=None): - language = language or self.get_current_language() - slug = self.safe_translation_getter('slug', language_code=language) + language = language or self.category.get_current_language() + slug = self.category.safe_translation_getter('slug', + language_code=language) if self.app_config_id: namespace = self.app_config.namespace else: @@ -145,8 +136,9 @@ class JobOffer(TranslatableModel): ) content = PlaceholderField('Job Offer Content') - category = models.ForeignKey( - JobCategory, verbose_name=_('Category'), related_name='jobs' + category = CategoryForeignKey( + Category, related_name='job_offers', + null=False ) created = models.DateTimeField(auto_now_add=True) is_active = models.BooleanField(_('Active'), default=True) @@ -168,7 +160,7 @@ class JobOffer(TranslatableModel): class Meta: verbose_name = _('Job offer') verbose_name_plural = _('Job offers') - ordering = ['category__ordering', 'category', '-created'] + ordering = ['category', '-created'] def __unicode__(self): return self.safe_translation_getter('title', str(self.pk)) @@ -210,7 +202,7 @@ def get_active(self): ]) def get_notification_emails(self): - return self.category.get_notification_emails() + return self.category.jobs_opts.get_notification_emails() class JobApplication(models.Model): @@ -407,11 +399,12 @@ def __str__(self): @property def categories(self): return ( - JobCategory.objects - .namespace(self.app_config.namespace) - .filter(jobs=True) - .annotate(count=models.Count('jobs')) - .order_by('ordering', '-count', 'translations__name') + Category.objects + .filter( + jobs_opts__app_config__namespace=self.app_config.namespace, # NOQA + job_offers=True + ) + .annotate(count=models.Count('job_offers')) ) diff --git a/aldryn_jobs/south_migrations/0026_auto__del_jobcategorytranslation__del_unique_jobcategorytranslation_sl.py b/aldryn_jobs/south_migrations/0026_auto__del_jobcategorytranslation__del_unique_jobcategorytranslation_sl.py new file mode 100644 index 0000000..9c29d2a --- /dev/null +++ b/aldryn_jobs/south_migrations/0026_auto__del_jobcategorytranslation__del_unique_jobcategorytranslation_sl.py @@ -0,0 +1,233 @@ +# -*- coding: utf-8 -*- +from south.utils import datetime_utils as datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + + +class Migration(SchemaMigration): + + depends_on = ( + ('aldryn_categories', '0002_auto__add_unique_categorytranslation_language_code_slug'), + ) + + def forwards(self, orm): + # Adding model 'JobCategoryOpts' + db.create_table(u'aldryn_jobs_jobcategoryopts', ( + (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('category', self.gf('aldryn_categories.fields.CategoryOneToOneField')(related_name='jobs_opts', unique=True, to=orm['aldryn_categories.Category'])), + ('app_config', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['aldryn_jobs.JobsConfig'], null=True)), + )) + db.send_create_signal(u'aldryn_jobs', ['JobCategoryOpts']) + + # Adding M2M table for field supervisors on 'JobCategoryOpts' + m2m_table_name = db.shorten_name(u'aldryn_jobs_jobcategoryopts_supervisors') + db.create_table(m2m_table_name, ( + ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)), + ('jobcategoryopts', models.ForeignKey(orm[u'aldryn_jobs.jobcategoryopts'], null=False)), + ('user', models.ForeignKey(orm[u'auth.user'], null=False)) + )) + db.create_unique(m2m_table_name, ['jobcategoryopts_id', 'user_id']) + + # Adding field 'JobOffer.category_new' + db.add_column(u'aldryn_jobs_joboffer', 'category_new', + self.gf('aldryn_categories.fields.CategoryForeignKey')(default=None, related_name='job_offers', null=True, to=orm['aldryn_categories.Category']), + keep_default=False) + + + # Changing field 'JobOffer.category' + db.alter_column(u'aldryn_jobs_joboffer', 'category_id', self.gf('django.db.models.fields.related.ForeignKey')(null=True, to=orm['aldryn_jobs.JobCategory'])) + + def backwards(self, orm): + # Deleting model 'JobCategoryOpts' + db.delete_table(u'aldryn_jobs_jobcategoryopts') + + # Removing M2M table for field supervisors on 'JobCategoryOpts' + db.delete_table(db.shorten_name(u'aldryn_jobs_jobcategoryopts_supervisors')) + + # Deleting field 'JobOffer.category_new' + db.delete_column(u'aldryn_jobs_joboffer', 'category_new_id') + + # Changing field 'JobOffer.category' + db.alter_column(u'aldryn_jobs_joboffer', 'category_id', self.gf('django.db.models.fields.related.ForeignKey')(default=None, to=orm['aldryn_jobs.JobCategory'])) + + models = { + u'aldryn_categories.category': { + 'Meta': {'object_name': 'Category'}, + 'depth': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'lft': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), + 'rgt': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), + 'tree_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}) + }, + u'aldryn_categories.categorytranslation': { + 'Meta': {'unique_together': "[(u'language_code', u'slug'), (u'language_code', u'master')]", 'object_name': 'CategoryTranslation', 'db_table': "u'aldryn_categories_category_translation'"}, + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'language_code': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}), + u'master': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'translations'", 'null': 'True', 'to': u"orm['aldryn_categories.Category']"}), + 'name': ('django.db.models.fields.CharField', [], {'default': "u''", 'max_length': '255'}), + 'slug': ('django.db.models.fields.SlugField', [], {'default': "u''", 'max_length': '255', 'blank': 'True'}) + }, + u'aldryn_jobs.jobapplication': { + 'Meta': {'ordering': "['-created']", 'object_name': 'JobApplication'}, + 'app_config': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['aldryn_jobs.JobsConfig']", 'null': 'True'}), + 'cover_letter': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), + 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '20'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_rejected': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'job_offer': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['aldryn_jobs.JobOffer']"}), + 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '20'}), + 'rejection_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), + 'salutation': ('django.db.models.fields.CharField', [], {'default': "'male'", 'max_length': '20', 'blank': 'True'}) + }, + u'aldryn_jobs.jobapplicationattachment': { + 'Meta': {'object_name': 'JobApplicationAttachment'}, + 'application': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'attachments'", 'to': u"orm['aldryn_jobs.JobApplication']"}), + 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + }, + u'aldryn_jobs.jobcategoriesplugin': { + 'Meta': {'object_name': 'JobCategoriesPlugin'}, + 'app_config': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['aldryn_jobs.JobsConfig']", 'null': 'True'}), + u'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}) + }, + u'aldryn_jobs.jobcategory': { + 'Meta': {'ordering': "['ordering']", 'object_name': 'JobCategory'}, + 'app_config': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['aldryn_jobs.JobsConfig']", 'null': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'ordering': ('django.db.models.fields.IntegerField', [], {'default': '0'}), + 'supervisors': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'job_offer_categories'", 'blank': 'True', 'to': u"orm['auth.User']"}) + }, + u'aldryn_jobs.jobcategoryopts': { + 'Meta': {'object_name': 'JobCategoryOpts'}, + 'app_config': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['aldryn_jobs.JobsConfig']", 'null': 'True'}), + 'category': ('aldryn_categories.fields.CategoryOneToOneField', [], {'related_name': "'jobs_opts'", 'unique': 'True', 'to': u"orm['aldryn_categories.Category']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'supervisors': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'job_categories_opts'", 'blank': 'True', 'to': u"orm['auth.User']"}) + }, + u'aldryn_jobs.jobcategorytranslation': { + 'Meta': {'unique_together': "[['slug', 'language_code'], (u'language_code', u'master')]", 'object_name': 'JobCategoryTranslation', 'db_table': "u'aldryn_jobs_jobcategory_translation'"}, + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'language_code': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}), + u'master': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'translations'", 'null': 'True', 'to': u"orm['aldryn_jobs.JobCategory']"}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '255', 'blank': 'True'}) + }, + u'aldryn_jobs.joblistplugin': { + 'Meta': {'object_name': 'JobListPlugin'}, + 'app_config': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['aldryn_jobs.JobsConfig']", 'null': 'True'}), + u'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}), + 'joboffers': ('sortedm2m.fields.SortedManyToManyField', [], {'symmetrical': 'False', 'to': u"orm['aldryn_jobs.JobOffer']", 'null': 'True', 'blank': 'True'}) + }, + u'aldryn_jobs.jobnewsletterregistrationplugin': { + 'Meta': {'object_name': 'JobNewsletterRegistrationPlugin', '_ormbases': ['cms.CMSPlugin']}, + u'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}), + 'mail_to_group': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Group']", 'symmetrical': 'False'}) + }, + u'aldryn_jobs.joboffer': { + 'Meta': {'ordering': "['category__ordering', 'category', '-created']", 'object_name': 'JobOffer'}, + 'app_config': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['aldryn_jobs.JobsConfig']", 'null': 'True'}), + 'can_apply': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'category': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'related_name': "'jobs'", 'null': 'True', 'to': u"orm['aldryn_jobs.JobCategory']"}), + 'category_new': ('aldryn_categories.fields.CategoryForeignKey', [], {'default': 'None', 'related_name': "'job_offers'", 'null': 'True', 'to': u"orm['aldryn_categories.Category']"}), + 'content': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.Placeholder']", 'null': 'True'}), + 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'publication_end': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), + 'publication_start': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}) + }, + u'aldryn_jobs.joboffertranslation': { + 'Meta': {'unique_together': "[['slug', 'language_code'], (u'language_code', u'master')]", 'object_name': 'JobOfferTranslation', 'db_table': "u'aldryn_jobs_joboffer_translation'"}, + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'language_code': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}), + 'lead_in': ('djangocms_text_ckeditor.fields.HTMLField', [], {'blank': 'True'}), + u'master': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'translations'", 'null': 'True', 'to': u"orm['aldryn_jobs.JobOffer']"}), + 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '255', 'blank': 'True'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + u'aldryn_jobs.jobsconfig': { + 'Meta': {'unique_together': "(('type', 'namespace'),)", 'object_name': 'JobsConfig'}, + 'app_data': ('app_data.fields.AppDataField', [], {'default': "'{}'"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'namespace': ('django.db.models.fields.CharField', [], {'default': 'None', 'max_length': '100'}), + 'type': ('django.db.models.fields.CharField', [], {'max_length': '100'}) + }, + u'aldryn_jobs.newslettersignup': { + 'Meta': {'object_name': 'NewsletterSignup'}, + 'confirmation_key': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '40'}), + 'default_language': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '32', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_disabled': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_verified': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'recipient': ('django.db.models.fields.EmailField', [], {'unique': 'True', 'max_length': '75'}), + 'signup_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}) + }, + u'aldryn_jobs.newslettersignupuser': { + 'Meta': {'object_name': 'NewsletterSignupUser'}, + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'signup': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'related_user'", 'to': u"orm['aldryn_jobs.NewsletterSignup']"}), + 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'newsletter_signup'", 'to': u"orm['auth.User']"}) + }, + u'auth.group': { + 'Meta': {'object_name': 'Group'}, + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), + 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) + }, + u'auth.permission': { + 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'}, + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + u'auth.user': { + 'Meta': {'object_name': 'User'}, + 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), + 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), + 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Group']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), + 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), + 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Permission']"}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + 'cms.cmsplugin': { + 'Meta': {'object_name': 'CMSPlugin'}, + 'changed_date': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), + 'creation_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'language': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}), + 'level': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), + 'lft': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), + 'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.CMSPlugin']", 'null': 'True', 'blank': 'True'}), + 'placeholder': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.Placeholder']", 'null': 'True'}), + 'plugin_type': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}), + 'position': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True', 'blank': 'True'}), + 'rght': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), + 'tree_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}) + }, + 'cms.placeholder': { + 'Meta': {'object_name': 'Placeholder'}, + 'default_width': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'slot': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}) + }, + u'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) + } + } + + complete_apps = ['aldryn_categories', 'aldryn_jobs'] diff --git a/aldryn_jobs/south_migrations/0027_data__migrate_jobcategory_to_aldryn_categories.py b/aldryn_jobs/south_migrations/0027_data__migrate_jobcategory_to_aldryn_categories.py new file mode 100644 index 0000000..e839194 --- /dev/null +++ b/aldryn_jobs/south_migrations/0027_data__migrate_jobcategory_to_aldryn_categories.py @@ -0,0 +1,277 @@ +# -*- coding: utf-8 -*- +from south.utils import datetime_utils as datetime +from south.db import db +from south.v2 import DataMigration +from django.db import models +from aldryn_categories.models import Category as NoFrozenCategory + + +class Migration(DataMigration): + + def forwards(self, orm): + "Write your forwards methods here." + # Note: Don't use "from appname.models import ModelName". + # Use orm.ModelName to refer to models in this application, + # and orm['appname.ModelName'] for models in other applications. + Category = orm['aldryn_categories.Category'] + JobCategory = orm.JobCategory + JobCategoryOpts = orm.JobCategoryOpts + for old_category in JobCategory.objects.all(): + # This is maybe wrong but using the model out of 'orm' (not frozen) + # we can access add_root. Copy all the treebeard category creation + # into migration is a big overhead, but would be the perfect thing + # to do. + en_tr = old_category.translations.get(language_code='en') + new_category = NoFrozenCategory.add_root( + name=en_tr.name, + slug=en_tr.slug, + ) + new_category = Category.objects.get(pk=new_category.pk) + + # When creating default translation parler use as default 'en-us', + # so we fix it here because we use only 'en'. + en_tr = new_category.translations.get() + en_tr.language_code = 'en' + en_tr.save() + + # add other translations, we can't use create_translations + # in migrations. + for tr in old_category.translations.exclude(language_code='en'): + new_category.translations.create( + language_code=tr.language_code, + name=tr.name, + slug=tr.slug, + ) + + for job in old_category.jobs.all(): + job.category_new = new_category + job.category = None + job.save() + + job_opts = JobCategoryOpts.objects.create( + category_id=new_category.pk, + app_config=old_category.app_config, + # ordering isn't migrated since aldryn-categories provide a way + # to order categories already + ) + job_opts.supervisors = old_category.supervisors.all() + job_opts.save() + + old_category.delete() + + def backwards(self, orm): + "Write your backwards methods here." + Category = orm['aldryn_categories.Category'] + JobCategory = orm.JobCategory + + for new_category in Category.objects.all(): + # create the old category + old_category = JobCategory.objects.create( + app_config=new_category.jobs_opts.app_config + ) + old_category.supervisors = new_category.jobs_opts.supervisors.all() + + # create default translation + en_tr = new_category.translations.get(language_code='en') + old_category.translations.create( + language_code='en', + name=en_tr.name, + slug=en_tr.slug + ) + for tr in new_category.translations.exclude(language_code='en'): + # create another translations + old_category.translations.create( + language_code=tr.language_code, + name=tr.name, + slug=tr.slug, + ) + + for job in new_category.job_offers.all(): + job.category = old_category + job.category_new = None + job.save() + + old_category.save() + new_category.delete() + + models = { + u'aldryn_categories.category': { + 'Meta': {'object_name': 'Category'}, + 'depth': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'lft': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), + 'rgt': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), + 'tree_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}) + }, + u'aldryn_categories.categorytranslation': { + 'Meta': {'unique_together': "[(u'language_code', u'slug'), (u'language_code', u'master')]", 'object_name': 'CategoryTranslation', 'db_table': "u'aldryn_categories_category_translation'"}, + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'language_code': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}), + u'master': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'translations'", 'null': 'True', 'to': u"orm['aldryn_categories.Category']"}), + 'name': ('django.db.models.fields.CharField', [], {'default': "u''", 'max_length': '255'}), + 'slug': ('django.db.models.fields.SlugField', [], {'default': "u''", 'max_length': '255', 'blank': 'True'}) + }, + u'aldryn_jobs.jobapplication': { + 'Meta': {'ordering': "['-created']", 'object_name': 'JobApplication'}, + 'app_config': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['aldryn_jobs.JobsConfig']", 'null': 'True'}), + 'cover_letter': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), + 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '20'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_rejected': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'job_offer': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['aldryn_jobs.JobOffer']"}), + 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '20'}), + 'rejection_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), + 'salutation': ('django.db.models.fields.CharField', [], {'default': "'male'", 'max_length': '20', 'blank': 'True'}) + }, + u'aldryn_jobs.jobapplicationattachment': { + 'Meta': {'object_name': 'JobApplicationAttachment'}, + 'application': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'attachments'", 'to': u"orm['aldryn_jobs.JobApplication']"}), + 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + }, + u'aldryn_jobs.jobcategoriesplugin': { + 'Meta': {'object_name': 'JobCategoriesPlugin'}, + 'app_config': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['aldryn_jobs.JobsConfig']", 'null': 'True'}), + u'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}) + }, + u'aldryn_jobs.jobcategory': { + 'Meta': {'ordering': "['ordering']", 'object_name': 'JobCategory'}, + 'app_config': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['aldryn_jobs.JobsConfig']", 'null': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'ordering': ('django.db.models.fields.IntegerField', [], {'default': '0'}), + 'supervisors': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'job_offer_categories'", 'blank': 'True', 'to': u"orm['auth.User']"}) + }, + u'aldryn_jobs.jobcategoryopts': { + 'Meta': {'object_name': 'JobCategoryOpts'}, + 'app_config': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['aldryn_jobs.JobsConfig']", 'null': 'True'}), + 'category': ('aldryn_categories.fields.CategoryOneToOneField', [], {'related_name': "'jobs_opts'", 'unique': 'True', 'to': u"orm['aldryn_categories.Category']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'supervisors': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'job_categories_opts'", 'blank': 'True', 'to': u"orm['auth.User']"}) + }, + u'aldryn_jobs.jobcategorytranslation': { + 'Meta': {'unique_together': "[['slug', 'language_code'], (u'language_code', u'master')]", 'object_name': 'JobCategoryTranslation', 'db_table': "u'aldryn_jobs_jobcategory_translation'"}, + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'language_code': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}), + u'master': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'translations'", 'null': 'True', 'to': u"orm['aldryn_jobs.JobCategory']"}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '255', 'blank': 'True'}) + }, + u'aldryn_jobs.joblistplugin': { + 'Meta': {'object_name': 'JobListPlugin'}, + 'app_config': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['aldryn_jobs.JobsConfig']", 'null': 'True'}), + u'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}), + 'joboffers': ('sortedm2m.fields.SortedManyToManyField', [], {'symmetrical': 'False', 'to': u"orm['aldryn_jobs.JobOffer']", 'null': 'True', 'blank': 'True'}) + }, + u'aldryn_jobs.jobnewsletterregistrationplugin': { + 'Meta': {'object_name': 'JobNewsletterRegistrationPlugin', '_ormbases': ['cms.CMSPlugin']}, + u'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}), + 'mail_to_group': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Group']", 'symmetrical': 'False'}) + }, + u'aldryn_jobs.joboffer': { + 'Meta': {'ordering': "['category__ordering', 'category', '-created']", 'object_name': 'JobOffer'}, + 'app_config': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['aldryn_jobs.JobsConfig']", 'null': 'True'}), + 'can_apply': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'category': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'related_name': "'jobs'", 'null': 'True', 'to': u"orm['aldryn_jobs.JobCategory']"}), + 'category_new': ('aldryn_categories.fields.CategoryForeignKey', [], {'default': 'None', 'related_name': "'job_offers'", 'null': 'True', 'to': u"orm['aldryn_categories.Category']"}), + 'content': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.Placeholder']", 'null': 'True'}), + 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'publication_end': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), + 'publication_start': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}) + }, + u'aldryn_jobs.joboffertranslation': { + 'Meta': {'unique_together': "[['slug', 'language_code'], (u'language_code', u'master')]", 'object_name': 'JobOfferTranslation', 'db_table': "u'aldryn_jobs_joboffer_translation'"}, + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'language_code': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}), + 'lead_in': ('djangocms_text_ckeditor.fields.HTMLField', [], {'blank': 'True'}), + u'master': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'translations'", 'null': 'True', 'to': u"orm['aldryn_jobs.JobOffer']"}), + 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '255', 'blank': 'True'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + u'aldryn_jobs.jobsconfig': { + 'Meta': {'unique_together': "(('type', 'namespace'),)", 'object_name': 'JobsConfig'}, + 'app_data': ('app_data.fields.AppDataField', [], {'default': "'{}'"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'namespace': ('django.db.models.fields.CharField', [], {'default': 'None', 'max_length': '100'}), + 'type': ('django.db.models.fields.CharField', [], {'max_length': '100'}) + }, + u'aldryn_jobs.newslettersignup': { + 'Meta': {'object_name': 'NewsletterSignup'}, + 'confirmation_key': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '40'}), + 'default_language': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '32', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_disabled': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_verified': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'recipient': ('django.db.models.fields.EmailField', [], {'unique': 'True', 'max_length': '75'}), + 'signup_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}) + }, + u'aldryn_jobs.newslettersignupuser': { + 'Meta': {'object_name': 'NewsletterSignupUser'}, + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'signup': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'related_user'", 'to': u"orm['aldryn_jobs.NewsletterSignup']"}), + 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'newsletter_signup'", 'to': u"orm['auth.User']"}) + }, + u'auth.group': { + 'Meta': {'object_name': 'Group'}, + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), + 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) + }, + u'auth.permission': { + 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'}, + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + u'auth.user': { + 'Meta': {'object_name': 'User'}, + 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), + 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), + 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Group']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), + 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), + 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Permission']"}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + 'cms.cmsplugin': { + 'Meta': {'object_name': 'CMSPlugin'}, + 'changed_date': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), + 'creation_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'language': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}), + 'level': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), + 'lft': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), + 'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.CMSPlugin']", 'null': 'True', 'blank': 'True'}), + 'placeholder': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.Placeholder']", 'null': 'True'}), + 'plugin_type': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}), + 'position': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True', 'blank': 'True'}), + 'rght': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), + 'tree_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}) + }, + 'cms.placeholder': { + 'Meta': {'object_name': 'Placeholder'}, + 'default_width': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'slot': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}) + }, + u'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) + } + } + + complete_apps = ['aldryn_categories', 'aldryn_jobs'] + symmetrical = True diff --git a/aldryn_jobs/south_migrations/0028_auto__del_jobcategorytranslation__del_unique_jobcategorytranslation_sl.py b/aldryn_jobs/south_migrations/0028_auto__del_jobcategorytranslation__del_unique_jobcategorytranslation_sl.py new file mode 100644 index 0000000..f9f7875 --- /dev/null +++ b/aldryn_jobs/south_migrations/0028_auto__del_jobcategorytranslation__del_unique_jobcategorytranslation_sl.py @@ -0,0 +1,236 @@ +# -*- coding: utf-8 -*- +from south.utils import datetime_utils as datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + + +class Migration(SchemaMigration): + + def forwards(self, orm): + # Removing unique constraint on 'JobCategoryTranslation', fields ['language_code', u'master'] + db.delete_unique(u'aldryn_jobs_jobcategory_translation', ['language_code', u'master_id']) + + # Removing unique constraint on 'JobCategoryTranslation', fields ['slug', 'language_code'] + db.delete_unique(u'aldryn_jobs_jobcategory_translation', ['slug', 'language_code']) + + # Deleting model 'JobCategoryTranslation' + db.delete_table(u'aldryn_jobs_jobcategory_translation') + + # Deleting model 'JobCategory' + db.delete_table(u'aldryn_jobs_jobcategory') + + # Removing M2M table for field supervisors on 'JobCategory' + db.delete_table(db.shorten_name(u'aldryn_jobs_jobcategory_supervisors')) + + # Deleting field 'JobOffer.category' + db.delete_column(u'aldryn_jobs_joboffer', 'category_id') + + # Rename field 'JobOffer.category_new' to 'JobOffer.category' + db.rename_column('aldryn_jobs_joboffer', 'category_new_id', 'category_id') + + def backwards(self, orm): + # Adding model 'JobCategoryTranslation' + db.create_table(u'aldryn_jobs_jobcategory_translation', ( + ('name', self.gf('django.db.models.fields.CharField')(max_length=255)), + (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + (u'master', self.gf('django.db.models.fields.related.ForeignKey')(related_name='translations', null=True, to=orm['aldryn_jobs.JobCategory'])), + ('language_code', self.gf('django.db.models.fields.CharField')(max_length=15, db_index=True)), + ('slug', self.gf('django.db.models.fields.SlugField')(max_length=255, blank=True)), + )) + db.send_create_signal(u'aldryn_jobs', ['JobCategoryTranslation']) + + # Adding unique constraint on 'JobCategoryTranslation', fields ['slug', 'language_code'] + db.create_unique(u'aldryn_jobs_jobcategory_translation', ['slug', 'language_code']) + + # Adding unique constraint on 'JobCategoryTranslation', fields ['language_code', u'master'] + db.create_unique(u'aldryn_jobs_jobcategory_translation', ['language_code', u'master_id']) + + # Adding model 'JobCategory' + db.create_table(u'aldryn_jobs_jobcategory', ( + ('ordering', self.gf('django.db.models.fields.IntegerField')(default=0)), + ('app_config', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['aldryn_jobs.JobsConfig'], null=True)), + (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + )) + db.send_create_signal(u'aldryn_jobs', ['JobCategory']) + + # Adding M2M table for field supervisors on 'JobCategory' + m2m_table_name = db.shorten_name(u'aldryn_jobs_jobcategory_supervisors') + db.create_table(m2m_table_name, ( + ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)), + ('jobcategory', models.ForeignKey(orm[u'aldryn_jobs.jobcategory'], null=False)), + ('user', models.ForeignKey(orm[u'auth.user'], null=False)) + )) + db.create_unique(m2m_table_name, ['jobcategory_id', 'user_id']) + + # Rename field 'JobOffer.category' to 'JobOffer.category_new' + db.rename_column('aldryn_jobs_joboffer', 'category_id', 'category_new_id') + + # Add old category field + db.add_column('aldryn_jobs_joboffer', 'category', + self.gf('django.db.models.fields.related.ForeignKey')(related_name='jobs', null=True, to=orm['aldryn_jobs.JobCategory'])) + + models = { + u'aldryn_categories.category': { + 'Meta': {'object_name': 'Category'}, + 'depth': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'lft': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), + 'rgt': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), + 'tree_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}) + }, + u'aldryn_categories.categorytranslation': { + 'Meta': {'unique_together': "[(u'language_code', u'slug'), (u'language_code', u'master')]", 'object_name': 'CategoryTranslation', 'db_table': "u'aldryn_categories_category_translation'"}, + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'language_code': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}), + u'master': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'translations'", 'null': 'True', 'to': u"orm['aldryn_categories.Category']"}), + 'name': ('django.db.models.fields.CharField', [], {'default': "u''", 'max_length': '255'}), + 'slug': ('django.db.models.fields.SlugField', [], {'default': "u''", 'max_length': '255', 'blank': 'True'}) + }, + u'aldryn_jobs.jobapplication': { + 'Meta': {'ordering': "['-created']", 'object_name': 'JobApplication'}, + 'app_config': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['aldryn_jobs.JobsConfig']", 'null': 'True'}), + 'cover_letter': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), + 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '20'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_rejected': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'job_offer': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['aldryn_jobs.JobOffer']"}), + 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '20'}), + 'rejection_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), + 'salutation': ('django.db.models.fields.CharField', [], {'default': "'male'", 'max_length': '20', 'blank': 'True'}) + }, + u'aldryn_jobs.jobapplicationattachment': { + 'Meta': {'object_name': 'JobApplicationAttachment'}, + 'application': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'attachments'", 'to': u"orm['aldryn_jobs.JobApplication']"}), + 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + }, + u'aldryn_jobs.jobcategoriesplugin': { + 'Meta': {'object_name': 'JobCategoriesPlugin'}, + 'app_config': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['aldryn_jobs.JobsConfig']", 'null': 'True'}), + u'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}) + }, + u'aldryn_jobs.jobcategoryopts': { + 'Meta': {'object_name': 'JobCategoryOpts'}, + 'app_config': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['aldryn_jobs.JobsConfig']", 'null': 'True'}), + 'category': ('aldryn_categories.fields.CategoryOneToOneField', [], {'related_name': "'jobs_opts'", 'unique': 'True', 'to': u"orm['aldryn_categories.Category']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'supervisors': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'job_categories_opts'", 'blank': 'True', 'to': u"orm['auth.User']"}) + }, + u'aldryn_jobs.joblistplugin': { + 'Meta': {'object_name': 'JobListPlugin'}, + 'app_config': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['aldryn_jobs.JobsConfig']", 'null': 'True'}), + u'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}), + 'joboffers': ('sortedm2m.fields.SortedManyToManyField', [], {'symmetrical': 'False', 'to': u"orm['aldryn_jobs.JobOffer']", 'null': 'True', 'blank': 'True'}) + }, + u'aldryn_jobs.jobnewsletterregistrationplugin': { + 'Meta': {'object_name': 'JobNewsletterRegistrationPlugin', '_ormbases': ['cms.CMSPlugin']}, + u'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}), + 'mail_to_group': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Group']", 'symmetrical': 'False'}) + }, + u'aldryn_jobs.joboffer': { + 'Meta': {'ordering': "['category', '-created']", 'object_name': 'JobOffer'}, + 'app_config': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['aldryn_jobs.JobsConfig']", 'null': 'True'}), + 'can_apply': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'category': ('aldryn_categories.fields.CategoryForeignKey', [], {'related_name': "'job_offers'", 'to': u"orm['aldryn_categories.Category']"}), + 'content': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.Placeholder']", 'null': 'True'}), + 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'publication_end': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), + 'publication_start': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}) + }, + u'aldryn_jobs.joboffertranslation': { + 'Meta': {'unique_together': "[['slug', 'language_code'], (u'language_code', u'master')]", 'object_name': 'JobOfferTranslation', 'db_table': "u'aldryn_jobs_joboffer_translation'"}, + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'language_code': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}), + 'lead_in': ('djangocms_text_ckeditor.fields.HTMLField', [], {'blank': 'True'}), + u'master': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'translations'", 'null': 'True', 'to': u"orm['aldryn_jobs.JobOffer']"}), + 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '255', 'blank': 'True'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + u'aldryn_jobs.jobsconfig': { + 'Meta': {'unique_together': "(('type', 'namespace'),)", 'object_name': 'JobsConfig'}, + 'app_data': ('app_data.fields.AppDataField', [], {'default': "'{}'"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'namespace': ('django.db.models.fields.CharField', [], {'default': 'None', 'max_length': '100'}), + 'type': ('django.db.models.fields.CharField', [], {'max_length': '100'}) + }, + u'aldryn_jobs.newslettersignup': { + 'Meta': {'object_name': 'NewsletterSignup'}, + 'confirmation_key': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '40'}), + 'default_language': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '32', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_disabled': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_verified': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'recipient': ('django.db.models.fields.EmailField', [], {'unique': 'True', 'max_length': '75'}), + 'signup_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}) + }, + u'aldryn_jobs.newslettersignupuser': { + 'Meta': {'object_name': 'NewsletterSignupUser'}, + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'signup': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'related_user'", 'to': u"orm['aldryn_jobs.NewsletterSignup']"}), + 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'newsletter_signup'", 'to': u"orm['auth.User']"}) + }, + u'auth.group': { + 'Meta': {'object_name': 'Group'}, + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), + 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) + }, + u'auth.permission': { + 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'}, + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + u'auth.user': { + 'Meta': {'object_name': 'User'}, + 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), + 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), + 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Group']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), + 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), + 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Permission']"}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + 'cms.cmsplugin': { + 'Meta': {'object_name': 'CMSPlugin'}, + 'changed_date': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), + 'creation_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'language': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}), + 'level': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), + 'lft': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), + 'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.CMSPlugin']", 'null': 'True', 'blank': 'True'}), + 'placeholder': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.Placeholder']", 'null': 'True'}), + 'plugin_type': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}), + 'position': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True', 'blank': 'True'}), + 'rght': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), + 'tree_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}) + }, + 'cms.placeholder': { + 'Meta': {'object_name': 'Placeholder'}, + 'default_width': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'slot': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}) + }, + u'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) + } + } + + complete_apps = ['aldryn_categories', 'aldryn_jobs'] diff --git a/aldryn_jobs/views.py b/aldryn_jobs/views.py index 3feb9ad..68b741d 100644 --- a/aldryn_jobs/views.py +++ b/aldryn_jobs/views.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from aldryn_apphooks_config.mixins import AppConfigMixin from aldryn_apphooks_config.utils import get_app_instance - +from aldryn_categories.models import Category from django.conf import settings from django.contrib import messages from django.core.urlresolvers import reverse @@ -27,7 +27,7 @@ NewsletterUnsubscriptionForm, NewsletterResendConfirmationForm ) from .models import ( - JobCategory, JobOffer, NewsletterSignup, JobNewsletterRegistrationPlugin, + JobOffer, NewsletterSignup, JobNewsletterRegistrationPlugin, NewsletterSignupUser, ) @@ -54,16 +54,17 @@ class CategoryJobOfferList(JobOfferList): def get_queryset(self): qs = super(CategoryJobOfferList, self).get_queryset() language = get_language_from_request(self.request) - category_slug = self.kwargs['category_slug'] try: self.category = ( - JobCategory.objects.language(language) - .translated(language, slug=category_slug) - .namespace(self.namespace) - .get() + Category.objects + .language(language) + .translated(language, slug=category_slug) + .filter( + jobs_opts__app_config__namespace=self.namespace + ).get() ) - except JobCategory.DoesNotExist: + except Category.DoesNotExist: raise Http404 self.set_language_changer(category=self.category) @@ -71,7 +72,7 @@ def get_queryset(self): def set_language_changer(self, category): """Translate the slug while changing the language.""" - set_language_changer(self.request, category.get_absolute_url) + set_language_changer(self.request, category.jobs_opts.get_absolute_url) class JobOfferDetail(AppConfigMixin, DetailView): From ab775424e7d29558536056ae234166b0d04c1e29 Mon Sep 17 00:00:00 2001 From: Felipe Prenholato Date: Tue, 7 Apr 2015 08:23:52 -0300 Subject: [PATCH 2/3] Few fixes all around aldryn-jobs --- ...n_newslettersignup_newslettersignupuser.py | 1 - .../migrations/0007_auto_20150330_0545.py | 1 - aldryn_jobs/models.py | 2 +- aldryn_jobs/sitemaps/sitemap.py | 6 ++-- aldryn_jobs/tests.py | 13 ++++---- runtests.py | 3 -- setup.py | 9 +++--- test_settings.py | 7 ++-- tox.ini | 32 +++++++++---------- 9 files changed, 36 insertions(+), 38 deletions(-) diff --git a/aldryn_jobs/migrations/0005_jobnewsletterregistrationplugin_newslettersignup_newslettersignupuser.py b/aldryn_jobs/migrations/0005_jobnewsletterregistrationplugin_newslettersignup_newslettersignupuser.py index 01c79a6..920c55a 100644 --- a/aldryn_jobs/migrations/0005_jobnewsletterregistrationplugin_newslettersignup_newslettersignupuser.py +++ b/aldryn_jobs/migrations/0005_jobnewsletterregistrationplugin_newslettersignup_newslettersignupuser.py @@ -9,7 +9,6 @@ class Migration(migrations.Migration): dependencies = [ ('auth', '0001_initial'), - ('cms', '0004_auto_20150309_1408'), migrations.swappable_dependency(settings.AUTH_USER_MODEL), ('aldryn_jobs', '0004_data_create_default_namespace_20150210_1211'), ] diff --git a/aldryn_jobs/migrations/0007_auto_20150330_0545.py b/aldryn_jobs/migrations/0007_auto_20150330_0545.py index f63cef6..37235ec 100644 --- a/aldryn_jobs/migrations/0007_auto_20150330_0545.py +++ b/aldryn_jobs/migrations/0007_auto_20150330_0545.py @@ -8,7 +8,6 @@ class Migration(migrations.Migration): dependencies = [ - ('cms', '0004_auto_20150309_1408'), ('aldryn_jobs', '0006_auto_20150330_0111'), ] diff --git a/aldryn_jobs/models.py b/aldryn_jobs/models.py index f67eb90..0116835 100644 --- a/aldryn_jobs/models.py +++ b/aldryn_jobs/models.py @@ -179,7 +179,7 @@ def get_absolute_url(self, language=None): try: # FIXME: does not looks correct return category url here if not slug: - return self.category.get_absolute_url(language=language) + return self.category.jobs_opts.get_absolute_url(language) kwargs = { 'category_slug': category_slug, 'job_offer_slug': slug, diff --git a/aldryn_jobs/sitemaps/sitemap.py b/aldryn_jobs/sitemaps/sitemap.py index da329c9..0ab231e 100644 --- a/aldryn_jobs/sitemaps/sitemap.py +++ b/aldryn_jobs/sitemaps/sitemap.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- +from aldryn_categories.models import Category from django.contrib.sitemaps import Sitemap - -from ..models import JobCategory, JobOffer +from ..models import JobOffer class JobOfferCategoriesSitemap(Sitemap): @@ -9,7 +9,7 @@ class JobOfferCategoriesSitemap(Sitemap): priority = 0.5 def items(self): - return JobCategory.objects.all() + return Category.objects.all() class JobOfferSitemap(Sitemap): diff --git a/aldryn_jobs/tests.py b/aldryn_jobs/tests.py index 67f659a..50421fe 100644 --- a/aldryn_jobs/tests.py +++ b/aldryn_jobs/tests.py @@ -1,13 +1,14 @@ from django.conf import settings from django.contrib.auth.models import User +from django.template.defaultfilters import slugify from django.test import TestCase - from cms import api from cms.utils import get_cms_setting from cms.test_utils.testcases import BaseCMSTestCase +from aldryn_categories.models import Category from .cms_plugins import JobList -from .models import JobCategory, JobOffer +from .models import JobOffer class JobsAddTest(TestCase, BaseCMSTestCase): @@ -23,17 +24,17 @@ def setUp(self): self.category = self.create_category() def create_category(self, name='Administration'): - return JobCategory.objects.create(name=name) + return Category.add_root(name=name, slug=slugify(name)) def create_superuser(self): - return User.objects.create_superuser(self.su_username, 'email@example.com', self.su_password) + return User.objects.create_superuser(self.su_username, 'email@example.com', self.su_password) def test_create_job_category(self): """ We can create a new job category """ self.assertEqual(self.category.name, 'Administration') - self.assertEqual(JobCategory.objects.all()[0], self.category) + self.assertEqual(Category.objects.all()[0], self.category) def test_create_job_offer(self): """ @@ -51,7 +52,7 @@ def test_create_job_offer_with_category(self): title = 'Senior' offer = JobOffer.objects.create(title=title, category=self.category) offer.save() - self.assertIn(offer, self.category.jobs.all()) + self.assertIn(offer, self.category.job_offers.all()) def test_add_offer_list_plugin_api(self): """ diff --git a/runtests.py b/runtests.py index 89edcee..91d4456 100644 --- a/runtests.py +++ b/runtests.py @@ -7,7 +7,4 @@ cmd = 'coverage run `which djangocms-helper` aldryn_jobs test --cms --extra-settings=test_settings' -if django.VERSION[:2] < (1, 6): - cmd += ' --runner=discover_runner.DiscoverRunner' - sys.exit(os.system(cmd)) diff --git a/setup.py b/setup.py index 6677b98..54a1cab 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ if not py26 and not py27: raise ValueError( - "Aldryn Events currently support only python >= 2.6.5" + "Aldryn Events currently support only python >= 2.6.5, not %s" % '.'.join(map(str, sys.version_info)) # NOQA ) @@ -22,17 +22,18 @@ 'aldryn-common>=0.0.4', 'unidecode', 'django-multiupload>=0.3', - 'django-sortedm2m' + 'django-sortedm2m', + 'aldryn-categories' ] if py26: REQUIREMENTS += [ - 'Django<1.6,>=1.5', + 'Django<1.7,>=1.6', ] if py27: REQUIREMENTS += [ - 'Django<1.8,>=1.5', + 'Django<1.8,>=1.6', ] DEPENDENCY_LINKS = [ diff --git a/test_settings.py b/test_settings.py index 7479914..6a9b043 100755 --- a/test_settings.py +++ b/test_settings.py @@ -3,11 +3,12 @@ HELPER_SETTINGS = { 'TIME_ZONE': 'Europe/Zurich', 'INSTALLED_APPS': [ - 'filer', + 'aldryn_common', + 'aldryn_categories', 'easy_thumbnails', + 'filer', 'parler', - 'aldryn_common', - 'django_sortedm2m' + 'sortedm2m', ], 'THUMBNAIL_PROCESSORS': ( 'easy_thumbnails.processors.colorspace', diff --git a/tox.ini b/tox.ini index 40f38d3..349d2e4 100644 --- a/tox.ini +++ b/tox.ini @@ -1,25 +1,25 @@ [tox] -envlist = py27-dj15, py27-dj16 +envlist = py{26,27}-django16, py27-django17, pep8 +skip_missing_interpreters=True [testenv] commands = - coverage erase + - coverage erase python runtests.py - coverage report -deps = + - coverage report +deps= + py26: unittest2 + ; Something happens that sometimes premailer (dependence of emailit) does + ; not install ordereddict on tox envs with Python 2.6.x, so I add it here. + ; If we found that issue on normal environments we must handle it as a bug + ; and add ordereddict to setup.py + py26: ordereddict + django16: django<1.7,>=1.6 + django17: django<1.8,>=1.7 + ; TODO: after merge the PR in aldryn-categories remove this line + https://github.com/aldryn/aldryn-categories/archive/feature/fk_fields.zip -rtest_requirements.txt -[testenv:py27-dj15] -deps = - -rtest_requirements.txt - Django<1.6 - django-discover-runner - -[testenv:py27-dj16] -deps = - -rtest_requirements.txt - Django<1.7 - [testenv:pep8] -commands = pep8 --repeat --show-source --max-line-length=120 --exclude=env,.tox,dist,migrations aldryn_jobs setup.py +commands = pep8 --repeat --show-source --max-line-length=79 --exclude=env,.tox,dist,migrations,south_migrations aldryn_jobs setup.py deps = pep8 From ce9640e052adb1dc2651c6c6ebd2be0ecca38720 Mon Sep 17 00:00:00 2001 From: Felipe Prenholato Date: Tue, 7 Apr 2015 08:50:07 -0300 Subject: [PATCH 3/3] Fix the environs names --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9face32..6816679 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,8 @@ language: python python: 2.7 env: - - TOX_ENV=py27-dj16 - - TOX_ENV=py27-dj17 + - TOX_ENV=py27-django16 + - TOX_ENV=py27-django17 - TOX_ENV=pep8 matrix: