Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ca7bc90
commit 4cf9891
Showing
12 changed files
with
189 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -107,6 +107,7 @@ | |
'questions', | ||
'classroom', | ||
'step', | ||
'suggest', | ||
) | ||
|
||
INSTALLED_APPS = PREREQ_APPS + PROJECT_APPS | ||
|
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 import forms | ||
from .models import Suggestion | ||
|
||
class SuggestForm(forms.ModelForm): | ||
|
||
class Meta: | ||
model = Suggestion |
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,40 @@ | ||
# -*- coding: 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 'Suggestion' | ||
db.create_table('suggest_suggestion', ( | ||
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), | ||
('created', self.gf('model_utils.fields.AutoCreatedField')(default=datetime.datetime.now)), | ||
('modified', self.gf('model_utils.fields.AutoLastModifiedField')(default=datetime.datetime.now)), | ||
('name', self.gf('django.db.models.fields.CharField')(max_length=255, blank=True)), | ||
('email', self.gf('django.db.models.fields.EmailField')(max_length=255, blank=True)), | ||
('description', self.gf('django.db.models.fields.TextField')(default='', null=True, blank=True)), | ||
)) | ||
db.send_create_signal('suggest', ['Suggestion']) | ||
|
||
|
||
def backwards(self, orm): | ||
# Deleting model 'Suggestion' | ||
db.delete_table('suggest_suggestion') | ||
|
||
|
||
models = { | ||
'suggest.suggestion': { | ||
'Meta': {'object_name': 'Suggestion'}, | ||
'created': ('model_utils.fields.AutoCreatedField', [], {'default': 'datetime.datetime.now'}), | ||
'description': ('django.db.models.fields.TextField', [], {'default': "''", 'null': 'True', 'blank': 'True'}), | ||
'email': ('django.db.models.fields.EmailField', [], {'max_length': '255', 'blank': 'True'}), | ||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | ||
'modified': ('model_utils.fields.AutoLastModifiedField', [], {'default': 'datetime.datetime.now'}), | ||
'name': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}) | ||
} | ||
} | ||
|
||
complete_apps = ['suggest'] |
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,11 @@ | ||
from django.db import models | ||
from model_utils.models import TimeStampedModel | ||
from django.utils.translation import ugettext_lazy as _ | ||
|
||
class Suggestion(TimeStampedModel): | ||
""" suggest class | ||
""" | ||
name = models.CharField(_('name'), max_length=255, blank=True) | ||
email = models.EmailField(_('email'), max_length=255, blank=True) | ||
description = models.TextField(_('description'), blank=True, null=True, default="") | ||
|
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,81 @@ | ||
{% extends 'base.html' %} | ||
{% load i18n %} | ||
|
||
{% block title %}{% trans "Suggest Class" %}{% endblock %} | ||
|
||
|
||
{% block page-js %} | ||
<script type="text/javascript"> | ||
|
||
$(document).ready(function(){ | ||
|
||
var validator = $("#suggest_form").validate({ | ||
rules: { | ||
name: "required", | ||
email: { | ||
required: true, | ||
email: true | ||
} | ||
}, | ||
highlight: function(label) { | ||
$(label).closest('.control-group').addClass('error'); | ||
}, | ||
success: function(label) { | ||
label | ||
.text('OK!').addClass('valid') | ||
.closest('.control-group').addClass('success'); | ||
} | ||
}); | ||
|
||
$('#save_button').click(function() { | ||
validator.resetForm(); | ||
}); | ||
|
||
$('#cancel_button').click(function() { | ||
validator.resetForm(); | ||
}); | ||
|
||
|
||
}); | ||
</script> | ||
|
||
{% endblock page-js %} | ||
|
||
{% block content %} | ||
{{ form.non_field_errors }} | ||
|
||
<form id="suggest_form" class="form-horizontal" action="" method="post"> | ||
<fieldset> | ||
<legend>Suggest a class</legend> | ||
<div class="control-group {%if form.name.errors %}error{% endif %}"> | ||
<label class="control-label" for="input01">*Your Name</label> | ||
<div class="controls"> | ||
{{form.name}} | ||
<span class="help-inline">{{form.name.errors}}</span> | ||
</div> | ||
</div> | ||
<div class="control-group {%if form.email.errors %}error{% endif %}"> | ||
<label class="control-label" for="input01">*Your Email</label> | ||
<div class="controls"> | ||
{{form.email}} | ||
<span class="help-inline">{{form.email.errors}}</span> | ||
</div> | ||
</div> | ||
|
||
<div class="control-group"> | ||
<label class="control-label" for="input01">Description</label> | ||
<div class="controls"> | ||
<div id="epiceditor"></div> | ||
{{form.description}} | ||
<p class="help-block"></p> | ||
</div> | ||
</div> | ||
<div class="form-actions"> | ||
<button type="submit" class="btn btn-primary" id='save_button'>Send Suggestion</button> | ||
<a class="btn" id="cancel_button" href='{% url home %}'>Cancel</a> | ||
</div> | ||
</fieldset> | ||
|
||
{% csrf_token %} | ||
</form> | ||
{% endblock %} |
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,16 @@ | ||
""" | ||
This file demonstrates writing tests using the unittest module. These will pass | ||
when you run "manage.py test". | ||
Replace this with more appropriate tests for your application. | ||
""" | ||
|
||
from django.test import TestCase | ||
|
||
|
||
class SimpleTest(TestCase): | ||
def test_basic_addition(self): | ||
""" | ||
Tests that 1 + 1 always equals 2. | ||
""" | ||
self.assertEqual(1 + 1, 2) |
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,6 @@ | ||
from django.conf.urls import patterns, include, url | ||
from .views import add | ||
|
||
urlpatterns = patterns('', | ||
url(r'^$', add, name='add_suggestion'), | ||
) |
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,25 @@ | ||
from .forms import SuggestForm | ||
from django.shortcuts import render | ||
from django.core.urlresolvers import reverse | ||
from django.http import HttpResponseRedirect | ||
|
||
def add(request): | ||
""" | ||
add Suggestion | ||
""" | ||
if request.method == 'POST': | ||
form = SuggestForm(request.POST) | ||
if form.is_valid(): | ||
try: | ||
step = form.save() | ||
return HttpResponseRedirect(reverse('home')) | ||
except Exception as e: | ||
#TODO: fix me. | ||
print("ERROR {0}".format(e)) | ||
else: | ||
print form | ||
else: | ||
form = SuggestForm() | ||
|
||
context = {'form':form} | ||
return render(request, 'suggest/index.html', context) |
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
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