Skip to content

Commit c4b120d

Browse files
authored
Merge pull request #7 from TheRealGD/develop
Merge changes
2 parents 41450d1 + 2411807 commit c4b120d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+144
-69
lines changed

Procfile

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
release: python manage.py migrate --no-input
2+
web: gunicorn rgundeals.wsgi --log-file -
3+

README.md

+45-25
File renamed without changes.

rgundeals/deals/admin.py renamed to deals/admin.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@
22
from django.db.models import Count
33
from django.utils import timezone
44

5-
from .models import Category, Comment, Deal, Vendor
5+
from .models import Category, Comment, Deal, Vendor, VendorDomain
6+
7+
8+
class VendorDomainInline(admin.TabularInline):
9+
model = VendorDomain
610

711

812
@admin.register(Vendor)
913
class VendorAdmin(admin.ModelAdmin):
10-
list_display = ('name', 'domains', 'url', 'deal_count')
14+
list_display = ('name', 'url', 'deal_count')
1115
prepopulated_fields = {'slug': ('name',)}
12-
search_fields = ('name', 'domains', 'url')
16+
search_fields = ('name', 'url')
17+
inlines = [VendorDomainInline, ]
1318

1419
def get_queryset(self, request):
1520
# Include count of assigned deals
File renamed without changes.
File renamed without changes.
File renamed without changes.

rgundeals/deals/migrations/0001_initial.py renamed to deals/migrations/0001_initial.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
# Generated by Django 2.0.3 on 2018-03-28 04:11
1+
# Generated by Django 2.0.3 on 2018-03-30 04:46
22

3-
import django.contrib.postgres.fields
43
import django.core.validators
54
from django.db import migrations, models
65
import django.db.models.deletion
@@ -27,7 +26,6 @@ class Migration(migrations.Migration):
2726
('level', models.PositiveIntegerField(db_index=True, editable=False)),
2827
],
2928
options={
30-
'ordering': ('name',),
3129
'verbose_name_plural': 'categories',
3230
},
3331
),
@@ -95,10 +93,17 @@ class Migration(migrations.Migration):
9593
('name', models.CharField(help_text='Company name', max_length=100)),
9694
('slug', models.SlugField(unique=True)),
9795
('url', models.URLField(help_text='Public-facing website', verbose_name='URL')),
98-
('domains', django.contrib.postgres.fields.ArrayField(base_field=models.CharField(max_length=100), help_text='URLs matching any of these domains will be associated with this vendor', size=None)),
9996
],
10097
options={
10198
'ordering': ('name',),
10299
},
103100
),
101+
migrations.CreateModel(
102+
name='VendorDomain',
103+
fields=[
104+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
105+
('domain', models.CharField(help_text='Vendor Domain', max_length=255, unique=True)),
106+
('vendor', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='deals.Vendor')),
107+
],
108+
),
104109
]

rgundeals/deals/migrations/0002_auto_20180328_0411.py renamed to deals/migrations/0002_auto_20180330_0446.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Generated by Django 2.0.3 on 2018-03-28 04:11
1+
# Generated by Django 2.0.3 on 2018-03-30 04:46
22

33
from django.conf import settings
44
from django.db import migrations, models
File renamed without changes.

rgundeals/deals/models.py renamed to deals/models.py

+12-5
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@
4747
)
4848

4949

50+
class VendorDomain(models.Model):
51+
domain = models.CharField(max_length=255, help_text="Vendor Domain", unique=True)
52+
vendor = models.ForeignKey('Vendor', on_delete=models.CASCADE)
53+
54+
def __str__(self):
55+
return self.domain
56+
57+
5058
class Vendor(models.Model):
5159
name = models.CharField(
5260
max_length=100,
@@ -59,10 +67,6 @@ class Vendor(models.Model):
5967
verbose_name='URL',
6068
help_text="Public-facing website"
6169
)
62-
domains = ArrayField(
63-
base_field=models.CharField(max_length=100),
64-
help_text="URLs matching any of these domains will be associated with this vendor"
65-
)
6670

6771
class Meta:
6872
ordering = ('name',)
@@ -225,7 +229,10 @@ def save(self, *args, **kwargs):
225229

226230
# Assign vendor based on URL domain upon creation of new deals
227231
if not self.pk and not self.vendor and self.domain:
228-
self.vendor = Vendor.objects.filter(domains__contains=[self.domain]).order_by('pk').first()
232+
try:
233+
self.vendor = VendorDomain.objects.get(domain=self.domain).vendor
234+
except VendorDomain.DoesNotExist:
235+
pass
229236

230237
return super().save(*args, **kwargs)
231238

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

requirements.txt

