Mikhail Korobov avatar Mikhail Korobov committed 225c184

Data URL can be regenerated

Comments (0)

Files changed (2)

 from django.contrib import admin
+from django import forms
 from netcash.models import NetcashGateway, NetcashOrder
 
+
 class NetcashGatewayAdmin(admin.ModelAdmin):
+
+    class form(forms.ModelForm):
+        regenerate_secret = forms.BooleanField(initial=False, required=False,
+            help_text='<span style="color:red">Check this in order to regenerate the Data URL. Be careful!</span>')
+
+        def save(self, *args, **kwargs):
+            instance = super(NetcashGatewayAdmin.form, self).save(*args, **kwargs)
+            if self.cleaned_data['regenerate_secret']:
+                instance.secret=None
+                instance.save()
+            return instance
+
+        class Meta:
+            model = NetcashGateway
+
     list_display = ['name', 'data_url', 'accept_url', 'reject_url', 'netcash_ip']
+    readonly_fields = ['data_url', 'accept_url', 'reject_url']
 
 class NetcashOrderAdmin(admin.ModelAdmin):
 
 
 setup(
     name='django-netcash',
-    version='0.1.11',
+    version='0.2',
     author='Mikhail Korobov',
     author_email='kmike84@gmail.com',
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.