online adapt
authorHongyuan Ma <CS_MaleicAcid@163.com>
Wed, 8 Aug 2018 17:03:40 +0000 (01:03 +0800)
committerHongyuan Ma <CS_MaleicAcid@163.com>
Wed, 8 Aug 2018 17:03:40 +0000 (01:03 +0800)
web/apps/test_records/admin.py
web/apps/users/admin.py
web/db_tools/data/alias_data.py
web/db_tools/import_alias_data.py
web/db_tools/import_category_data.py
web/db_tools/import_machine_data.py

index 6d695ffd24faf7afc408c4bec4c0b84470471b0c..edd026086c399989dd40ba859200e031204b4d50 100644 (file)
@@ -10,7 +10,6 @@ from .models import TestRecord, TestBranch
 class TestRecordAdmin(admin.ModelAdmin):
     list_display = ('id', 'branch', 'uuid', 'test_machine')
     list_filter = ('branch',)
-    actions = ['approve_machine']
 
 admin.site.register(TestRecord, TestRecordAdmin)
 
index f9224ff85046d58f5afdf5a11f16c8177b24dcf2..2c31eefef45325a2c44ff3226735f44168b9f8c6 100644 (file)
@@ -18,7 +18,7 @@ admin.site.register(UserProfile, UserProfileAdmin)
 class UserMachineAdmin(admin.ModelAdmin):
     list_display = ('id', 'alias', 'state', 'machine_sn', 'machine_secret', )
     list_filter = ('state',)
-    actions = ['approve_machine']
+    actions = ['approve_machine','only_approve']
 
     def approve_machine(self, request, queryset):
 
@@ -62,6 +62,29 @@ PG PERF FARM" % (ret['alias'], ret['secret'], ret['system'], ret['compiler'])
 
     approve_machine.short_description = u'Approve Machine(Modify the state to active, generate machine_sn, machine_secret and assign an alias)'
 
+    def only_approve(self, request, queryset):
+
+        total = 0
+        error = 0
+        success = 0
+        for machine in queryset:
+
+            ret = machine.approve_machine()
+            # ret = {"is_success": True, "alias": self.alias.name, "secret": self.machine_secret, "system": system,  "compiler":compiler,"email":user_email}
+
+            if ret['is_success']:
+                success += 1
+            else:
+                error += 1
+
+            total += 1
+
+        # rows_updated = queryset.update(state=1)
+        # message_bit = "%s machine(s)" % rows_updated
+        self.message_user(request,
+                          "Total: %s ,Success: %s ,Error: %s. Please make sure there are enough unused aliases." % (
+                              total, success, error))
+    only_approve.short_description = u'Approve Machine(with send emails)'
 
 admin.site.register(UserMachine, UserMachineAdmin)
 
index d9a643b49d7dc5f1b8a01bbadf0190952b300093..5f4d11bbcafebb25ce41d9bdb3a166696124c288 100644 (file)
@@ -1,11 +1,11 @@
 row_data = [
     {
         'name': 'Avocado',
-        'is_used': True
+        'is_used': False
     },
     {
         'name': 'Cabbage',
-        'is_used': True
+        'is_used': False
     },
     {
         'name': 'Cucumber',
index 05a1f9c70a8d0befe3039d4009856832f88032ca..8f9902a2d4104f23e5413c619152f694846bcc89 100644 (file)
@@ -1,6 +1,6 @@
 import sys
 import os
-from pgperffarm.settings import PORJECT_PATH
+from path import PORJECT_PATH
 # Use django's model independently
 pwd = os.path.dirname(os.path.realpath(__file__))
 sys.path.append(pwd)
index f603ee2feffb94b541ef71f2845bb8120a4e796f..09e7146563d9ae54a04bc97cf131fee7ebb2b975 100644 (file)
@@ -1,6 +1,6 @@
 import sys
 import os
-from pgperffarm.settings import PORJECT_PATH
+from path import PORJECT_PATH
 # Use django's model independently
 pwd = os.path.dirname(os.path.realpath(__file__))
 sys.path.append(pwd+ "../")
index 54230364666dc9d29f60fa01bd6f7461d4a3f3ea..2f4e4257d13ed25a73c7aa532fef5c61def03a7c 100644 (file)
@@ -1,6 +1,6 @@
 import sys
 import os
-from pgperffarm.settings import PORJECT_PATH
+from path import PORJECT_PATH
 # Use django's model independently
 pwd = os.path.dirname(os.path.realpath(__file__))
 sys.path.append(pwd+ "../")