+29-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,29 @@
1-
Django>=2.0.3
2-
django-bootstrap4>=0.0.6
3-
django-debug-toolbar>=1.9.1
4-
django-filter>=1.1.0
5-
django-mptt>=0.9.0
6-
Markdown>=2.6.11
7-
psycopg2-binary>=2.7.4
8-
py-gfm>=0.1.3
1+
appnope==0.1.0
2+
decorator==4.2.1
3+
dj-database-url==0.5.0
4+
Django==2.0.3
5+
django-bootstrap4==0.0.6
6+
django-debug-toolbar==1.9.1
7+
django-filter==1.1.0
8+
django-js-asset==1.0.0
9+
django-mptt==0.9.0
10+
gunicorn==19.7.1
11+
ipython==6.2.1
12+
ipython-genutils==0.2.0
13+
jedi==0.11.1
14+
Markdown==2.6.11
15+
parso==0.1.1
16+
pexpect==4.4.0
17+
pickleshare==0.7.4
18+
prompt-toolkit==1.0.15
19+
psycopg2-binary==2.7.4
20+
ptyprocess==0.5.2
21+
py-gfm==0.1.3
22+
Pygments==2.2.0
23+
pytz==2018.3
24+
simplegeneric==0.8.1
25+
six==1.11.0
26+
sqlparse==0.2.4
27+
traitlets==4.3.2
28+
wcwidth==0.1.7
29+
whitenoise==3.3.1
File renamed without changes.

rgundeals/deals/migrations/0003_fix_category_ordering.py

-17
This file was deleted.

rgundeals/rgundeals/settings.py renamed to rgundeals/settings.py

+34-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
import os
2-
3-
from .configuration import *
4-
2+
import dj_database_url
53

64
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
75
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
6+
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
7+
8+
# Debugging settings, export the DJ_DEBUG if you need to enable debugging (SHOULD NEVER BE ON IN PROD!)
9+
DEBUG = os.environ.get('DJ_DEBUG', 'False').lower() == 'true'
10+
11+
# SECRET KEY SHOULD ALWAYS BE CHANGED IN PROD!
12+
SECRET_KEY = os.environ.get('DJ_SECRET_KEY', 'CHANGEME!!!')
13+
14+
# Allowed domain names
15+
# TODO: change to a DJ_HOSTS variable
16+
ALLOWED_HOSTS = ['*']
17+
18+
# For emailing errors
19+
ADMINS = (('root', 'root@localhost'), )
820

921
INSTALLED_APPS = [
1022

@@ -14,6 +26,9 @@
1426
'django.contrib.contenttypes',
1527
'django.contrib.sessions',
1628
'django.contrib.messages',
29+
30+
# WhiteNoise
31+
'whitenoise.runserver_nostatic',
1732
'django.contrib.staticfiles',
1833

1934
# Third party
@@ -29,6 +44,7 @@
2944

3045
MIDDLEWARE = [
3146
'django.middleware.security.SecurityMiddleware',
47+
'whitenoise.middleware.WhiteNoiseMiddleware',
3248
'django.contrib.sessions.middleware.SessionMiddleware',
3349
'django.middleware.common.CommonMiddleware',
3450
'django.middleware.csrf.CsrfViewMiddleware',
@@ -86,8 +102,19 @@
86102
# Custom user model
87103
AUTH_USER_MODEL = 'users.User'
88104

105+
106+
# Set the default DB up, but use dj_database_url to pull the DATABASE_URL from the ENV variable
107+
DATABASES = {
108+
'default': {
109+
'ENGINE': 'django.db.backends.sqlite3',
110+
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
111+
}
112+
}
113+
DATABASES['default'].update(dj_database_url.config(conn_max_age=500))
114+
115+
89116
# Static files (CSS, JavaScript, Images)
90-
STATIC_ROOT = BASE_DIR + '/static/'
117+
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
91118
STATIC_URL = '/static/'
92119
STATICFILES_DIRS = (
93120
os.path.join(BASE_DIR, 'project-static'),
@@ -106,3 +133,6 @@
106133
# Pagination
107134
DEFAULT_PAGE_SIZE = 50
108135
MAX_PAGE_SIZE = 200
136+
137+
# WhiteNoise Configuration
138+
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
File renamed without changes.
File renamed without changes.

runtime.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
python-3.6.4
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

rgundeals/users/migrations/0001_initial.py renamed to users/migrations/0001_initial.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Generated by Django 2.0.3 on 2018-03-28 04:11
1+
# Generated by Django 2.0.3 on 2018-03-30 04:46
22

33
import django.contrib.auth.models
44
from django.db import migrations, models
@@ -12,8 +12,8 @@ class Migration(migrations.Migration):
1212
initial = True
1313

1414
dependencies = [
15-
('deals', '0001_initial'),
1615
('auth', '0009_alter_user_last_name_max_length'),
16+
('deals', '0001_initial'),
1717
]
1818

1919
operations = [
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)