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