Permalink
Browse files

Added profile model with image.

  • Loading branch information...
1 parent e673b62 commit d566211859fb39e9170e160eb866271bc2f7a1fd Johan committed Oct 9, 2011
View
@@ -28,10 +28,16 @@ def latest(request):
else:
name = user.username
+ try:
+ image = user.get_profile().image.url
+ except:
+ image = False
+
data.append({
'member': name,
'on_illutron': entry.on_illutron,
'latest_checkin_time': latest_checkin_entry,
+ 'image': image
#'last_log_entry': entry.time.isoformat(),
#'latitude': entry.latitude,
#'longitude': entry.longitude,
@@ -41,5 +47,5 @@ def latest(request):
pass
- return HttpResponse(simplejson.dumps(data))
+ return HttpResponse(simplejson.dumps(data), mimetype='application/json')
No changes.
@@ -0,0 +1,6 @@
+# -*- coding: utf-8 -*-
+
+from django.contrib import admin
+from models import Profile
+
+admin.site.register(Profile, admin.ModelAdmin)
@@ -0,0 +1,71 @@
+# encoding: 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 'Profile'
+ db.create_table('profiles_profile', (
+ ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+ ('user', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['auth.User'], unique=True)),
+ ('image', self.gf('sorl.thumbnail.fields.ImageField')(max_length=100, null=True, blank=True)),
+ ))
+ db.send_create_signal('profiles', ['Profile'])
+
+
+ def backwards(self, orm):
+
+ # Deleting model 'Profile'
+ db.delete_table('profiles_profile')
+
+
+ models = {
+ 'auth.group': {
+ 'Meta': {'object_name': 'Group'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+ 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+ },
+ 'auth.permission': {
+ 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
+ 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+ },
+ 'auth.user': {
+ 'Meta': {'object_name': 'User'},
+ 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+ 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+ 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+ },
+ 'contenttypes.contenttype': {
+ 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+ 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+ },
+ 'profiles.profile': {
+ 'Meta': {'object_name': 'Profile'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'image': ('sorl.thumbnail.fields.ImageField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
+ 'user': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['auth.User']", 'unique': 'True'})
+ }
+ }
+
+ complete_apps = ['profiles']
No changes.
@@ -0,0 +1,12 @@
+from django.contrib.auth.models import User
+from django.db import models
+from sorl.thumbnail import ImageField
+
+class Profile(models.Model):
+ user = models.OneToOneField(User, unique=True)
+ image = ImageField(
+ upload_to='images/profiles/',
+ blank=True,
+ null=True,
+ )
+
@@ -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)
@@ -0,0 +1 @@
+# Create your views here.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -78,6 +78,8 @@
# Apps
'log',
'sync',
+ 'profiles',
+
#'import',
# Third-party
@@ -100,6 +102,8 @@
DATETIME_FORMAT = "j N Y H:i"
PAGINATE_BY = 12
+AUTH_PROFILE_MODULE = "profiles.Profile"
+
# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error.
View
Binary file not shown.
View
@@ -1,4 +1,5 @@
from django.conf.urls.defaults import patterns, include, url
+import settings
from django.contrib import admin
admin.autodiscover()
@@ -13,5 +14,12 @@
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
url(r'^admin/', include(admin.site.urls)),
-
)
+
+
+if settings.DEBUG:
+ urlpatterns += patterns('django.views.static',
+ (r'^media/(?P<path>.*)$',
+ 'serve', {
+ 'document_root': settings.MEDIA_ROOT,
+ 'show_indexes': True }),)

0 comments on commit d566211

Please sign in to comment.