Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit. Threw together a basic site based on a Customer model…
… and related form, along with settings for email capability. Next step is email and formatting
- Loading branch information
0 parents
commit 2796188
Showing
18 changed files
with
196 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
*.py[co] | ||
.idea/ | ||
*/settings.py | ||
db.sqlite3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Rice Bikes Processing App | ||
========================= | ||
|
||
This site is built for use by the employees of Rice Bikes, the student- | ||
run bike shop at Rice University. | ||
|
||
Users can enter the information of a customer, including email address. | ||
When the order is submitted, the customer will receive an email from | ||
the bike shop confirming they have been processed. When the job is | ||
finished, the emloyees can update the status to completed, and the | ||
customer will receive an email notifying them that they can come in | ||
and pick up their bike. |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from django.contrib import admin | ||
from app.models import Customer | ||
|
||
admin.site.register(Customer) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from django.forms import ModelForm | ||
from app.models import Customer | ||
|
||
|
||
class CustomerForm(ModelForm): | ||
class Meta: | ||
model = Customer | ||
fields = ['first_name', 'last_name', 'email', 'service_description','completed', 'date_submitted'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import models, migrations | ||
import app.models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Customer', | ||
fields=[ | ||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), | ||
('first_name', models.CharField(max_length=100)), | ||
('last_name', models.CharField(max_length=100)), | ||
('email', models.CharField(max_length=100, validators=[app.models.validate_email])), | ||
('service_description', models.CharField(max_length=500)), | ||
('price', models.IntegerField(default=0)), | ||
('completed', models.BooleanField(default=False)), | ||
('date_submitted', models.DateTimeField(verbose_name=b'date submitted')), | ||
], | ||
options={ | ||
}, | ||
bases=(models.Model,), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import models, migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('app', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='customer', | ||
name='date_submitted', | ||
field=models.DateTimeField(verbose_name='date submitted'), | ||
preserve_default=True, | ||
), | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from django.db import models | ||
from django.core.exceptions import ValidationError | ||
import re | ||
|
||
|
||
def validate_email(email_string): | ||
possible_match = re.match(r'[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}', email_string) | ||
if possible_match is None: | ||
raise ValidationError(u'%s is not a valid email address' % email_string) | ||
|
||
|
||
class Customer(models.Model): | ||
first_name = models.CharField(max_length=100) | ||
last_name = models.CharField(max_length=100) | ||
email = models.CharField(max_length=100, validators=[validate_email]) | ||
service_description = models.CharField(max_length=500) | ||
price = models.IntegerField(default=0) | ||
completed = models.BooleanField(default=False) | ||
date_submitted = models.DateTimeField('date submitted') | ||
|
||
def __str__(self): | ||
return self.first_name + " " + self.last_name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %} | ||
|
||
<form action="" method="post"> | ||
{% csrf_token %} | ||
{{ form.as_p }} | ||
<input type="submit" value="Save" /> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{% if customers_list %} | ||
<h3>Active</h3> | ||
<ul> | ||
{% for customer in customers_list %} | ||
{% if customer.completed == False %} | ||
<li><a href="{% url 'app:detail' customer.id %}">{{ customer.first_name }} {{ customer.last_name }}</a></li> | ||
{% endif %} | ||
{% endfor %} | ||
</ul> | ||
|
||
<h3>Inactive</h3> | ||
<ul> | ||
{% for customer in customers_list %} | ||
{% if customer.completed == True %} | ||
<li><a href="{% url 'app:detail' customer.id %}">{{ customer.first_name }} {{ customer.last_name }}</a></li> | ||
{% endif %} | ||
{% endfor %} | ||
</ul> | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from django.conf.urls import patterns, url | ||
|
||
from app import views | ||
|
||
urlpatterns = patterns('', | ||
url(r'^$', views.index, name='index'), | ||
url(r'(?P<pk>\d+)/', views.CustomerUpdate.as_view(), name='detail'), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from django.http import HttpResponseRedirect | ||
from django.shortcuts import render, get_object_or_404 | ||
from app.models import Customer | ||
from django.core.urlresolvers import reverse_lazy | ||
from django.views.generic.edit import CreateView, UpdateView, DeleteView, FormView | ||
from app.forms import CustomerForm | ||
|
||
|
||
def index(request): | ||
print "Index view" | ||
customers_list = Customer.objects.order_by('date_submitted') | ||
return render(request, 'app/index.html', {'customers_list': customers_list}) | ||
|
||
|
||
def detail(request, customer_id): | ||
customer = get_object_or_404(Customer, pk=customer_id) | ||
form = CustomerForm(instance=customer) | ||
return render(request, 'app/detail.html', { | ||
'customer': customer, | ||
'form': form, | ||
}) | ||
|
||
|
||
class CustomerUpdate(UpdateView): | ||
model = Customer | ||
fields = ['first_name', 'last_name', 'email', 'service_description', 'price', 'completed', 'date_submitted'] | ||
template_name = "app/detail.html" | ||
success_url = "/app" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env python | ||
import os | ||
import sys | ||
|
||
if __name__ == "__main__": | ||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") | ||
|
||
from django.core.management import execute_from_command_line | ||
|
||
execute_from_command_line(sys.argv) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from django.conf.urls import patterns, include, url | ||
from django.contrib import admin | ||
|
||
urlpatterns = patterns('', | ||
url(r'^app/', include('app.urls', namespace="app")), | ||
url(r'^admin/', include(admin.site.urls)), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
""" | ||
WSGI config for mysite project. | ||
It exposes the WSGI callable as a module-level variable named ``application``. | ||
For more information on this file, see | ||
https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/ | ||
""" | ||
|
||
import os | ||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") | ||
|
||
from django.core.wsgi import get_wsgi_application | ||
application = get_wsgi_application() |