-
diff --git a/pinry/core/templates/core/register.html b/pinry/core/templates/core/register.html
new file mode 100644
index 0000000..68d56e8
--- /dev/null
+++ b/pinry/core/templates/core/register.html
@@ -0,0 +1,26 @@
+{% extends 'core/base.html' %}
+
+{% load bootstrap_field %}
+
+
+{% block title %}Login{% endblock %}
+
+{% block yield %}
+
+{% endblock %}
diff --git a/pinry/core/templates/core/templatetags/bootstrap_field.html b/pinry/core/templates/core/templatetags/bootstrap_field.html
new file mode 100644
index 0000000..e51c2e3
--- /dev/null
+++ b/pinry/core/templates/core/templatetags/bootstrap_field.html
@@ -0,0 +1,15 @@
+
+
+
+ {{ field }}
+ {% if field.errors %}
+
+ {% if field.errors %}
+ {% for error in field.errors %}
+ {{ error|escape }}
+ {% endfor %}
+ {% endif %}
+
+ {% endif %}
+
+
diff --git a/pinry/core/templatetags/__init__.py b/pinry/core/templatetags/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/pinry/core/templatetags/bootstrap_field.py b/pinry/core/templatetags/bootstrap_field.py
new file mode 100644
index 0000000..d081aaa
--- /dev/null
+++ b/pinry/core/templatetags/bootstrap_field.py
@@ -0,0 +1,11 @@
+from django import template
+from django.template import loader, Context
+
+
+register = template.Library()
+
+
+@register.simple_tag
+def bootstrap_field(field):
+ template = loader.get_template('core/templatetags/bootstrap_field.html')
+ return template.render(Context({'field': field}))
diff --git a/pinry/pins/forms.py b/pinry/pins/forms.py
index 4411609..6a4766a 100644
--- a/pinry/pins/forms.py
+++ b/pinry/pins/forms.py
@@ -5,7 +5,6 @@ from .models import Pin
class PinForm(forms.ModelForm):
url = forms.CharField(label='URL')
- title = forms.CharField(required=False)
class Meta:
model = Pin
diff --git a/pinry/pins/migrations/0002_auto__del_tag__del_field_pin_title__add_field_pin_description.py b/pinry/pins/migrations/0002_auto__del_tag__del_field_pin_title__add_field_pin_description.py
new file mode 100644
index 0000000..c5fdc3b
--- /dev/null
+++ b/pinry/pins/migrations/0002_auto__del_tag__del_field_pin_title__add_field_pin_description.py
@@ -0,0 +1,58 @@
+# -*- 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):
+ # Deleting model 'Tag'
+ db.delete_table('pins_tag')
+
+ # Deleting field 'Pin.title'
+ db.delete_column('pins_pin', 'title')
+
+ # Adding field 'Pin.description'
+ db.add_column('pins_pin', 'description',
+ self.gf('django.db.models.fields.TextField')(null=True, blank=True),
+ keep_default=False)
+
+ # Removing M2M table for field tags on 'Pin'
+ db.delete_table('pins_pin_tags')
+
+ def backwards(self, orm):
+ # Adding model 'Tag'
+ db.create_table('pins_tag', (
+ ('slug', self.gf('django.db.models.fields.SlugField')(max_length=50)),
+ ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+ ('name', self.gf('django.db.models.fields.CharField')(max_length=70)),
+ ))
+ db.send_create_signal('pins', ['Tag'])
+
+
+ # User chose to not deal with backwards NULL issues for 'Pin.title'
+ raise RuntimeError("Cannot reverse this migration. 'Pin.title' and its values cannot be restored.")
+ # Deleting field 'Pin.description'
+ db.delete_column('pins_pin', 'description')
+
+ # Adding M2M table for field tags on 'Pin'
+ db.create_table('pins_pin_tags', (
+ ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
+ ('pin', models.ForeignKey(orm['pins.pin'], null=False)),
+ ('tag', models.ForeignKey(orm['pins.tag'], null=False))
+ ))
+ db.create_unique('pins_pin_tags', ['pin_id', 'tag_id'])
+
+ models = {
+ 'pins.pin': {
+ 'Meta': {'object_name': 'Pin'},
+ 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'image': ('thumbs.ImageWithThumbsField', [], {'max_length': '100', 'sizes': '((200, 1000),)'}),
+ 'url': ('django.db.models.fields.TextField', [], {})
+ }
+ }
+
+ complete_apps = ['pins']
\ No newline at end of file
diff --git a/pinry/pins/models.py b/pinry/pins/models.py
index 1ec591e..b602c2b 100644
--- a/pinry/pins/models.py
+++ b/pinry/pins/models.py
@@ -10,12 +10,11 @@ import urllib2
class Pin(models.Model):
url = models.TextField()
- title = models.CharField(max_length=70)
+ description = models.TextField(blank=True, null=True)
image = ImageWithThumbsField(upload_to='pins/pin', sizes=((200,1000),))
- tags = models.ManyToManyField('Tag')
def __unicode__(self):
- return self.title
+ return self.url
def save(self):
if not self.image:
@@ -23,18 +22,4 @@ class Pin(models.Model):
temp_img.write(urllib2.urlopen(self.url).read())
temp_img.flush()
self.image.save(self.url.split('/')[-1], File(temp_img))
- if not self.title:
- self.title = self.url.split('/')[-1]
super(Pin, self).save()
-
-
-class Tag(models.Model):
- name = models.CharField(max_length=70)
- slug = models.SlugField()
-
- def __unicode__(self):
- return self.name
-
- def save(self):
- self.slug = slugify(self.name)
- super(Tag, self).save()
diff --git a/pinry/pins/templates/pins/new_pin.html b/pinry/pins/templates/pins/new_pin.html
index 5ed1b60..f07f2bf 100644
--- a/pinry/pins/templates/pins/new_pin.html
+++ b/pinry/pins/templates/pins/new_pin.html
@@ -1,14 +1,24 @@
{% extends 'core/base.html' %}
+{% load bootstrap_field %}
+
+
{% block title %}New Pin{% endblock %}
{% block yield %}
-
diff --git a/pinry/pins/templates/pins/recent_pins.html b/pinry/pins/templates/pins/recent_pins.html
index c87f1b2..e93ea31 100644
--- a/pinry/pins/templates/pins/recent_pins.html
+++ b/pinry/pins/templates/pins/recent_pins.html
@@ -4,44 +4,15 @@
{% block yield %}
-
{% for pin in pins %}
{% if pin.image %}
-
+
{% endif %}
- {% if pin.tags %}
-
- Tags:
- {% for tag in pin.tags.all %}
- {% if not forloop.last %}
- {{ tag }},
- {% else %}
- {{ tag }}
- {% endif %}
- {% endfor %}
-
+ {% if pin.description %}
+
Description: {{ pin.description }}
{% endif %}
{% endfor %}
diff --git a/pinry/pins/views.py b/pinry/pins/views.py
index 5372402..ec1a17a 100644
--- a/pinry/pins/views.py
+++ b/pinry/pins/views.py
@@ -8,7 +8,7 @@ from .forms import PinForm
def recent_pins(request):
context = {
- 'pins': Pin.objects.all()[:20],
+ 'pins': Pin.objects.order_by('-id')[:50],
}
return TemplateResponse(request, 'pins/recent_pins.html', context)