Permalink
Browse files

Changed user profile to link to tagging.Tag directly rather than use …

…the slightly weird 'tags' field type

Made settings more DRY
  • Loading branch information...
1 parent 2da81e1 commit 73d0800839619eb0477a1edc98ef3ecd53bbbc1a @a-musing-moose committed Apr 14, 2011
@@ -1,7 +1,6 @@
from django.contrib import admin
from accounts.models import UserProfile
-
class ProfileAdmin(admin.ModelAdmin):
pass
@@ -1,11 +1,11 @@
from django.db import models
from django.contrib.auth.models import User
from django.db.models.signals import post_save
-from tagging.fields import TagField
+#from tagging.fields import TagField
class UserProfile(models.Model):
user = models.ForeignKey(User)
- tags = TagField()
+ tags = models.ManyToManyField('tagging.tag')
def __str__(self):
return "%s's profile" % self.user
View
@@ -18,4 +18,7 @@ class Alert(models.Model):
class Meta():
ordering = ['-date_created',]
+ def __unicode__(self):
+ return self.summary
+
alert_received.connect(email_alert)
@@ -0,0 +1,2 @@
+FROM_EMAIL_ADDRESS = "achtung@localhost"
+USER_AUTHENTICATION = False
View
@@ -3,6 +3,7 @@
from tagging.models import TaggedItem
from accounts.models import UserProfile
from django.contrib.auth.models import User
+from alert.settings import FROM_EMAIL_ADDRESS
import settings
@@ -28,6 +29,6 @@ def email_alert(sender, alert, **kwargs):
filtered_users = list(set(users))
subject = "[Achtung] %s - %s" % (alert.project_name, alert.summary)
- from_email = getattr(settings, 'ACHTUNG_FROM_EMAIL_ADDRESS', 'achtung@tangentone.com.au')
+ from_email = getattr(settings, 'ACHTUNG_FROM_EMAIL_ADDRESS', FROM_EMAIL_ADDRESS)
send.delay(subject, alert.message, from_email, filtered_users)
View
@@ -2,6 +2,7 @@
from alert.handlers import AlertHandler
from piston.resource import Resource
from piston.authentication import HttpBasicAuthentication
+from alert.settings import USER_AUTHENTICATION
import settings
class CsrfExemptResource(Resource):
@@ -12,7 +13,7 @@ def __init__(self, handler, authentication=None):
-if getattr(settings, "ACHTUNG_USER_AUTHENTICATION", False):
+if getattr(settings, "ACHTUNG_USER_AUTHENTICATION", USER_AUTHENTICATION):
alert_handler = CsrfExemptResource(AlertHandler, authentication=HttpBasicAuthentication(realm="Achtung baby"))
else:
alert_handler = CsrfExemptResource(AlertHandler)
View
@@ -0,0 +1,37 @@
+from django.contrib.sites.models import Site
+
+
+class DbMap(dict):
+
+ def __getitem__(self, key):
+ return {
+ 'ENGINE': 'django.db.backends.mysql',
+ 'NAME': 'django_achtung',
+ 'USER': 'root',
+ 'PASSWORD': 'ran32dom',
+ 'HOST': '',
+ 'PORT': '',
+ 'OPTIONS': {
+ 'init_command': 'SET storage_engine=INNODB',
+ }
+ }
+
+class DomainRouter(object):
+ """A router to control which database is used by which domain"""
+
+
+ def get_db_from_domain(self):
+ print Site.objects.get_current()
+ return 'default'
+
+ def db_for_read(self, model, **hints):
+ return self.get_db_from_domain()
+
+ def db_for_write(self, model, **hints):
+ return self.get_db_from_domain()
+
+ def allow_relation(self, obj1, obj2, **hints):
+ return None
+
+ def allow_syncdb(self, db, model):
+ return True
View
@@ -1,6 +1,10 @@
class ContentTypeMiddleware(object):
def process_request(self, request):
+ u"""
+ Piston is not very clever with it's handling of CONTENT_TYPE and barfs
+ if a charset is specified.
+ """
if request.META['CONTENT_TYPE'] == 'application/x-www-form-urlencoded; charset=UTF-8':
request.META['CONTENT_TYPE'] = 'application/x-www-form-urlencoded'
return None
@@ -15,4 +15,4 @@ def send(subject, message, from_email, recipient_list, fail_silently=False, auth
mail.save()
except:
was_successful = False
- return was_successful
+ return was_successful
View
@@ -108,14 +108,14 @@
ACHTUNG_USER_AUTHENTICATION = False
# Celery Settings
+CELERY_RESULT_BACKEND = "amqp"
+# Celery Broker Settings
BROKER_HOST = "localhost"
BROKER_PORT = 5672
BROKER_USER = "myuser"
BROKER_PASSWORD = "mypassword"
BROKER_VHOST = "myvhost"
-CELERY_RESULT_BACKEND = "amqp"
-
import djcelery
djcelery.setup_loader()

0 comments on commit 73d0800

Please sign in to comment.