Skip to content

Commit

Permalink
Remove postgres dependencies fixes #115
Browse files Browse the repository at this point in the history
  • Loading branch information
robmoorman authored and mvantellingen committed May 31, 2017
1 parent 9705947 commit 194daba
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
9 changes: 3 additions & 6 deletions sandbox/sandbox/apps/user/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-05-03 13:55
# Generated by Django 1.11.1 on 2017-05-31 12:22
from __future__ import unicode_literals

from django.contrib.postgres.operations import CITextExtension
from django.db import migrations, models
import django.contrib.auth.models
import django.contrib.postgres.fields.citext
from django.db import migrations, models
import django.utils.timezone


Expand All @@ -18,7 +16,6 @@ class Migration(migrations.Migration):
]

operations = [
CITextExtension(),
migrations.CreateModel(
name='User',
fields=[
Expand All @@ -28,7 +25,7 @@ class Migration(migrations.Migration):
('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
('first_name', models.CharField(blank=True, max_length=100, verbose_name='first name')),
('last_name', models.CharField(blank=True, max_length=100, verbose_name='last name')),
('email', django.contrib.postgres.fields.citext.CIEmailField(blank=True, max_length=254, unique=True, verbose_name='email address')),
('email', models.EmailField(blank=True, max_length=254, unique=True, verbose_name='email address')),
('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')),
('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')),
('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')),
Expand Down
12 changes: 1 addition & 11 deletions sandbox/sandbox/apps/user/models.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,19 @@
from django.contrib.auth.models import (
AbstractBaseUser, PermissionsMixin, UserManager)
from django.contrib.postgres.fields import CIEmailField
from django.core.mail import send_mail
from django.db import connections, models
from django.db.models.signals import pre_migrate
from django.dispatch import receiver
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _


@receiver(pre_migrate)
def setup_postgres_extensions(sender, **kwargs):
conn = connections[kwargs['using']]
if conn.vendor == 'postgresql':
cursor = conn.cursor()
cursor.execute("CREATE EXTENSION IF NOT EXISTS citext")


class User(AbstractBaseUser, PermissionsMixin):
"""Cusomtized version of the default `AbstractUser` from Django.
"""
first_name = models.CharField(_('first name'), max_length=100, blank=True)
last_name = models.CharField(_('last name'), max_length=100, blank=True)
email = CIEmailField(_('email address'), blank=True, unique=True)
email = models.EmailField(_('email address'), blank=True, unique=True)
is_staff = models.BooleanField(
_('staff status'), default=False,
help_text=_('Designates whether the user can log into this admin '
Expand Down

0 comments on commit 194daba

Please sign in to comment.