@@ -0,0 +1,10 | |||||
|
1 | {% extends "abscontrol/index.html" %} | |||
|
2 | {% block title %}ABS CONTROL:::::SENDING FILE{% endblock %} | |||
|
3 | ||||
|
4 | {% block maincolumn %} | |||
|
5 | <div id="maincolumn"> | |||
|
6 | <div class="divMessage"> | |||
|
7 | <label>{{ message }}</label> | |||
|
8 | </div> | |||
|
9 | </div> | |||
|
10 | {% endblock %} No newline at end of file |
@@ -1,159 +1,161 | |||||
1 | # Django settings for abs_webapp_dev project. |
|
1 | # Django settings for abs_webapp_dev project. | |
2 |
|
2 | |||
3 | import os |
|
3 | import os, sys | |
4 | PROJECT_DIR = os.path.split(os.path.dirname(__file__))[0] |
|
4 | PROJECT_DIR = os.path.split(os.path.dirname(__file__))[0] | |
|
5 | API_DIR = "/home/dev/workspace/absclient" | |||
|
6 | sys.path.append(API_DIR) | |||
5 |
|
7 | |||
6 | DEBUG = True |
|
8 | DEBUG = True | |
7 | TEMPLATE_DEBUG = DEBUG |
|
9 | TEMPLATE_DEBUG = DEBUG | |
8 |
|
10 | |||
9 | ADMINS = ( |
|
11 | ADMINS = ( | |
10 | # ('Your Name', 'your_email@example.com'), |
|
12 | # ('Your Name', 'your_email@example.com'), | |
11 | ) |
|
13 | ) | |
12 |
|
14 | |||
13 | MANAGERS = ADMINS |
|
15 | MANAGERS = ADMINS | |
14 |
|
16 | |||
15 | DATABASES = { |
|
17 | DATABASES = { | |
16 | 'default': { |
|
18 | 'default': { | |
17 | 'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. |
|
19 | 'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. | |
18 | 'NAME': 'db_jrowebapp_dev', # Or path to database file if using sqlite3. |
|
20 | 'NAME': 'db_jrowebapp_dev', # Or path to database file if using sqlite3. | |
19 | 'USER': 'abscontrol', # Not used with sqlite3. |
|
21 | 'USER': 'abscontrol', # Not used with sqlite3. | |
20 | 'PASSWORD': 'abscontrol', # Not used with sqlite3. |
|
22 | 'PASSWORD': 'abscontrol', # Not used with sqlite3. | |
21 | 'HOST': 'localhost', # Set to empty string for localhost. Not used with sqlite3. |
|
23 | 'HOST': 'localhost', # Set to empty string for localhost. Not used with sqlite3. | |
22 | 'PORT': '3306', # Set to empty string for default. Not used with sqlite3. |
|
24 | 'PORT': '3306', # Set to empty string for default. Not used with sqlite3. | |
23 | } |
|
25 | } | |
24 | } |
|
26 | } | |
25 |
|
27 | |||
26 | # Local time zone for this installation. Choices can be found here: |
|
28 | # Local time zone for this installation. Choices can be found here: | |
27 | # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name |
|
29 | # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name | |
28 | # although not all choices may be available on all operating systems. |
|
30 | # although not all choices may be available on all operating systems. | |
29 | # In a Windows environment this must be set to your system time zone. |
|
31 | # In a Windows environment this must be set to your system time zone. | |
30 | TIME_ZONE = 'America/Lima' |
|
32 | TIME_ZONE = 'America/Lima' | |
31 |
|
33 | |||
32 | # Language code for this installation. All choices can be found here: |
|
34 | # Language code for this installation. All choices can be found here: | |
33 | # http://www.i18nguy.com/unicode/language-identifiers.html |
|
35 | # http://www.i18nguy.com/unicode/language-identifiers.html | |
34 | LANGUAGE_CODE = 'en-us' |
|
36 | LANGUAGE_CODE = 'en-us' | |
35 |
|
37 | |||
36 | SITE_ID = 1 |
|
38 | SITE_ID = 1 | |
37 |
|
39 | |||
38 | # If you set this to False, Django will make some optimizations so as not |
|
40 | # If you set this to False, Django will make some optimizations so as not | |
39 | # to load the internationalization machinery. |
|
41 | # to load the internationalization machinery. | |
40 | USE_I18N = True |
|
42 | USE_I18N = True | |
41 |
|
43 | |||
42 | # If you set this to False, Django will not format dates, numbers and |
|
44 | # If you set this to False, Django will not format dates, numbers and | |
43 | # calendars according to the current locale. |
|
45 | # calendars according to the current locale. | |
44 | USE_L10N = True |
|
46 | USE_L10N = True | |
45 |
|
47 | |||
46 | # If you set this to False, Django will not use timezone-aware datetimes. |
|
48 | # If you set this to False, Django will not use timezone-aware datetimes. | |
47 | USE_TZ = True |
|
49 | USE_TZ = True | |
48 |
|
50 | |||
49 | # Absolute filesystem path to the directory that will hold user-uploaded files. |
|
51 | # Absolute filesystem path to the directory that will hold user-uploaded files. | |
50 | # Example: "/home/media/media.lawrence.com/media/" |
|
52 | # Example: "/home/media/media.lawrence.com/media/" | |
51 | MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media').replace('\\', '/') |
|
53 | MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media').replace('\\', '/') | |
52 |
|
54 | |||
53 | # URL that handles the media served from MEDIA_ROOT. Make sure to use a |
|
55 | # URL that handles the media served from MEDIA_ROOT. Make sure to use a | |
54 | # trailing slash. |
|
56 | # trailing slash. | |
55 | # Examples: "http://media.lawrence.com/media/", "http://example.com/media/" |
|
57 | # Examples: "http://media.lawrence.com/media/", "http://example.com/media/" | |
56 | MEDIA_URL = '/media/' |
|
58 | MEDIA_URL = '/media/' | |
57 |
|
59 | |||
58 | # Absolute path to the directory static files should be collected to. |
|
60 | # Absolute path to the directory static files should be collected to. | |
59 | # Don't put anything in this directory yourself; store your static files |
|
61 | # Don't put anything in this directory yourself; store your static files | |
60 | # in apps' "static/" subdirectories and in STATICFILES_DIRS. |
|
62 | # in apps' "static/" subdirectories and in STATICFILES_DIRS. | |
61 | # Example: "/home/media/media.lawrence.com/static/" |
|
63 | # Example: "/home/media/media.lawrence.com/static/" | |
62 | #STATIC_ROOT = os.path.join(PROJECT_DIR, 'static-serve').replace('\\', '/'), |
|
64 | #STATIC_ROOT = os.path.join(PROJECT_DIR, 'static-serve').replace('\\', '/'), | |
63 | STATIC_ROOT = '' |
|
65 | STATIC_ROOT = '' | |
64 |
|
66 | |||
65 | # URL prefix for static files. |
|
67 | # URL prefix for static files. | |
66 | # Example: "http://media.lawrence.com/static/" |
|
68 | # Example: "http://media.lawrence.com/static/" | |
67 | STATIC_URL = '/static/' |
|
69 | STATIC_URL = '/static/' | |
68 |
|
70 | |||
69 | # Additional locations of static files |
|
71 | # Additional locations of static files | |
70 | STATICFILES_DIRS = ( |
|
72 | STATICFILES_DIRS = ( | |
71 | # Put strings here, like "/home/html/static" or "C:/www/django/static". |
|
73 | # Put strings here, like "/home/html/static" or "C:/www/django/static". | |
72 | # Always use forward slashes, even on Windows. |
|
74 | # Always use forward slashes, even on Windows. | |
73 | # Don't forget to use absolute paths, not relative paths. |
|
75 | # Don't forget to use absolute paths, not relative paths. | |
74 | #os.path.join(PROJECT_DIR, "static").replace('\\', '/'), |
|
76 | #os.path.join(PROJECT_DIR, "static").replace('\\', '/'), | |
75 | ("static", os.path.join(PROJECT_DIR, "static").replace('\\', '/')), |
|
77 | ("static", os.path.join(PROJECT_DIR, "static").replace('\\', '/')), | |
76 | ) |
|
78 | ) | |
77 |
|
79 | |||
78 | # List of finder classes that know how to find static files in |
|
80 | # List of finder classes that know how to find static files in | |
79 | # various locations. |
|
81 | # various locations. | |
80 | STATICFILES_FINDERS = ( |
|
82 | STATICFILES_FINDERS = ( | |
81 | 'django.contrib.staticfiles.finders.FileSystemFinder', |
|
83 | 'django.contrib.staticfiles.finders.FileSystemFinder', | |
82 | 'django.contrib.staticfiles.finders.AppDirectoriesFinder', |
|
84 | 'django.contrib.staticfiles.finders.AppDirectoriesFinder', | |
83 | # 'django.contrib.staticfiles.finders.DefaultStorageFinder', |
|
85 | # 'django.contrib.staticfiles.finders.DefaultStorageFinder', | |
84 | ) |
|
86 | ) | |
85 |
|
87 | |||
86 | # Make this unique, and don't share it with anybody. |
|
88 | # Make this unique, and don't share it with anybody. | |
87 | SECRET_KEY = '=^abu)gd=)7hf#rme_vw=tv!bdh7+tts*^&)h(n=7@7(9#__@e' |
|
89 | SECRET_KEY = '=^abu)gd=)7hf#rme_vw=tv!bdh7+tts*^&)h(n=7@7(9#__@e' | |
88 |
|
90 | |||
89 | # List of callables that know how to import templates from various sources. |
|
91 | # List of callables that know how to import templates from various sources. | |
90 | TEMPLATE_LOADERS = ( |
|
92 | TEMPLATE_LOADERS = ( | |
91 | 'django.template.loaders.filesystem.Loader', |
|
93 | 'django.template.loaders.filesystem.Loader', | |
92 | 'django.template.loaders.app_directories.Loader', |
|
94 | 'django.template.loaders.app_directories.Loader', | |
93 | # 'django.template.loaders.eggs.Loader', |
|
95 | # 'django.template.loaders.eggs.Loader', | |
94 | ) |
|
96 | ) | |
95 |
|
97 | |||
96 | MIDDLEWARE_CLASSES = ( |
|
98 | MIDDLEWARE_CLASSES = ( | |
97 | 'django.middleware.common.CommonMiddleware', |
|
99 | 'django.middleware.common.CommonMiddleware', | |
98 | 'django.contrib.sessions.middleware.SessionMiddleware', |
|
100 | 'django.contrib.sessions.middleware.SessionMiddleware', | |
99 | #'django.middleware.csrf.CsrfViewMiddleware', |
|
101 | #'django.middleware.csrf.CsrfViewMiddleware', | |
100 | 'django.contrib.auth.middleware.AuthenticationMiddleware', |
|
102 | 'django.contrib.auth.middleware.AuthenticationMiddleware', | |
101 | 'django.contrib.messages.middleware.MessageMiddleware', |
|
103 | 'django.contrib.messages.middleware.MessageMiddleware', | |
102 | # Uncomment the next line for simple clickjacking protection: |
|
104 | # Uncomment the next line for simple clickjacking protection: | |
103 | # 'django.middleware.clickjacking.XFrameOptionsMiddleware', |
|
105 | # 'django.middleware.clickjacking.XFrameOptionsMiddleware', | |
104 | ) |
|
106 | ) | |
105 |
|
107 | |||
106 | ROOT_URLCONF = 'abs_webapp_dev.urls' |
|
108 | ROOT_URLCONF = 'abs_webapp_dev.urls' | |
107 |
|
109 | |||
108 | # Python dotted path to the WSGI application used by Django's runserver. |
|
110 | # Python dotted path to the WSGI application used by Django's runserver. | |
109 | WSGI_APPLICATION = 'abs_webapp_dev.wsgi.application' |
|
111 | WSGI_APPLICATION = 'abs_webapp_dev.wsgi.application' | |
110 |
|
112 | |||
111 | TEMPLATE_DIRS = ( |
|
113 | TEMPLATE_DIRS = ( | |
112 | # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". |
|
114 | # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". | |
113 | # Always use forward slashes, even on Windows. |
|
115 | # Always use forward slashes, even on Windows. | |
114 | # Don't forget to use absolute paths, not relative paths. |
|
116 | # Don't forget to use absolute paths, not relative paths. | |
115 | os.path.join(PROJECT_DIR, "templates").replace('\\', '/'), |
|
117 | os.path.join(PROJECT_DIR, "templates").replace('\\', '/'), | |
116 | ) |
|
118 | ) | |
117 |
|
119 | |||
118 | INSTALLED_APPS = ( |
|
120 | INSTALLED_APPS = ( | |
119 | 'django.contrib.auth', |
|
121 | 'django.contrib.auth', | |
120 | 'django.contrib.contenttypes', |
|
122 | 'django.contrib.contenttypes', | |
121 | 'django.contrib.sessions', |
|
123 | 'django.contrib.sessions', | |
122 | 'django.contrib.sites', |
|
124 | 'django.contrib.sites', | |
123 | 'django.contrib.messages', |
|
125 | 'django.contrib.messages', | |
124 | 'django.contrib.staticfiles', |
|
126 | 'django.contrib.staticfiles', | |
125 | # Uncomment the next line to enable the admin: |
|
127 | # Uncomment the next line to enable the admin: | |
126 | 'django.contrib.admin', |
|
128 | 'django.contrib.admin', | |
127 | # Uncomment the next line to enable admin documentation: |
|
129 | # Uncomment the next line to enable admin documentation: | |
128 | # 'django.contrib.admindocs', |
|
130 | # 'django.contrib.admindocs', | |
129 | 'abscontrol', |
|
131 | 'abscontrol', | |
130 | ) |
|
132 | ) | |
131 |
|
133 | |||
132 | # A sample logging configuration. The only tangible logging |
|
134 | # A sample logging configuration. The only tangible logging | |
133 | # performed by this configuration is to send an email to |
|
135 | # performed by this configuration is to send an email to | |
134 | # the site admins on every HTTP 500 error when DEBUG=False. |
|
136 | # the site admins on every HTTP 500 error when DEBUG=False. | |
135 | # See http://docs.djangoproject.com/en/dev/topics/logging for |
|
137 | # See http://docs.djangoproject.com/en/dev/topics/logging for | |
136 | # more details on how to customize your logging configuration. |
|
138 | # more details on how to customize your logging configuration. | |
137 | LOGGING = { |
|
139 | LOGGING = { | |
138 | 'version': 1, |
|
140 | 'version': 1, | |
139 | 'disable_existing_loggers': False, |
|
141 | 'disable_existing_loggers': False, | |
140 | 'filters': { |
|
142 | 'filters': { | |
141 | 'require_debug_false': { |
|
143 | 'require_debug_false': { | |
142 | '()': 'django.utils.log.RequireDebugFalse' |
|
144 | '()': 'django.utils.log.RequireDebugFalse' | |
143 | } |
|
145 | } | |
144 | }, |
|
146 | }, | |
145 | 'handlers': { |
|
147 | 'handlers': { | |
146 | 'mail_admins': { |
|
148 | 'mail_admins': { | |
147 | 'level': 'ERROR', |
|
149 | 'level': 'ERROR', | |
148 | 'filters': ['require_debug_false'], |
|
150 | 'filters': ['require_debug_false'], | |
149 | 'class': 'django.utils.log.AdminEmailHandler' |
|
151 | 'class': 'django.utils.log.AdminEmailHandler' | |
150 | } |
|
152 | } | |
151 | }, |
|
153 | }, | |
152 | 'loggers': { |
|
154 | 'loggers': { | |
153 | 'django.request': { |
|
155 | 'django.request': { | |
154 | 'handlers': ['mail_admins'], |
|
156 | 'handlers': ['mail_admins'], | |
155 | 'level': 'ERROR', |
|
157 | 'level': 'ERROR', | |
156 | 'propagate': True, |
|
158 | 'propagate': True, | |
157 | }, |
|
159 | }, | |
158 | } |
|
160 | } | |
159 | } |
|
161 | } |
@@ -1,22 +1,23 | |||||
1 | from django.conf.urls import patterns, url |
|
1 | from django.conf.urls import patterns, url | |
2 |
|
2 | |||
3 | urlpatterns = patterns('abscontrol.views', |
|
3 | urlpatterns = patterns('abscontrol.views', | |
4 | url(r'^$', 'index'), |
|
4 | url(r'^$', 'index'), | |
5 | url(r'^new/$', 'new'), |
|
5 | url(r'^new/$', 'new'), | |
6 | url(r'^save/$', 'save'), |
|
6 | url(r'^save/$', 'save'), | |
7 | url(r'^view/(?P<profile_id>\d+)/$', 'view'), |
|
7 | url(r'^view/(?P<profile_id>\d+)/$', 'view'), | |
8 | url(r'^edit/(?P<profile_id>\d+)/$', 'edit'), |
|
8 | url(r'^edit/(?P<profile_id>\d+)/$', 'edit'), | |
9 | #url(r'^(?P<profile_id>\d+)/$', 'detail'), |
|
9 | #url(r'^(?P<profile_id>\d+)/$', 'detail'), | |
10 | url(r'^(?P<profile_id>\d+)/add/$', 'addPattern'), |
|
10 | url(r'^(?P<profile_id>\d+)/add/$', 'addPattern'), | |
11 | url(r'^(?P<profile_id>\d+)/save/$', 'savePattern'), |
|
11 | url(r'^(?P<profile_id>\d+)/save/$', 'savePattern'), | |
12 | url(r'^(?P<profile_id>\d+)/edit/(?P<pattern_id>\d+)/$', 'editPattern'), |
|
12 | url(r'^(?P<profile_id>\d+)/edit/(?P<pattern_id>\d+)/$', 'editPattern'), | |
13 | url(r'^(?P<profile_id>\d+)/view/(?P<pattern_id>\d+)/$', 'viewPattern'), |
|
13 | url(r'^(?P<profile_id>\d+)/view/(?P<pattern_id>\d+)/$', 'viewPattern'), | |
14 | url(r'^(?P<profile_id>\d+)/delete/(?P<pattern_id>\d+)/$', 'deletePattern'), |
|
14 | url(r'^(?P<profile_id>\d+)/delete/(?P<pattern_id>\d+)/$', 'deletePattern'), | |
15 | #url(r'^(?P<poll_id>\d+)/results/$', 'results'), |
|
15 | #url(r'^(?P<poll_id>\d+)/results/$', 'results'), | |
16 | #url(r'^(?P<poll_id>\d+)/vote/$', 'vote'), |
|
16 | #url(r'^(?P<poll_id>\d+)/vote/$', 'vote'), | |
17 | url(r'^import/$', 'importProfile'), |
|
17 | url(r'^import/$', 'importProfile'), | |
18 | url(r'^showImport/$', 'showImport'), |
|
18 | url(r'^showImport/$', 'showImport'), | |
19 | url(r'^saveImport/$', 'saveImport'), |
|
19 | url(r'^saveImport/$', 'saveImport'), | |
20 | url(r'^(?P<profile_id>\d+)/(?P<pattern_id>\d+)/overjro/(?P<antenna_id>\d+)/$', 'overJRO'), |
|
20 | url(r'^(?P<profile_id>\d+)/(?P<pattern_id>\d+)/overjro/(?P<antenna_id>\d+)/$', 'overJRO'), | |
21 | url(r'^export/(?P<profile_id>\d+)/$', 'export'), |
|
21 | url(r'^export/(?P<profile_id>\d+)/$', 'export'), | |
|
22 | url(r'^send/(?P<profile_id>\d+)/$', 'send'), | |||
22 | ) No newline at end of file |
|
23 | ) |
@@ -1,344 +1,374 | |||||
1 | from django.shortcuts import render_to_response, redirect |
|
1 | from django.shortcuts import render_to_response, redirect | |
2 | from django.http import HttpResponse |
|
2 | from django.http import HttpResponse | |
3 | from django.conf import settings |
|
3 | from django.conf import settings | |
4 | from django.utils.encoding import smart_str |
|
4 | from django.utils.encoding import smart_str | |
5 | from django.core.servers.basehttp import FileWrapper |
|
5 | from django.core.servers.basehttp import FileWrapper | |
6 | import mimetypes |
|
6 | import mimetypes | |
7 | from abscontrol.models import Profile, Pattern, AntennaDown, AntennaUp |
|
7 | from abscontrol.models import Profile, Pattern, AntennaDown, AntennaUp | |
8 | from util.readABSFile import readABSFile |
|
8 | from util.readABSFile import readABSFile | |
9 | from util.saveABSFile import saveABSFile |
|
9 | from util.saveABSFile import saveABSFile | |
10 |
|
10 | from scripts.sendFile import sendFile | ||
11 |
|
11 | |||
12 | txtAntenna = "[[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5]," \ |
|
12 | txtAntenna = "[[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5]," \ | |
13 | "[1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0]," \ |
|
13 | "[1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0]," \ | |
14 | "[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5]," \ |
|
14 | "[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5]," \ | |
15 | "[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5]," \ |
|
15 | "[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5]," \ | |
16 | "[1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0]," \ |
|
16 | "[1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0]," \ | |
17 | "[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5]," \ |
|
17 | "[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5]," \ | |
18 | "[1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0]," \ |
|
18 | "[1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0]," \ | |
19 | "[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5]]" |
|
19 | "[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5]]" | |
20 |
|
20 | |||
21 | txtTxUp = "[[1,1,1,1,1,1,1,1]," \ |
|
21 | txtTxUp = "[[1,1,1,1,1,1,1,1]," \ | |
22 | "[1,1,1,1,1,1,1,1]," \ |
|
22 | "[1,1,1,1,1,1,1,1]," \ | |
23 | "[1,1,1,1,1,1,1,1]," \ |
|
23 | "[1,1,1,1,1,1,1,1]," \ | |
24 | "[1,1,1,1,1,1,1,1]," \ |
|
24 | "[1,1,1,1,1,1,1,1]," \ | |
25 | "[1,1,1,1,1,1,1,1]," \ |
|
25 | "[1,1,1,1,1,1,1,1]," \ | |
26 | "[1,1,1,1,1,1,1,1]," \ |
|
26 | "[1,1,1,1,1,1,1,1]," \ | |
27 | "[1,1,1,1,1,1,1,1]," \ |
|
27 | "[1,1,1,1,1,1,1,1]," \ | |
28 | "[1,1,1,1,1,1,1,1]]" |
|
28 | "[1,1,1,1,1,1,1,1]]" | |
29 |
|
29 | |||
30 | txtTxDown = "[[1,1,1,1,0,0,0,0]," \ |
|
30 | txtTxDown = "[[1,1,1,1,0,0,0,0]," \ | |
31 | "[1,1,1,1,0,0,0,0]," \ |
|
31 | "[1,1,1,1,0,0,0,0]," \ | |
32 | "[1,1,1,1,0,0,0,0]," \ |
|
32 | "[1,1,1,1,0,0,0,0]," \ | |
33 | "[1,1,1,1,0,0,0,0]," \ |
|
33 | "[1,1,1,1,0,0,0,0]," \ | |
34 | "[0,0,0,0,1,1,1,1]," \ |
|
34 | "[0,0,0,0,1,1,1,1]," \ | |
35 | "[0,0,0,0,1,1,1,1]," \ |
|
35 | "[0,0,0,0,1,1,1,1]," \ | |
36 | "[0,0,0,0,1,1,1,1]," \ |
|
36 | "[0,0,0,0,1,1,1,1]," \ | |
37 | "[0,0,0,0,1,1,1,1]]" |
|
37 | "[0,0,0,0,1,1,1,1]]" | |
38 |
|
38 | |||
39 | txtRxUp = "[[0,0,0,0,1,1,1,1]," \ |
|
39 | txtRxUp = "[[0,0,0,0,1,1,1,1]," \ | |
40 | "[0,0,0,0,1,1,1,1]," \ |
|
40 | "[0,0,0,0,1,1,1,1]," \ | |
41 | "[0,0,0,0,1,1,1,1]," \ |
|
41 | "[0,0,0,0,1,1,1,1]," \ | |
42 | "[0,0,0,0,1,1,1,1]," \ |
|
42 | "[0,0,0,0,1,1,1,1]," \ | |
43 | "[1,1,1,1,1,1,1,1]," \ |
|
43 | "[1,1,1,1,1,1,1,1]," \ | |
44 | "[1,1,1,1,1,1,1,1]," \ |
|
44 | "[1,1,1,1,1,1,1,1]," \ | |
45 | "[1,1,1,1,1,1,1,1]," \ |
|
45 | "[1,1,1,1,1,1,1,1]," \ | |
46 | "[1,1,1,1,1,1,1,1]]" |
|
46 | "[1,1,1,1,1,1,1,1]]" | |
47 |
|
47 | |||
48 | txtRxDown = "[[1,1,1,1,1,1,1,1]," \ |
|
48 | txtRxDown = "[[1,1,1,1,1,1,1,1]," \ | |
49 | "[1,1,1,1,1,1,1,1]," \ |
|
49 | "[1,1,1,1,1,1,1,1]," \ | |
50 | "[1,1,1,1,1,1,1,1]," \ |
|
50 | "[1,1,1,1,1,1,1,1]," \ | |
51 | "[1,1,1,1,1,1,1,1]," \ |
|
51 | "[1,1,1,1,1,1,1,1]," \ | |
52 | "[1,1,1,1,1,1,1,1]," \ |
|
52 | "[1,1,1,1,1,1,1,1]," \ | |
53 | "[1,1,1,1,1,1,1,1]," \ |
|
53 | "[1,1,1,1,1,1,1,1]," \ | |
54 | "[1,1,1,1,1,1,1,1]," \ |
|
54 | "[1,1,1,1,1,1,1,1]," \ | |
55 | "[1,1,1,1,1,1,1,1]]" |
|
55 | "[1,1,1,1,1,1,1,1]]" | |
56 |
|
56 | |||
57 | txtUes = "[0.533333,0.00000,1.06667,0.00000]" |
|
57 | txtUes = "[0.533333,0.00000,1.06667,0.00000]" | |
58 |
|
58 | |||
59 | def index(request): |
|
59 | def index(request): | |
60 | #latest_poll_list = profileAntenna.objects.all().order_by('-pub_date')[:5] |
|
60 | #latest_poll_list = profileAntenna.objects.all().order_by('-pub_date')[:5] | |
61 | profile_list = Profile.objects.all() |
|
61 | profile_list = Profile.objects.all() | |
62 | return render_to_response('abscontrol/index.html', {'profile_list': profile_list}) |
|
62 | return render_to_response('abscontrol/index.html', {'profile_list': profile_list}) | |
63 |
|
63 | |||
64 | def new(request): |
|
64 | def new(request): | |
65 | profile_list = Profile.objects.all() |
|
65 | profile_list = Profile.objects.all() | |
66 |
|
66 | |||
67 | return render_to_response('abscontrol/new.html', {'profile_list': profile_list, |
|
67 | return render_to_response('abscontrol/new.html', {'profile_list': profile_list, | |
68 | 'txtAntenna' : txtAntenna, |
|
68 | 'txtAntenna' : txtAntenna, | |
69 | 'txtUes' : txtUes, 'txtTxUp' : txtTxUp, |
|
69 | 'txtUes' : txtUes, 'txtTxUp' : txtTxUp, | |
70 | 'txtTxDown' : txtTxDown, 'txtRxUp' : txtRxUp, |
|
70 | 'txtTxDown' : txtTxDown, 'txtRxUp' : txtRxUp, | |
71 | 'txtRxDown' : txtRxDown, |
|
71 | 'txtRxDown' : txtRxDown, | |
72 | }) |
|
72 | }) | |
73 |
|
73 | |||
74 | def save(request): |
|
74 | def save(request): | |
75 |
|
75 | |||
76 | txtProfile = request.POST["txtProfile"] |
|
76 | txtProfile = request.POST["txtProfile"] | |
77 |
|
77 | |||
78 | txtAntennaUp = request.POST["txtAntennaUp"] |
|
78 | txtAntennaUp = request.POST["txtAntennaUp"] | |
79 | txtTxUp = request.POST["txtTxUp"] |
|
79 | txtTxUp = request.POST["txtTxUp"] | |
80 | txtRxUp = request.POST["txtRxUp"] |
|
80 | txtRxUp = request.POST["txtRxUp"] | |
81 | txtUesUp = request.POST["txtUesUp"] |
|
81 | txtUesUp = request.POST["txtUesUp"] | |
82 |
|
82 | |||
83 | txtAntennaDown = request.POST["txtAntennaDown"] |
|
83 | txtAntennaDown = request.POST["txtAntennaDown"] | |
84 | txtTxDown = request.POST["txtTxDown"] |
|
84 | txtTxDown = request.POST["txtTxDown"] | |
85 | txtRxDown = request.POST["txtRxDown"] |
|
85 | txtRxDown = request.POST["txtRxDown"] | |
86 | txtUesDown = request.POST["txtUesDown"] |
|
86 | txtUesDown = request.POST["txtUesDown"] | |
87 |
|
87 | |||
88 | newprofile = Profile(name=txtProfile) |
|
88 | newprofile = Profile(name=txtProfile) | |
89 | newprofile.save() |
|
89 | newprofile.save() | |
90 |
|
90 | |||
91 | newpattern = newprofile.pattern_set.create(value=1) |
|
91 | newpattern = newprofile.pattern_set.create(value=1) | |
92 | newpattern.antennaup_set.create(value=txtAntennaUp,tx=txtTxUp,rx=txtRxUp,ues=txtUesUp) |
|
92 | newpattern.antennaup_set.create(value=txtAntennaUp,tx=txtTxUp,rx=txtRxUp,ues=txtUesUp) | |
93 | newpattern.antennadown_set.create(value=txtAntennaDown,tx=txtTxDown,rx=txtRxDown,ues=txtUesDown) |
|
93 | newpattern.antennadown_set.create(value=txtAntennaDown,tx=txtTxDown,rx=txtRxDown,ues=txtUesDown) | |
94 |
|
94 | |||
95 | newurl = '/abscontrol/view/%d' % newprofile.id |
|
95 | newurl = '/abscontrol/view/%d' % newprofile.id | |
96 |
|
96 | |||
97 | return redirect(newurl) |
|
97 | return redirect(newurl) | |
98 |
|
98 | |||
99 | def view(request, profile_id): |
|
99 | def view(request, profile_id): | |
100 | nextPattern = 0 |
|
100 | nextPattern = 0 | |
101 |
|
101 | |||
102 | if request.method == 'GET' and 'pattern' in request.GET: |
|
102 | if request.method == 'GET' and 'pattern' in request.GET: | |
103 | pattern_value = request.GET["pattern"] |
|
103 | pattern_value = request.GET["pattern"] | |
104 | else: |
|
104 | else: | |
105 | pattern_value = 1 |
|
105 | pattern_value = 1 | |
106 |
|
106 | |||
107 | profile_list = Profile.objects.all() |
|
107 | profile_list = Profile.objects.all() | |
108 | objProfile = Profile.objects.get(pk=profile_id) |
|
108 | objProfile = Profile.objects.get(pk=profile_id) | |
109 |
|
109 | |||
110 | lsPatterns = objProfile.pattern_set.all() |
|
110 | lsPatterns = objProfile.pattern_set.all() | |
111 | patternChoosen = objProfile.pattern_set.get(value=pattern_value) |
|
111 | patternChoosen = objProfile.pattern_set.get(value=pattern_value) | |
112 | objAntennaUp = patternChoosen.antennaup_set.get() |
|
112 | objAntennaUp = patternChoosen.antennaup_set.get() | |
113 | objAntennaDown = patternChoosen.antennadown_set.get() |
|
113 | objAntennaDown = patternChoosen.antennadown_set.get() | |
114 |
|
114 | |||
115 | if len(lsPatterns) > 1: |
|
115 | if len(lsPatterns) > 1: | |
116 | if pattern_value == 1: |
|
116 | if pattern_value == 1: | |
117 | nextValuePattern = pattern_value + 1 |
|
117 | nextValuePattern = pattern_value + 1 | |
118 | nextPattern = objProfile.pattern_set.get(value=nextValuePattern) |
|
118 | nextPattern = objProfile.pattern_set.get(value=nextValuePattern) | |
119 |
|
119 | |||
120 |
|
120 | |||
121 | return render_to_response('abscontrol/view.html', {'objProfile': objProfile, 'profile_list': profile_list, |
|
121 | return render_to_response('abscontrol/view.html', {'objProfile': objProfile, 'profile_list': profile_list, | |
122 | 'patternChoosen' : patternChoosen, 'lsPatterns' : lsPatterns, |
|
122 | 'patternChoosen' : patternChoosen, 'lsPatterns' : lsPatterns, | |
123 | 'antennaUp' : objAntennaUp, 'antennaDown' : objAntennaDown, |
|
123 | 'antennaUp' : objAntennaUp, 'antennaDown' : objAntennaDown, | |
124 | 'nextPattern' : nextPattern, |
|
124 | 'nextPattern' : nextPattern, | |
125 | }) |
|
125 | }) | |
126 |
|
126 | |||
127 | def edit(request, profile_id): |
|
127 | def edit(request, profile_id): | |
128 | if request.method == 'GET' and 'pattern' in request.GET: |
|
128 | if request.method == 'GET' and 'pattern' in request.GET: | |
129 | pattern_value = request.GET["pattern"] |
|
129 | pattern_value = request.GET["pattern"] | |
130 | else: |
|
130 | else: | |
131 | pattern_value = 1 |
|
131 | pattern_value = 1 | |
132 |
|
132 | |||
133 | profile_list = Profile.objects.all() |
|
133 | profile_list = Profile.objects.all() | |
134 | objProfile = Profile.objects.get(pk=profile_id) |
|
134 | objProfile = Profile.objects.get(pk=profile_id) | |
135 |
|
135 | |||
136 | lsPatterns = objProfile.pattern_set.all() |
|
136 | lsPatterns = objProfile.pattern_set.all() | |
137 | patternChoosen = objProfile.pattern_set.get(value=pattern_value) |
|
137 | patternChoosen = objProfile.pattern_set.get(value=pattern_value) | |
138 | objAntennaUp = patternChoosen.antennaup_set.get() |
|
138 | objAntennaUp = patternChoosen.antennaup_set.get() | |
139 | objAntennaDown = patternChoosen.antennadown_set.get() |
|
139 | objAntennaDown = patternChoosen.antennadown_set.get() | |
140 |
|
140 | |||
141 | return render_to_response('abscontrol/edit.html', {'objProfile': objProfile, 'profile_list': profile_list, |
|
141 | return render_to_response('abscontrol/edit.html', {'objProfile': objProfile, 'profile_list': profile_list, | |
142 | 'patternChoosen' : patternChoosen, 'lsPatterns' : lsPatterns, |
|
142 | 'patternChoosen' : patternChoosen, 'lsPatterns' : lsPatterns, | |
143 | 'antennaUp' : objAntennaUp, 'antennaDown' : objAntennaDown, |
|
143 | 'antennaUp' : objAntennaUp, 'antennaDown' : objAntennaDown, | |
144 | }) |
|
144 | }) | |
145 |
|
145 | |||
146 | def addPattern(request, profile_id): |
|
146 | def addPattern(request, profile_id): | |
147 | profile_list = Profile.objects.all() |
|
147 | profile_list = Profile.objects.all() | |
148 | objProfile = Profile.objects.get(pk=profile_id) |
|
148 | objProfile = Profile.objects.get(pk=profile_id) | |
149 |
|
149 | |||
150 | return render_to_response('abscontrol/addPattern.html', {'objProfile': objProfile, 'profile_list': profile_list, |
|
150 | return render_to_response('abscontrol/addPattern.html', {'objProfile': objProfile, 'profile_list': profile_list, | |
151 | 'txtAntenna' : txtAntenna, 'txtUes' : txtUes, |
|
151 | 'txtAntenna' : txtAntenna, 'txtUes' : txtUes, | |
152 | 'txtTxUp' : txtTxUp, 'txtTxDown' : txtTxDown, |
|
152 | 'txtTxUp' : txtTxUp, 'txtTxDown' : txtTxDown, | |
153 | 'txtRxUp' : txtRxUp, 'txtRxDown' : txtRxDown, |
|
153 | 'txtRxUp' : txtRxUp, 'txtRxDown' : txtRxDown, | |
154 | }) |
|
154 | }) | |
155 |
|
155 | |||
156 | def editPattern(request, profile_id, pattern_id): |
|
156 | def editPattern(request, profile_id, pattern_id): | |
157 | profile_list = Profile.objects.all() |
|
157 | profile_list = Profile.objects.all() | |
158 | objProfile = Profile.objects.get(pk=profile_id) |
|
158 | objProfile = Profile.objects.get(pk=profile_id) | |
159 | lsPatterns = objProfile.pattern_set.all() |
|
159 | lsPatterns = objProfile.pattern_set.all() | |
160 | patternChoosen = Pattern.objects.get(pk=pattern_id) |
|
160 | patternChoosen = Pattern.objects.get(pk=pattern_id) | |
161 | objAntennaUp = patternChoosen.antennaup_set.get() |
|
161 | objAntennaUp = patternChoosen.antennaup_set.get() | |
162 | objAntennaDown = patternChoosen.antennadown_set.get() |
|
162 | objAntennaDown = patternChoosen.antennadown_set.get() | |
163 |
|
163 | |||
164 | return render_to_response('abscontrol/editPattern.html', {'objProfile': objProfile, 'profile_list': profile_list, |
|
164 | return render_to_response('abscontrol/editPattern.html', {'objProfile': objProfile, 'profile_list': profile_list, | |
165 | 'patternChoosen' : patternChoosen, 'lsPatterns' : lsPatterns, |
|
165 | 'patternChoosen' : patternChoosen, 'lsPatterns' : lsPatterns, | |
166 | 'antennaUp' : objAntennaUp, 'antennaDown' : objAntennaDown, |
|
166 | 'antennaUp' : objAntennaUp, 'antennaDown' : objAntennaDown, | |
167 | }) |
|
167 | }) | |
168 |
|
168 | |||
169 | def savePattern(request, profile_id): |
|
169 | def savePattern(request, profile_id): | |
170 | pattern_id = 0 |
|
170 | pattern_id = 0 | |
171 | method = "save" |
|
171 | method = "save" | |
172 |
|
172 | |||
173 | if 'pattern_id' in request.POST: |
|
173 | if 'pattern_id' in request.POST: | |
174 | pattern_id = request.POST["pattern_id"] |
|
174 | pattern_id = request.POST["pattern_id"] | |
175 | method = "update" |
|
175 | method = "update" | |
176 |
|
176 | |||
177 | maxValuePattern = 0 |
|
177 | maxValuePattern = 0 | |
178 | txtAntennaUp = request.POST["txtAntennaUp"] |
|
178 | txtAntennaUp = request.POST["txtAntennaUp"] | |
179 | txtTxUp = request.POST["txtTxUp"] |
|
179 | txtTxUp = request.POST["txtTxUp"] | |
180 | txtRxUp = request.POST["txtRxUp"] |
|
180 | txtRxUp = request.POST["txtRxUp"] | |
181 | txtUesUp = request.POST["txtUesUp"] |
|
181 | txtUesUp = request.POST["txtUesUp"] | |
182 |
|
182 | |||
183 | txtAntennaDown = request.POST["txtAntennaDown"] |
|
183 | txtAntennaDown = request.POST["txtAntennaDown"] | |
184 | txtTxDown = request.POST["txtTxDown"] |
|
184 | txtTxDown = request.POST["txtTxDown"] | |
185 | txtRxDown = request.POST["txtRxDown"] |
|
185 | txtRxDown = request.POST["txtRxDown"] | |
186 | txtUesDown = request.POST["txtUesDown"] |
|
186 | txtUesDown = request.POST["txtUesDown"] | |
187 |
|
187 | |||
188 | if method == "save": |
|
188 | if method == "save": | |
189 | objProfile = Profile.objects.get(pk=profile_id) |
|
189 | objProfile = Profile.objects.get(pk=profile_id) | |
190 | lsPatterns = objProfile.pattern_set.all() |
|
190 | lsPatterns = objProfile.pattern_set.all() | |
191 | for element in lsPatterns: |
|
191 | for element in lsPatterns: | |
192 | if element.value > maxValuePattern: |
|
192 | if element.value > maxValuePattern: | |
193 | maxPattern = element.value |
|
193 | maxPattern = element.value | |
194 |
|
194 | |||
195 | if maxPattern < 10 : |
|
195 | if maxPattern < 10 : | |
196 | newValuePattern = maxPattern + 1 |
|
196 | newValuePattern = maxPattern + 1 | |
197 | newpattern = objProfile.pattern_set.create(value=newValuePattern) |
|
197 | newpattern = objProfile.pattern_set.create(value=newValuePattern) | |
198 | newpattern.antennaup_set.create(value=txtAntennaUp,tx=txtTxUp,rx=txtRxUp,ues=txtUesUp) |
|
198 | newpattern.antennaup_set.create(value=txtAntennaUp,tx=txtTxUp,rx=txtRxUp,ues=txtUesUp) | |
199 | newpattern.antennadown_set.create(value=txtAntennaDown,tx=txtTxDown,rx=txtRxDown,ues=txtUesDown) |
|
199 | newpattern.antennadown_set.create(value=txtAntennaDown,tx=txtTxDown,rx=txtRxDown,ues=txtUesDown) | |
200 |
|
200 | |||
201 | newurl = '/abscontrol/%d/view/%d' % (int(profile_id), newpattern.id) |
|
201 | newurl = '/abscontrol/%d/view/%d' % (int(profile_id), newpattern.id) | |
202 | else: |
|
202 | else: | |
203 | newurl = '/abscontrol/edit/%d' % (int(profile_id)) |
|
203 | newurl = '/abscontrol/edit/%d' % (int(profile_id)) | |
204 | else: |
|
204 | else: | |
205 | txtAntennaUpId = request.POST["txtAntennaUpId"] |
|
205 | txtAntennaUpId = request.POST["txtAntennaUpId"] | |
206 | objAntennaUp = AntennaUp.objects.get(pk=txtAntennaUpId) |
|
206 | objAntennaUp = AntennaUp.objects.get(pk=txtAntennaUpId) | |
207 | objAntennaUp.value = txtAntennaUp |
|
207 | objAntennaUp.value = txtAntennaUp | |
208 | objAntennaUp.tx = txtTxUp |
|
208 | objAntennaUp.tx = txtTxUp | |
209 | objAntennaUp.rx = txtRxUp |
|
209 | objAntennaUp.rx = txtRxUp | |
210 | objAntennaUp.ues = txtUesUp |
|
210 | objAntennaUp.ues = txtUesUp | |
211 | objAntennaUp.save() |
|
211 | objAntennaUp.save() | |
212 |
|
212 | |||
213 | txtAntennaDownId = request.POST["txtAntennaDownId"] |
|
213 | txtAntennaDownId = request.POST["txtAntennaDownId"] | |
214 | objAntennaDown = AntennaDown.objects.get(pk=txtAntennaDownId) |
|
214 | objAntennaDown = AntennaDown.objects.get(pk=txtAntennaDownId) | |
215 | objAntennaDown.value = txtAntennaDown |
|
215 | objAntennaDown.value = txtAntennaDown | |
216 | objAntennaDown.tx = txtTxDown |
|
216 | objAntennaDown.tx = txtTxDown | |
217 | objAntennaDown.rx = txtRxDown |
|
217 | objAntennaDown.rx = txtRxDown | |
218 | objAntennaDown.ues = txtUesDown |
|
218 | objAntennaDown.ues = txtUesDown | |
219 | objAntennaDown.save() |
|
219 | objAntennaDown.save() | |
220 |
|
220 | |||
221 | newurl = '/abscontrol/%d/view/%d' % (int(profile_id), int(pattern_id)) |
|
221 | newurl = '/abscontrol/%d/view/%d' % (int(profile_id), int(pattern_id)) | |
222 |
|
222 | |||
223 | return redirect(newurl) |
|
223 | return redirect(newurl) | |
224 |
|
224 | |||
225 | def viewPattern(request, profile_id, pattern_id): |
|
225 | def viewPattern(request, profile_id, pattern_id): | |
226 |
|
226 | |||
227 | profile_list = Profile.objects.all() |
|
227 | profile_list = Profile.objects.all() | |
228 | objProfile = Profile.objects.get(pk=profile_id) |
|
228 | objProfile = Profile.objects.get(pk=profile_id) | |
229 |
|
229 | |||
230 | patternChoosen = Pattern.objects.get(pk=pattern_id) |
|
230 | patternChoosen = Pattern.objects.get(pk=pattern_id) | |
231 |
|
231 | |||
232 | objAntennaUp = patternChoosen.antennaup_set.get() |
|
232 | objAntennaUp = patternChoosen.antennaup_set.get() | |
233 | objAntennaDown = patternChoosen.antennadown_set.get() |
|
233 | objAntennaDown = patternChoosen.antennadown_set.get() | |
234 |
|
234 | |||
235 | lsPatterns = objProfile.pattern_set.all() |
|
235 | lsPatterns = objProfile.pattern_set.all() | |
236 |
|
236 | |||
237 | return render_to_response('abscontrol/viewPattern.html', {'objProfile': objProfile, 'profile_list': profile_list, |
|
237 | return render_to_response('abscontrol/viewPattern.html', {'objProfile': objProfile, 'profile_list': profile_list, | |
238 | 'patternChoosen' : patternChoosen, 'lsPatterns' : lsPatterns, |
|
238 | 'patternChoosen' : patternChoosen, 'lsPatterns' : lsPatterns, | |
239 | 'antennaUp' : objAntennaUp, 'antennaDown' : objAntennaDown, |
|
239 | 'antennaUp' : objAntennaUp, 'antennaDown' : objAntennaDown, | |
240 | }) |
|
240 | }) | |
241 |
|
241 | |||
242 | def deletePattern(request, profile_id, pattern_id): |
|
242 | def deletePattern(request, profile_id, pattern_id): | |
243 | newurl = '/abscontrol/edit/%d' % int(profile_id) |
|
243 | newurl = '/abscontrol/edit/%d' % int(profile_id) | |
244 |
|
244 | |||
245 | return redirect(newurl) |
|
245 | return redirect(newurl) | |
246 |
|
246 | |||
247 | def importProfile(request): |
|
247 | def importProfile(request): | |
248 | profile_list = Profile.objects.all() |
|
248 | profile_list = Profile.objects.all() | |
249 | return render_to_response('abscontrol/import.html', {'profile_list': profile_list,}) |
|
249 | return render_to_response('abscontrol/import.html', {'profile_list': profile_list,}) | |
250 |
|
250 | |||
251 | def showImport(request): |
|
251 | def showImport(request): | |
252 | if request.method == 'POST': |
|
252 | if request.method == 'POST': | |
253 | txtFilename = request.FILES['txtFile'] |
|
253 | txtFilename = request.FILES['txtFile'] | |
254 | if txtFilename: |
|
254 | if txtFilename: | |
255 | destination = open('/tmp/'+txtFilename.name, 'wb+') |
|
255 | destination = open('/tmp/'+txtFilename.name, 'wb+') | |
256 | for chunk in txtFilename.chunks(): |
|
256 | for chunk in txtFilename.chunks(): | |
257 | destination.write(chunk) |
|
257 | destination.write(chunk) | |
258 | destination.close() |
|
258 | destination.close() | |
259 | filename = '/tmp/'+txtFilename.name |
|
259 | filename = '/tmp/'+txtFilename.name | |
260 | readFile = readABSFile(filename) |
|
260 | readFile = readABSFile(filename) | |
261 | expName, num_patterns, patterns = readFile.getMetadata() |
|
261 | expName, num_patterns, patterns = readFile.getMetadata() | |
262 | else: |
|
262 | else: | |
263 | txtFilename = "Error" |
|
263 | txtFilename = "Error" | |
264 | #content = "Error" |
|
264 | #content = "Error" | |
265 | expName = "" |
|
265 | expName = "" | |
266 | num_patterns = 0 |
|
266 | num_patterns = 0 | |
267 |
|
267 | |||
268 | return render_to_response('abscontrol/upload-edit.html', {'txtFilename': txtFilename, 'patterns' : patterns, |
|
268 | return render_to_response('abscontrol/upload-edit.html', {'txtFilename': txtFilename, 'patterns' : patterns, | |
269 | 'expName' : expName, 'num_patterns' : num_patterns, |
|
269 | 'expName' : expName, 'num_patterns' : num_patterns, | |
270 | }) |
|
270 | }) | |
271 |
|
271 | |||
272 | def saveImport(request): |
|
272 | def saveImport(request): | |
273 | patterns = [] |
|
273 | patterns = [] | |
274 |
|
274 | |||
275 | expName = request.POST["txtProfile"] |
|
275 | expName = request.POST["txtProfile"] | |
276 | num_patterns = int(request.POST["txtNumPatterns"]) |
|
276 | num_patterns = int(request.POST["txtNumPatterns"]) | |
277 |
|
277 | |||
278 | newprofile = Profile(name=expName) |
|
278 | newprofile = Profile(name=expName) | |
279 | newprofile.save() |
|
279 | newprofile.save() | |
280 |
|
280 | |||
281 | for i in range(0,num_patterns): |
|
281 | for i in range(0,num_patterns): | |
282 | number = request.POST["txtNumberPattern"+str(i+1)] |
|
282 | number = request.POST["txtNumberPattern"+str(i+1)] | |
283 | txtAntennaUp = request.POST["txtAntennaUp"+str(i+1)] |
|
283 | txtAntennaUp = request.POST["txtAntennaUp"+str(i+1)] | |
284 | txtAntennaDown = request.POST["txtAntennaDown"+str(i+1)] |
|
284 | txtAntennaDown = request.POST["txtAntennaDown"+str(i+1)] | |
285 | dicPattern = {"number" : number, "up" : txtAntennaUp, "down" : txtAntennaDown} |
|
285 | dicPattern = {"number" : number, "up" : txtAntennaUp, "down" : txtAntennaDown} | |
286 | patterns.append(dicPattern) |
|
286 | patterns.append(dicPattern) | |
287 | newpattern = newprofile.pattern_set.create(value=number) |
|
287 | newpattern = newprofile.pattern_set.create(value=number) | |
288 | newpattern.antennaup_set.create(value=txtAntennaUp) |
|
288 | newpattern.antennaup_set.create(value=txtAntennaUp) | |
289 | newpattern.antennadown_set.create(value=txtAntennaDown) |
|
289 | newpattern.antennadown_set.create(value=txtAntennaDown) | |
290 |
|
290 | |||
291 | newurl = '/abscontrol/view/%d' % newprofile.id |
|
291 | newurl = '/abscontrol/view/%d' % newprofile.id | |
292 |
|
292 | |||
293 | return redirect(newurl) |
|
293 | return redirect(newurl) | |
294 | ''' |
|
294 | ''' | |
295 | return render_to_response('abscontrol/upload-view.html', {'expName' : expName, 'patterns' : patterns, |
|
295 | return render_to_response('abscontrol/upload-view.html', {'expName' : expName, 'patterns' : patterns, | |
296 | 'num_patterns' : num_patterns, |
|
296 | 'num_patterns' : num_patterns, | |
297 | }) |
|
297 | }) | |
298 | ''' |
|
298 | ''' | |
299 |
|
299 | |||
300 | def overJRO(request, profile_id, pattern_id, antenna_id): |
|
300 | def overJRO(request, profile_id, pattern_id, antenna_id): | |
301 | if request.GET["beam"] == "Up": |
|
301 | if request.GET["beam"] == "Up": | |
302 | objAntenna = AntennaUp.objects.get(pk=antenna_id) |
|
302 | objAntenna = AntennaUp.objects.get(pk=antenna_id) | |
303 | else: |
|
303 | else: | |
304 | objAntenna = AntennaDown.objects.get(pk=antenna_id) |
|
304 | objAntenna = AntennaDown.objects.get(pk=antenna_id) | |
305 | objProfile = Profile.objects.get(pk=profile_id) |
|
305 | objProfile = Profile.objects.get(pk=profile_id) | |
306 | exp_name = objProfile.name |
|
306 | exp_name = objProfile.name | |
307 |
|
307 | |||
308 | phase_tx = objAntenna.value |
|
308 | phase_tx = objAntenna.value | |
309 | gain_tx = objAntenna.tx |
|
309 | gain_tx = objAntenna.tx | |
310 | gain_rx = objAntenna.rx |
|
310 | gain_rx = objAntenna.rx | |
311 | ues_tx = objAntenna.ues |
|
311 | ues_tx = objAntenna.ues | |
312 | only_rx = objAntenna.only_rx |
|
312 | only_rx = objAntenna.only_rx | |
313 |
|
313 | |||
314 | return exp_name, phase_tx, gain_tx, gain_rx, ues_tx, only_rx |
|
314 | return exp_name, phase_tx, gain_tx, gain_rx, ues_tx, only_rx | |
315 |
|
315 | |||
316 | def export(request, profile_id): |
|
316 | def export(request, profile_id): | |
317 | listPatterns = [] |
|
317 | listPatterns = [] | |
318 | objProfile = Profile.objects.get(pk=profile_id) |
|
318 | objProfile = Profile.objects.get(pk=profile_id) | |
319 | exp_name = objProfile.name |
|
319 | exp_name = objProfile.name | |
320 | lsPatterns = objProfile.pattern_set.all() |
|
320 | lsPatterns = objProfile.pattern_set.all() | |
321 | for element in lsPatterns: |
|
321 | for element in lsPatterns: | |
322 | objAntennaUp = element.antennaup_set.get() |
|
322 | objAntennaUp = element.antennaup_set.get() | |
323 | objAntennaDown = element.antennadown_set.get() |
|
323 | objAntennaDown = element.antennadown_set.get() | |
324 | dicPatterns = {"number" : element.value, "up" : objAntennaUp.value, "down" : objAntennaDown.value} |
|
324 | dicPatterns = {"number" : element.value, "up" : objAntennaUp.value, "down" : objAntennaDown.value} | |
325 | listPatterns.append(dicPatterns) |
|
325 | listPatterns.append(dicPatterns) | |
326 |
|
326 | |||
327 | absFile = saveABSFile() |
|
327 | absFile = saveABSFile() | |
328 | absFile.setParameters(settings.MEDIA_ROOT, exp_name, listPatterns) |
|
328 | absFile.setParameters(settings.MEDIA_ROOT, exp_name, listPatterns) | |
329 | filename, filesize = absFile.save() |
|
329 | filename, filesize = absFile.save() | |
330 |
|
330 | |||
331 | wrapper = FileWrapper( open( filename, "r" ) ) |
|
331 | wrapper = FileWrapper( open( filename, "r" ) ) | |
332 | content_type = mimetypes.guess_type( filename )[0] |
|
332 | content_type = mimetypes.guess_type( filename )[0] | |
333 |
|
333 | |||
334 | response = HttpResponse(wrapper, content_type = content_type) |
|
334 | response = HttpResponse(wrapper, content_type = content_type) | |
335 | response['Content-Description'] = 'File Transfer' |
|
335 | response['Content-Description'] = 'File Transfer' | |
336 | response['Content-Disposition'] = 'attachment; filename=%s' % smart_str(filename) |
|
336 | response['Content-Disposition'] = 'attachment; filename=%s' % smart_str(filename) | |
337 | response['Content-Transfer-Encoding'] = 'binary' |
|
337 | response['Content-Transfer-Encoding'] = 'binary' | |
338 | response['Expires'] = '0' |
|
338 | response['Expires'] = '0' | |
339 | response['Cache-Control'] = 'must-revalidate' |
|
339 | response['Cache-Control'] = 'must-revalidate' | |
340 | response['Pragma'] = 'public' |
|
340 | response['Pragma'] = 'public' | |
341 | response['Content-Length'] = '%s' % str(filesize) |
|
341 | response['Content-Length'] = '%s' % str(filesize) | |
342 | response['X-Sendfile'] = '%s' % smart_str(filename) |
|
342 | response['X-Sendfile'] = '%s' % smart_str(filename) | |
343 |
|
343 | |||
344 | return response |
|
344 | return response | |
|
345 | ||||
|
346 | def send(request, profile_id): | |||
|
347 | listPatterns = [] | |||
|
348 | objProfile = Profile.objects.get(pk=profile_id) | |||
|
349 | exp_name = objProfile.name | |||
|
350 | ||||
|
351 | lsPatterns = objProfile.pattern_set.all() | |||
|
352 | for element in lsPatterns: | |||
|
353 | objAntennaUp = element.antennaup_set.get() | |||
|
354 | objAntennaDown = element.antennadown_set.get() | |||
|
355 | dicPatterns = {"number" : element.value, "up" : objAntennaUp.value, "down" : objAntennaDown.value} | |||
|
356 | listPatterns.append(dicPatterns) | |||
|
357 | ||||
|
358 | absFile = saveABSFile() | |||
|
359 | absFile.setParameters(settings.MEDIA_ROOT, exp_name, listPatterns) | |||
|
360 | filename, filesize = absFile.save() | |||
|
361 | ||||
|
362 | apiclient = sendFile() | |||
|
363 | apiclient.execute(filename) | |||
|
364 | ||||
|
365 | objProfile.hits += 1 | |||
|
366 | objProfile.save() | |||
|
367 | ||||
|
368 | message = "File sent successfully." | |||
|
369 | ||||
|
370 | profile_list = Profile.objects.all() | |||
|
371 | ||||
|
372 | return render_to_response('abscontrol/sendFile.html', {'message': message, "profile_list" : profile_list, | |||
|
373 | 'objProfile': objProfile, | |||
|
374 | }) |
@@ -1,30 +1,30 | |||||
1 | /** |
|
1 | /** | |
2 | * @author Jose Antonio Sal y Rosas Celi |
|
2 | * @author Jose Antonio Sal y Rosas Celi | |
3 | * @contact: jose.salyrosas@jro.igp.gob.pe, arturo.jasyrc@gmail.com |
|
3 | * @contact: jose.salyrosas@jro.igp.gob.pe, arturo.jasyrc@gmail.com | |
4 | */ |
|
4 | */ | |
5 |
|
5 | |||
6 | $(document).on('ready',function(){ |
|
6 | $(document).on('ready',function(){ | |
7 | $('#listProfiles').change(function() { |
|
7 | $('#listProfiles').change(function() { | |
8 | if($(this).val() != -1){ |
|
8 | if($(this).val() != -1){ | |
9 | location.href="/abscontrol/view/" + $(this).val(); |
|
9 | location.href="/abscontrol/view/" + $(this).val(); | |
10 | } |
|
10 | } | |
11 | }); |
|
11 | }); | |
12 |
|
||||
13 | $('#lnkSave').click(function() { |
|
12 | $('#lnkSave').click(function() { | |
14 | $('#frmPattern').submit(); |
|
13 | $('#frmPattern').submit(); | |
15 | }); |
|
14 | }); | |
16 |
|
||||
17 | $('#lnkCancel').click(function() { |
|
15 | $('#lnkCancel').click(function() { | |
18 | if ($("#pattern_id").val() == 0){ |
|
16 | if ($("#pattern_id").val() == 0){ | |
19 | location.href="/abscontrol/edit/" + $("#profile_id").val(); |
|
17 | location.href="/abscontrol/edit/" + $("#profile_id").val(); | |
20 | }else{ |
|
18 | }else{ | |
21 | location.href="/abscontrol/" + $("#profile_id").val() + "/view/" + $("#pattern_id").val() |
|
19 | location.href="/abscontrol/" + $("#profile_id").val() + "/view/" + $("#pattern_id").val() | |
22 | } |
|
20 | } | |
23 |
|
||||
24 | }); |
|
21 | }); | |
25 |
|
||||
26 | $('#lnkExport').click(function(){ |
|
22 | $('#lnkExport').click(function(){ | |
27 | profile_id = $(this).attr("alt"); |
|
23 | profile_id = $(this).attr("alt"); | |
28 | location.href="/abscontrol/export/" + profile_id + "/"; |
|
24 | location.href="/abscontrol/export/" + profile_id + "/"; | |
29 | }); |
|
25 | }); | |
|
26 | $('#lnkSendFile').click(function(){ | |||
|
27 | profile_id = $(this).attr("alt"); | |||
|
28 | location.href="/abscontrol/send/" + profile_id + "/"; | |||
|
29 | }); | |||
30 | }); No newline at end of file |
|
30 | }); |
@@ -1,27 +1,31 | |||||
1 | /** |
|
1 | /** | |
2 | * @author Jose Antonio Sal y Rosas Celi |
|
2 | * @author Jose Antonio Sal y Rosas Celi | |
3 | * @contact: jose.salyrosas@jro.igp.gob.pe, arturo.jasyrc@gmail.com |
|
3 | * @contact: jose.salyrosas@jro.igp.gob.pe, arturo.jasyrc@gmail.com | |
4 | */ |
|
4 | */ | |
5 |
|
5 | |||
6 | $(document).on('ready',function(){ |
|
6 | $(document).on('ready',function(){ | |
7 | $('#listProfiles').change(function() { |
|
7 | $('#listProfiles').change(function() { | |
8 | if($(this).val() != -1){ |
|
8 | if($(this).val() != -1){ | |
9 | location.href="/abscontrol/view/" + $(this).val(); |
|
9 | location.href="/abscontrol/view/" + $(this).val(); | |
10 | } |
|
10 | } | |
11 | }); |
|
11 | }); | |
12 | $('.activeOverJRO').click(function() { |
|
12 | $('.activeOverJRO').click(function() { | |
13 | profile_id = $('input[name=txtProfileId]').val(); |
|
13 | profile_id = $('input[name=txtProfileId]').val(); | |
14 | pattern_id = $('input[name=txtPatternId]').val(); |
|
14 | pattern_id = $('input[name=txtPatternId]').val(); | |
15 | field_Id = $(this).attr("id"); |
|
15 | field_Id = $(this).attr("id"); | |
16 | field_value = $('input[name=txtAntenna'+field_Id+'Id]').val(); |
|
16 | field_value = $('input[name=txtAntenna'+field_Id+'Id]').val(); | |
17 | url = "/abscontrol/"+profile_id+"/"+pattern_id+"/overjro/"+field_value+"/?beam="+field_Id; |
|
17 | url = "/abscontrol/"+profile_id+"/"+pattern_id+"/overjro/"+field_value+"/?beam="+field_Id; | |
18 | alert(url); |
|
18 | alert(url); | |
19 | }); |
|
19 | }); | |
20 | $('#lnkSaveImport').click(function(){ |
|
20 | $('#lnkSaveImport').click(function(){ | |
21 | $('#frmImportProfile').submit(); |
|
21 | $('#frmImportProfile').submit(); | |
22 | }); |
|
22 | }); | |
23 | $('#lnkExport').click(function(){ |
|
23 | $('#lnkExport').click(function(){ | |
24 | profile_id = $(this).attr("alt"); |
|
24 | profile_id = $(this).attr("alt"); | |
25 | location.href="/abscontrol/export/" + profile_id + "/"; |
|
25 | location.href="/abscontrol/export/" + profile_id + "/"; | |
26 | }); |
|
26 | }); | |
|
27 | $('#lnkSendFile').click(function(){ | |||
|
28 | profile_id = $(this).attr("alt"); | |||
|
29 | location.href="/abscontrol/send/" + profile_id + "/"; | |||
|
30 | }); | |||
27 | }); No newline at end of file |
|
31 | }); |
@@ -1,62 +1,62 | |||||
1 | {% extends "base.html" %} |
|
1 | {% extends "base.html" %} | |
2 |
|
2 | |||
3 | {% block title %}ABS CONTROL:::::{% endblock %} |
|
3 | {% block title %}ABS CONTROL:::::{% endblock %} | |
4 | {% block scripting %} |
|
4 | {% block scripting %} | |
5 | {% if profile_list %} |
|
5 | {% if profile_list %} | |
6 | <script src="/static/static/js/profiles.js"></script> |
|
6 | <script src="/static/static/js/profiles.js"></script> | |
7 | {% endif %} |
|
7 | {% endif %} | |
8 | {% endblock %} |
|
8 | {% endblock %} | |
9 | {% block content %} |
|
9 | {% block content %} | |
10 | <div id="content"> |
|
10 | <div id="content"> | |
11 | {% block leftcolumn %} |
|
11 | {% block leftcolumn %} | |
12 | <div id="leftcolumn"> |
|
12 | <div id="leftcolumn"> | |
13 | <div id="lsProfiles"> |
|
13 | <div id="lsProfiles"> | |
14 | <div id="infoProfiles"> |
|
14 | <div id="infoProfiles"> | |
15 | <label for="lblProfile" class="lblInfo">Profiles:</label><br /> |
|
15 | <label for="lblProfile" class="lblInfo">Profiles:</label><br /> | |
16 | {% if profile_list %} |
|
16 | {% if profile_list %} | |
17 | <select name="lsProfiles" id="listProfiles"> |
|
17 | <select name="lsProfiles" id="listProfiles"> | |
18 | <option value="-1">Choose ...</option> |
|
18 | <option value="-1">Choose ...</option> | |
19 | {% for entry in profile_list %} |
|
19 | {% for entry in profile_list %} | |
20 | {% if objProfile %} |
|
20 | {% if objProfile %} | |
21 | {% if objProfile.id == entry.id %} |
|
21 | {% if objProfile.id == entry.id %} | |
22 | <option value="{{ entry.id }}" selected>{{ entry.name }}</option> |
|
22 | <option value="{{ entry.id }}" selected>{{ entry.name }}</option> | |
23 | {% else %} |
|
23 | {% else %} | |
24 | <option value="{{ entry.id }}">{{ entry.name }}</option> |
|
24 | <option value="{{ entry.id }}">{{ entry.name }}</option> | |
25 | {% endif %} |
|
25 | {% endif %} | |
26 | {% else %} |
|
26 | {% else %} | |
27 | <option value="{{ entry.id }}">{{ entry.name }}</option> |
|
27 | <option value="{{ entry.id }}">{{ entry.name }}</option> | |
28 | {% endif %} |
|
28 | {% endif %} | |
29 | {% endfor %} |
|
29 | {% endfor %} | |
30 | </select> |
|
30 | </select> | |
31 | {% else %} |
|
31 | {% else %} | |
32 | <label for="lblMessage" class="lblInfo">No profiles.</label> |
|
32 | <label for="lblMessage" class="lblInfo">No profiles.</label> | |
33 | {% endif %} |
|
33 | {% endif %} | |
34 | </div> |
|
34 | </div> | |
35 | </div> |
|
35 | </div> | |
36 | {% block mnu_profile %} |
|
36 | {% block mnu_profile %} | |
37 | <nav class="MnuVertical" id="mnuProfiles"> |
|
37 | <nav class="MnuVertical" id="mnuProfiles"> | |
38 | <ul> |
|
38 | <ul> | |
39 | <li><a href="/abscontrol/new">New</a></li> |
|
39 | <li><a href="/abscontrol/new">New</a></li> | |
40 | {% if objProfile %} |
|
40 | {% if objProfile %} | |
41 | <li><a href="/abscontrol/edit/{{ objProfile.id }}">Edit</a></li> |
|
41 | <li><a href="/abscontrol/edit/{{ objProfile.id }}">Edit</a></li> | |
42 | <li><a href="#">Save</a></li> |
|
42 | <li><a href="#">Save</a></li> | |
43 | {% endif %} |
|
43 | {% endif %} | |
44 | <li><a href="#">Save as</a></li> |
|
44 | <li><a href="#">Save as</a></li> | |
45 | <li><a href="/abscontrol/import">Import</a></li> |
|
45 | <li><a href="/abscontrol/import">Import</a></li> | |
46 | {% if objProfile %} |
|
46 | {% if objProfile %} | |
47 | <li><a href="#" id="lnkExport" alt="{{ objProfile.id }}">Export</a></li> |
|
47 | <li><a href="#" id="lnkExport" alt="{{ objProfile.id }}">Export</a></li> | |
48 |
<li><a href="#"> |
|
48 | <li><a href="#" id="lnkSendFile" alt="{{ objProfile.id }}">Send</a></li> | |
49 | {% endif %} |
|
49 | {% endif %} | |
50 | </ul> |
|
50 | </ul> | |
51 | </nav> |
|
51 | </nav> | |
52 | {% endblock %} |
|
52 | {% endblock %} | |
53 | </div> |
|
53 | </div> | |
54 | {% endblock %} |
|
54 | {% endblock %} | |
55 | {% block maincolumn %} |
|
55 | {% block maincolumn %} | |
56 | <div id="maincolumn"> |
|
56 | <div id="maincolumn"> | |
57 |
|
57 | |||
58 | </div> |
|
58 | </div> | |
59 | {% endblock %} |
|
59 | {% endblock %} | |
60 | <div class="cleardivs"></div> |
|
60 | <div class="cleardivs"></div> | |
61 | </div> |
|
61 | </div> | |
62 | {% endblock %} No newline at end of file |
|
62 | {% endblock %} |
General Comments 0
You need to be logged in to leave comments.
Login now