Permalink
Browse files

user crawler preferences + constants

  • Loading branch information...
1 parent 03a5f5f commit 48db463a6a3c56a7f1851f598c1b03b6ce6a5c93 @alexanderad committed Jul 30, 2011
View
@@ -0,0 +1,7 @@
+# -*- coding: utf-8 -*-
+NOTIFICATIONS_SETTINGS = (
+ ('dashboard-only', u'Dashboard notifications only'),
+ ('weekly', u'Weekly digest of all problems'),
+ ('dead-links-only', u'Dead links only'),
+ ('very-verbose', u'All problems in one email immediately after check'),
+)
@@ -0,0 +1,80 @@
+# 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 field 'UserProfile.notifications_settings'
+ db.add_column('accounts_userprofile', 'notifications_settings', self.gf('django.db.models.fields.CharField')(default='dashboard-only', max_length=32), keep_default=False)
+
+ # Adding field 'UserProfile.crawler_visits_frequency'
+ db.add_column('accounts_userprofile', 'crawler_visits_frequency', self.gf('django.db.models.fields.CharField')(default='daily', max_length=16), keep_default=False)
+
+ # Adding field 'UserProfile.limit_link_types'
+ db.add_column('accounts_userprofile', 'limit_link_types', self.gf('django.db.models.fields.CharField')(default=u'web css js img', max_length=32), keep_default=False)
+
+
+ def backwards(self, orm):
+
+ # Deleting field 'UserProfile.notifications_settings'
+ db.delete_column('accounts_userprofile', 'notifications_settings')
+
+ # Deleting field 'UserProfile.crawler_visits_frequency'
+ db.delete_column('accounts_userprofile', 'crawler_visits_frequency')
+
+ # Deleting field 'UserProfile.limit_link_types'
+ db.delete_column('accounts_userprofile', 'limit_link_types')
+
+
+ models = {
+ 'accounts.userprofile': {
+ 'Meta': {'object_name': 'UserProfile'},
+ 'crawler_visits_frequency': ('django.db.models.fields.CharField', [], {'default': "'daily'", 'max_length': '16'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'limit_link_types': ('django.db.models.fields.CharField', [], {'default': "u'web css js img'", 'max_length': '32'}),
+ 'notifications_settings': ('django.db.models.fields.CharField', [], {'default': "'dashboard-only'", 'max_length': '32'}),
+ 'user': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['auth.User']", 'unique': 'True'})
+ },
+ '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'})
+ }
+ }
+
+ complete_apps = ['accounts']
View
@@ -1,7 +1,15 @@
# -*- coding: utf-8 -*-
from django.db import models
from django.contrib.auth.models import User
+from accounts.constants import NOTIFICATIONS_SETTINGS
+from crawler.constants import CRAWLER_VISITS_FREQ
class UserProfile(models.Model):
""" User profile """
- user = models.OneToOneField(User, unique=True)
+ user = models.OneToOneField(User, unique=True)
+ # user preferences (scan defaults for newly created Task)
+ notifications_settings = models.CharField(max_length=32, choices=NOTIFICATIONS_SETTINGS, default='dashboard-only')
+ crawler_visits_frequency = models.CharField(max_length=16, choices=CRAWLER_VISITS_FREQ, default='daily')
+ limit_link_types = models.CharField(max_length=32, default=u'web css js img') # space separated link types
+ def __unicode__(self):
+ return u'Profile for %s' % self
View
@@ -0,0 +1,8 @@
+# -*- coding: utf-8 -*-
+CRAWLER_VISITS_FREQ = (
+ ('hourly', u'Every hour'),
+ ('daily', u'Daily'),
+ ('weekly', u'Weekly'),
+ ('twice-a-week', u'Twice a week'),
+)
+

0 comments on commit 48db463

Please sign in to comment.