mirror of
https://github.com/nikdoof/pacmanager.git
synced 2025-12-13 07:32:15 +00:00
Add storage of API error messages
This commit is contained in:
@@ -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']
|
||||
@@ -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):
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
<td>{% if perms.delete_key %}<a href="#" class="delete" id="{{ obj.pk }}" title="Remove"><i class="icon-remove"></i></a> {% endif %}
|
||||
<a href="#" class="refresh" id="{{ obj.pk }}" title="Refresh"><i class="icon-repeat"></i></a>
|
||||
<a href="#" class="import" id="{{ obj.pk }}" title="Import Wallet"><i class="icon-download-alt"></i></a>
|
||||
{% if obj.error %}<i class="icon-exclamation-sign" alt="{{ obj.error }}"></i>{% endif %}
|
||||
</td></tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
||||
Reference in New Issue
Block a user