diff --git a/pacmanager/core/migrations/0004_auto__add_field_apicache_error.py b/pacmanager/core/migrations/0004_auto__add_field_apicache_error.py new file mode 100644 index 0000000..664c75c --- /dev/null +++ b/pacmanager/core/migrations/0004_auto__add_field_apicache_error.py @@ -0,0 +1,118 @@ +# -*- 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 field 'APICache.error' + db.add_column('core_apicache', 'error', + self.gf('django.db.models.fields.CharField')(max_length=512, null=True), + keep_default=False) + + def backwards(self, orm): + # Deleting field 'APICache.error' + db.delete_column('core_apicache', 'error') + + 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'}) + }, + 'core.apicache': { + 'Meta': {'object_name': 'APICache'}, + 'cache_until': ('django.db.models.fields.DateTimeField', [], {}), + 'document': ('django.db.models.fields.TextField', [], {}), + 'error': ('django.db.models.fields.CharField', [], {'max_length': '512', 'null': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'key': ('django.db.models.fields.CharField', [], {'max_length': '40'}) + }, + 'core.character': { + 'Meta': {'object_name': 'Character'}, + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + 'core.corporation': { + 'Meta': {'object_name': 'Corporation'}, + 'balance': ('django.db.models.fields.DecimalField', [], {'default': '0', 'max_digits': '25', 'decimal_places': '2'}), + 'ceo': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': "orm['core.Character']"}), + 'contact': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'corporations'", 'null': 'True', 'to': "orm['auth.User']"}), + 'fixed_value': ('django.db.models.fields.DecimalField', [], {'default': 'None', 'null': 'True', 'max_digits': '25', 'decimal_places': '2', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'last_transaction': ('django.db.models.fields.BigIntegerField', [], {'default': '0'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'payment_id': ('django.db.models.fields.CharField', [], {'max_length': '36'}), + 'tax_rate': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}) + }, + 'core.key': { + 'Meta': {'object_name': 'Key'}, + 'active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'corporation': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'keys'", 'to': "orm['core.Corporation']"}), + 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'keyid': ('django.db.models.fields.BigIntegerField', [], {'primary_key': 'True'}), + 'mask': ('django.db.models.fields.BigIntegerField', [], {}), + 'update': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), + 'vcode': ('django.db.models.fields.CharField', [], {'max_length': '64'}) + }, + 'core.monthtotal': { + 'Meta': {'ordering': "['-year', '-month']", 'object_name': 'MonthTotal'}, + 'charged': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'corporation': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'totals'", 'to': "orm['core.Corporation']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'month': ('django.db.models.fields.PositiveIntegerField', [], {}), + 'tax': ('django.db.models.fields.DecimalField', [], {'default': '0', 'max_digits': '25', 'decimal_places': '2'}), + 'year': ('django.db.models.fields.PositiveIntegerField', [], {}) + }, + 'core.setting': { + 'Meta': {'object_name': 'Setting'}, + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'key': ('django.db.models.fields.CharField', [], {'max_length': '32'}), + 'value': ('django.db.models.fields.CharField', [], {'max_length': '200'}) + }, + 'core.transaction': { + 'Meta': {'ordering': "['-date']", 'object_name': 'Transaction'}, + 'comment': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'corporation': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'transactions'", 'to': "orm['core.Corporation']"}), + 'date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'type': ('django.db.models.fields.PositiveIntegerField', [], {}), + 'value': ('django.db.models.fields.DecimalField', [], {'max_digits': '25', 'decimal_places': '2'}) + } + } + + complete_apps = ['core'] \ No newline at end of file diff --git a/pacmanager/core/models.py b/pacmanager/core/models.py index 5952299..af71b12 100644 --- a/pacmanager/core/models.py +++ b/pacmanager/core/models.py @@ -154,6 +154,7 @@ class APICache(models.Model): key = models.CharField('Cache Key', blank=False, max_length=40) cache_until = models.DateTimeField('Cached Until', blank=False) document = models.TextField('Document') + error = models.CharField('API Error', blank=False, null=True, max_length=512) class DjangoCacheHandler(object): diff --git a/pacmanager/core/tasks.py b/pacmanager/core/tasks.py index b713c04..44ef737 100644 --- a/pacmanager/core/tasks.py +++ b/pacmanager/core/tasks.py @@ -20,12 +20,15 @@ def import_wallet_journal(corporation_id): def get_records(corp=None, fromID=None, rowCount=2560): if fromID and fromID <= corp.last_transaction: return None - #print "get_records: ", corp, fromID try: res = auth.corp.WalletJournal(rowCount=rowCount, fromID=fromID) except Error, e: print e + key.error = str(e) + key.save() else: + key.error = None + key.save() if type(res.entries) == str: return None entries = res.entries.SortedBy('refID', reverse=True) if len(entries) == rowCount: diff --git a/pacmanager/core/templates/core/key_list.html b/pacmanager/core/templates/core/key_list.html index 7cc6857..760a65c 100644 --- a/pacmanager/core/templates/core/key_list.html +++ b/pacmanager/core/templates/core/key_list.html @@ -14,6 +14,7 @@