Skip to content

Commit

Permalink
upgrade to work with django 1.10
Browse files Browse the repository at this point in the history
  • Loading branch information
tonylampada committed Mar 19, 2017
1 parent 7a64543 commit 0942cdc
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 175 deletions.
122 changes: 39 additions & 83 deletions emailmgr/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,83 +1,39 @@
# encoding: utf-8
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models

class Migration(SchemaMigration):

def forwards(self, orm):

# Adding model 'EmailAddress'
db.create_table('emailmgr_emailaddress', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('user', self.gf('django.db.models.fields.related.ForeignKey')(related_name='emailaddress', to=orm['auth.User'])),
('email', self.gf('django.db.models.fields.EmailField')(max_length=75)),
('is_primary', self.gf('django.db.models.fields.BooleanField')(default=False)),
('is_active', self.gf('django.db.models.fields.BooleanField')(default=False)),
('identifier', self.gf('django.db.models.fields.CharField')(max_length=255, null=True)),
))
db.send_create_signal('emailmgr', ['EmailAddress'])

# Adding unique constraint on 'EmailAddress', fields ['user', 'email']
db.create_unique('emailmgr_emailaddress', ['user_id', 'email'])


def backwards(self, orm):

# Removing unique constraint on 'EmailAddress', fields ['user', 'email']
db.delete_unique('emailmgr_emailaddress', ['user_id', 'email'])

# Deleting model 'EmailAddress'
db.delete_table('emailmgr_emailaddress')


models = {
'auth.group': {
'Meta': {'object_name': 'Group'},
'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': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
},
'auth.permission': {
'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
},
'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', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
'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', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
},
'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'}),
'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'})
},
'emailmgr.emailaddress': {
'Meta': {'unique_together': "(('user', 'email'),)", 'object_name': 'EmailAddress'},
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'identifier': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True'}),
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'is_primary': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'emailaddress'", 'to': "orm['auth.User']"})
}
}

complete_apps = ['emailmgr']
# -*- coding: utf-8 -*-
# Generated by Django 1.10.6 on 2017-03-19 15:00
from __future__ import unicode_literals

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


class Migration(migrations.Migration):

initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name='EmailAddress',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('email', models.EmailField(max_length=254, verbose_name='Email Address')),
('is_primary', models.BooleanField(default=False)),
('is_active', models.BooleanField(default=False)),
('is_activation_sent', models.BooleanField(default=False)),
('identifier', models.CharField(max_length=255, null=True)),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='emailaddress', to=settings.AUTH_USER_MODEL)),
],
options={
'verbose_name': 'email address',
'verbose_name_plural': 'email addresses',
},
),
migrations.AlterUniqueTogether(
name='emailaddress',
unique_together=set([('user', 'email')]),
),
]

This file was deleted.

6 changes: 3 additions & 3 deletions emailmgr/urls.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
from django.conf.urls import patterns, include, url
from django.conf.urls import include, url
from django.conf import settings
from views import email_add, email_list, email_delete, \
email_send_activation, email_activate, email_make_primary

#add an email to a User account
urlpatterns = patterns('',
urlpatterns = [
url(
r'^email/add/$',
email_add,
Expand Down Expand Up @@ -36,4 +36,4 @@
email_list,
name='emailmgr_email_list'
),
)
]
24 changes: 5 additions & 19 deletions emailmgr/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.shortcuts import render_to_response
from django.shortcuts import render
from django.template import RequestContext
from django.contrib import messages as Msg
from django.http import HttpResponseRedirect
Expand Down Expand Up @@ -28,13 +28,11 @@ def email_add(request):
else:
form = EmailAddressForm(user=request.user)
emails_list = EmailAddress.objects.filter(user=request.user).order_by(*sort_email())
return render_to_response(get_template('emailmgr_email_list.html'),
return render(request, get_template('emailmgr_email_list.html'),
{
'email_list': emails_list,
'email_form': form
},
context_instance=RequestContext(request)
)
})

@login_required
def email_make_primary(request, identifier="somekey"):
Expand Down Expand Up @@ -137,20 +135,8 @@ def email_list(request):
"""
form = EmailAddressForm(user=request.user)
emails_list = EmailAddress.objects.filter(user=request.user).order_by(*sort_email())
return render_to_response(get_template('emailmgr_email_list.html'),
return render(request, get_template('emailmgr_email_list.html'),
{
'email_list': emails_list,
'email_form': form
},
context_instance=RequestContext(request)
)










})

0 comments on commit 0942cdc

Please sign in to comment.