summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHongyuan Ma2018-08-08 17:03:40 +0000
committerHongyuan Ma2018-08-08 17:03:40 +0000
commit450013a05fe531f706536681b2a196344b1587e0 (patch)
treeea2e38f8227d9f7d272c81b6c81243be34118d3f
parent54af3cc5196a593d72688fd90d719c629ff0f05c (diff)
online adapt
-rw-r--r--web/apps/test_records/admin.py1
-rw-r--r--web/apps/users/admin.py25
-rw-r--r--web/db_tools/data/alias_data.py4
-rw-r--r--web/db_tools/import_alias_data.py2
-rw-r--r--web/db_tools/import_category_data.py2
-rw-r--r--web/db_tools/import_machine_data.py2
6 files changed, 29 insertions, 7 deletions
diff --git a/web/apps/test_records/admin.py b/web/apps/test_records/admin.py
index 6d695ff..edd0260 100644
--- a/web/apps/test_records/admin.py
+++ b/web/apps/test_records/admin.py
@@ -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)
diff --git a/web/apps/users/admin.py b/web/apps/users/admin.py
index f9224ff..2c31eef 100644
--- a/web/apps/users/admin.py
+++ b/web/apps/users/admin.py
@@ -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)
diff --git a/web/db_tools/data/alias_data.py b/web/db_tools/data/alias_data.py
index d9a643b..5f4d11b 100644
--- a/web/db_tools/data/alias_data.py
+++ b/web/db_tools/data/alias_data.py
@@ -1,11 +1,11 @@
row_data = [
{
'name': 'Avocado',
- 'is_used': True
+ 'is_used': False
},
{
'name': 'Cabbage',
- 'is_used': True
+ 'is_used': False
},
{
'name': 'Cucumber',
diff --git a/web/db_tools/import_alias_data.py b/web/db_tools/import_alias_data.py
index 05a1f9c..8f9902a 100644
--- a/web/db_tools/import_alias_data.py
+++ b/web/db_tools/import_alias_data.py
@@ -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)
diff --git a/web/db_tools/import_category_data.py b/web/db_tools/import_category_data.py
index f603ee2..09e7146 100644
--- a/web/db_tools/import_category_data.py
+++ b/web/db_tools/import_category_data.py
@@ -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+ "../")
diff --git a/web/db_tools/import_machine_data.py b/web/db_tools/import_machine_data.py
index 5423036..2f4e425 100644
--- a/web/db_tools/import_machine_data.py
+++ b/web/db_tools/import_machine_data.py
@@ -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+ "../")