##// END OF EJS Templates
- Agrupando los modelos de la aplicacion en una sola clase.
jsalyrosas -
r120:121
parent child
Show More
@@ -1,159 +1,159
1 1 # Django settings for abs_webapp_dev project.
2 2
3 3 import os
4 4 PROJECT_DIR = os.path.split(os.path.dirname(__file__))[0]
5 5
6 6 DEBUG = True
7 7 TEMPLATE_DEBUG = DEBUG
8 8
9 9 ADMINS = (
10 10 # ('Your Name', 'your_email@example.com'),
11 11 )
12 12
13 13 MANAGERS = ADMINS
14 14
15 15 DATABASES = {
16 16 'default': {
17 17 'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
18 18 'NAME': 'db_jrowebapp_dev', # Or path to database file if using sqlite3.
19 19 'USER': 'abscontrol', # Not used with sqlite3.
20 20 'PASSWORD': 'abscontrol', # Not used with sqlite3.
21 21 'HOST': 'localhost', # Set to empty string for localhost. Not used with sqlite3.
22 22 'PORT': '3306', # Set to empty string for default. Not used with sqlite3.
23 23 }
24 24 }
25 25
26 26 # Local time zone for this installation. Choices can be found here:
27 27 # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
28 28 # although not all choices may be available on all operating systems.
29 29 # In a Windows environment this must be set to your system time zone.
30 30 TIME_ZONE = 'America/Lima'
31 31
32 32 # Language code for this installation. All choices can be found here:
33 33 # http://www.i18nguy.com/unicode/language-identifiers.html
34 34 LANGUAGE_CODE = 'en-us'
35 35
36 36 SITE_ID = 1
37 37
38 38 # If you set this to False, Django will make some optimizations so as not
39 39 # to load the internationalization machinery.
40 40 USE_I18N = True
41 41
42 42 # If you set this to False, Django will not format dates, numbers and
43 43 # calendars according to the current locale.
44 44 USE_L10N = True
45 45
46 46 # If you set this to False, Django will not use timezone-aware datetimes.
47 47 USE_TZ = True
48 48
49 49 # Absolute filesystem path to the directory that will hold user-uploaded files.
50 50 # Example: "/home/media/media.lawrence.com/media/"
51 51 MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media').replace('\\', '/')
52 52
53 53 # URL that handles the media served from MEDIA_ROOT. Make sure to use a
54 54 # trailing slash.
55 55 # Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
56 56 MEDIA_URL = '/media/'
57 57
58 58 # Absolute path to the directory static files should be collected to.
59 59 # Don't put anything in this directory yourself; store your static files
60 60 # in apps' "static/" subdirectories and in STATICFILES_DIRS.
61 61 # Example: "/home/media/media.lawrence.com/static/"
62 STATIC_ROOT = os.path.join(PROJECT_DIR, 'static-serve').replace('\\', '/'),
62 #STATIC_ROOT = os.path.join(PROJECT_DIR, 'static-serve').replace('\\', '/'),
63 STATIC_ROOT = ''
63 64
64 65 # URL prefix for static files.
65 66 # Example: "http://media.lawrence.com/static/"
66 67 STATIC_URL = '/static/'
67 68
68 69 # Additional locations of static files
69 70 STATICFILES_DIRS = (
70 71 # Put strings here, like "/home/html/static" or "C:/www/django/static".
71 72 # Always use forward slashes, even on Windows.
72 73 # Don't forget to use absolute paths, not relative paths.
73 os.path.join(PROJECT_DIR, "static").replace('\\', '/'),
74 #os.path.join(PROJECT_DIR, "static").replace('\\', '/'),
75 ("static", os.path.join(PROJECT_DIR, "static").replace('\\', '/')),
74 76 )
75 77
76 78 # List of finder classes that know how to find static files in
77 79 # various locations.
78 80 STATICFILES_FINDERS = (
79 81 'django.contrib.staticfiles.finders.FileSystemFinder',
80 82 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
81 83 # 'django.contrib.staticfiles.finders.DefaultStorageFinder',
82 84 )
83 85
84 86 # Make this unique, and don't share it with anybody.
85 87 SECRET_KEY = '=^abu)gd=)7hf#rme_vw=tv!bdh7+tts*^&)h(n=7@7(9#__@e'
86 88
87 89 # List of callables that know how to import templates from various sources.
88 90 TEMPLATE_LOADERS = (
89 91 'django.template.loaders.filesystem.Loader',
90 92 'django.template.loaders.app_directories.Loader',
91 93 # 'django.template.loaders.eggs.Loader',
92 94 )
93 95
94 96 MIDDLEWARE_CLASSES = (
95 97 'django.middleware.common.CommonMiddleware',
96 98 'django.contrib.sessions.middleware.SessionMiddleware',
97 'django.middleware.csrf.CsrfViewMiddleware',
99 #'django.middleware.csrf.CsrfViewMiddleware',
98 100 'django.contrib.auth.middleware.AuthenticationMiddleware',
99 101 'django.contrib.messages.middleware.MessageMiddleware',
100 102 # Uncomment the next line for simple clickjacking protection:
101 103 # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
102 104 )
103 105
104 106 ROOT_URLCONF = 'abs_webapp_dev.urls'
105 107
106 108 # Python dotted path to the WSGI application used by Django's runserver.
107 109 WSGI_APPLICATION = 'abs_webapp_dev.wsgi.application'
108 110
109 111 TEMPLATE_DIRS = (
110 112 # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
111 113 # Always use forward slashes, even on Windows.
112 114 # Don't forget to use absolute paths, not relative paths.
113 115 os.path.join(PROJECT_DIR, "templates").replace('\\', '/'),
114 116 )
115 117
116 118 INSTALLED_APPS = (
117 119 'django.contrib.auth',
118 120 'django.contrib.contenttypes',
119 121 'django.contrib.sessions',
120 122 'django.contrib.sites',
121 123 'django.contrib.messages',
122 124 'django.contrib.staticfiles',
123 125 # Uncomment the next line to enable the admin:
124 126 # 'django.contrib.admin',
125 127 # Uncomment the next line to enable admin documentation:
126 128 # 'django.contrib.admindocs',
127 'components.antenna',
128 'components.pattern_antenna',
129 'components.profile_antenna',
129 'abscontrol',
130 130 )
131 131
132 132 # A sample logging configuration. The only tangible logging
133 133 # performed by this configuration is to send an email to
134 134 # the site admins on every HTTP 500 error when DEBUG=False.
135 135 # See http://docs.djangoproject.com/en/dev/topics/logging for
136 136 # more details on how to customize your logging configuration.
137 137 LOGGING = {
138 138 'version': 1,
139 139 'disable_existing_loggers': False,
140 140 'filters': {
141 141 'require_debug_false': {
142 142 '()': 'django.utils.log.RequireDebugFalse'
143 143 }
144 144 },
145 145 'handlers': {
146 146 'mail_admins': {
147 147 'level': 'ERROR',
148 148 'filters': ['require_debug_false'],
149 149 'class': 'django.utils.log.AdminEmailHandler'
150 150 }
151 151 },
152 152 'loggers': {
153 153 'django.request': {
154 154 'handlers': ['mail_admins'],
155 155 'level': 'ERROR',
156 156 'propagate': True,
157 157 },
158 158 }
159 159 }
@@ -1,3 +1,113
1 1 from django.db import models
2 from django.utils import timezone
2 3
3 # Create your models here.
4 class profileAntenna(models.Model):
5
6 name = models.CharField(max_length=250)
7 date_create = models.DateTimeField()
8 date_modified = models.DateTimeField(null=True)
9 hits = models.PositiveIntegerField()
10 state = models.PositiveSmallIntegerField()
11
12 class Meta:
13 db_table = "abs_profile_antenna"
14 verbose_name = "Profile of Configuration"
15 verbose_name_plural = "Profiles of Configuration"
16
17 def save(self):
18 if self.pk is None:
19 self.date_create = timezone.now()
20 self.hits = 0
21 self.state = 1
22 else:
23 self.date_modified = timezone.now()
24 super(profileAntenna, self).save()
25
26 def __unicode__(self):
27 return u'%s' % self.value
28
29 class patternAntenna(models.Model):
30
31 profile = models.ForeignKey(profileAntenna)
32 date_create = models.DateTimeField()
33 date_modified = models.DateTimeField(null=True)
34 hits = models.PositiveIntegerField()
35 state = models.PositiveSmallIntegerField()
36
37 class Meta:
38 db_table = "abs_pattern_antenna"
39 verbose_name = "Pattern of Antenna"
40 verbose_name_plural = "List of Patterns of Antenna"
41
42 def save(self):
43 if self.pk is None:
44 self.date_create = timezone.now()
45 self.hits = 0
46 self.state = 1
47 else:
48 self.date_modified = timezone.now()
49 super(patternAntenna, self).save()
50
51 '''
52 def __unicode__(self):
53 return u'%s' % self.value
54 '''
55
56 class antennaUp(models.Model):
57
58 pattern = models.ForeignKey(patternAntenna)
59 value = models.CharField(max_length=250)
60 tx = models.CharField(max_length=250)
61 rx = models.CharField(max_length=250)
62 ues = models.CharField(max_length=80)
63 date_create = models.DateTimeField()
64 date_modified = models.DateTimeField(null=True)
65 hits = models.PositiveIntegerField()
66 state = models.PositiveSmallIntegerField()
67
68 class Meta:
69 db_table = "abs_antenna_up"
70 verbose_name = "Antenna Up"
71 verbose_name_plural = "List of Antenna Up"
72
73 def save(self):
74 if self.pk is None:
75 self.date_create = timezone.now()
76 self.hits = 0
77 self.state = 1
78 else:
79 self.date_modified = timezone.now()
80 super(antennaUp, self).save()
81
82 def __unicode__(self):
83 return u'%s' % self.value
84
85
86 class antennaDown(models.Model):
87
88 pattern = models.ForeignKey(patternAntenna)
89 value = models.CharField(max_length=250)
90 tx = models.CharField(max_length=250)
91 rx = models.CharField(max_length=250)
92 ues = models.CharField(max_length=80)
93 date_create = models.DateTimeField()
94 date_modified = models.DateTimeField(null=True)
95 hits = models.PositiveIntegerField()
96 state = models.PositiveSmallIntegerField()
97
98 class Meta:
99 db_table = "abs_antenna_down"
100 verbose_name = "Antenna Down"
101 verbose_name_plural = "List of Antenna Down"
102
103 def save(self):
104 if self.pk is None:
105 self.date_create = timezone.now()
106 self.hits = 0
107 self.state = 1
108 else:
109 self.date_modified = timezone.now()
110 super(antennaDown, self).save()
111
112 def __unicode__(self):
113 return u'%s' % self.value
@@ -1,9 +1,10
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 url(r'^save/$', 'save'),
6 7 url(r'^(?P<profile_id>\d+)/$', 'detail'),
7 8 #url(r'^(?P<poll_id>\d+)/results/$', 'results'),
8 9 #url(r'^(?P<poll_id>\d+)/vote/$', 'vote'),
9 10 ) No newline at end of file
@@ -1,11 +1,49
1 1 from django.shortcuts import render_to_response
2 from components.profile_antenna.models import profileAntenna
2 from django.http import HttpResponseRedirect
3 from django.core.urlresolvers import reverse
4 from django.template import RequestContext
5
6 from abscontrol.models import profileAntenna, patternAntenna, antennaUp, antennaDown
3 7
4 8 def index(request):
5 9 #latest_poll_list = profileAntenna.objects.all().order_by('-pub_date')[:5]
6 10 profile_list = profileAntenna.objects.all()
7 11 return render_to_response('abscontrol/index.html', {'profile_list': profile_list})
8 12
9 13 def new(request):
10 14 #profile_list = profileAntenna.objects.all()
11 15 return render_to_response('abscontrol/new.html', {})
16
17 def save(request):
18 try:
19 txtProfile = request.POST["txtProfile"]
20
21 txtAntennaUp = request.POST["txtAntennaUp"]
22 txtTxUp = request.POST["txtTxUp"]
23 txtRxUp = request.POST["txtRxUp"]
24 txtUesUp = request.POST["txtUesUp"]
25
26 txtAntennaDown = request.POST["txtAntennaDown"]
27 txtTxDown = request.POST["txtTxDown"]
28 txtRxDown = request.POST["txtRxDown"]
29 txtUesDown = request.POST["txtUesDown"]
30
31 objProfile = profileAntenna(name=txtProfile)
32 objProfile.save()
33
34 profile = profileAntenna.objects.get(pk=objProfile.id)
35 print profile.id
36 newpattern = profile.pattern_set.create()
37 '''
38 pattern = patternAntenna.objects.get(pk=newpattern.id)
39 pattern.antennaUp_set.create(value=txtAntennaUp, tx=txtTxUp, rx=txtRxUp, ues=txtUesUp)
40 pattern.antennaDown_set.create(value=txtAntennaDown, tx=txtTxDown, rx=txtRxDown, ues=txtUesDown)
41 '''
42 return HttpResponseRedirect(reverse('abscontrol.views.index'))
43
44 except:
45 # Redisplay the form
46 return render_to_response('abscontrol/new.html', {
47 'error_message': "You didn't select a choice.",
48 }, context_instance=RequestContext(request))
49
@@ -1,6 +1,35
1 body {
2 font-size: 11px;
3 }
1 body {font-size: 11px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif}
4 2 article, aside, figure, footer, header, hgroup, nav, section { display:block; }
5 header{border: 1px solid #f00; font-size: 1.2em}
6 #schema{margin: 0 auto; width: 980px; border: 1px solid #f00;}
3 header {border: 1px solid #fcc; font-size: 2em; height: 50px; text-align: center; line-height: 50px}
4 #schema {margin: 0 auto; width: 980px; border: 1px solid #f00; padding: 10px 10px 10px 10px}
5 #content {border: 1px solid #1cc; margin-top: 5px; margin-bottom: 5px}
6 #content #leftcolumn {float: left;border: 1px solid #c55; width: 150px; font-family: Monaco;}
7 #content #maincolumn {float: left; border: 1px solid #000; width: 800px; padding-left: 20px;}
8 footer {border: 1px solid #200; font-size: 0.9em; height: 30px; text-align: center; line-height: 20px}
9
10 .cleardivs {clear: both; border: 1px solid #400; height: 0px}
11
12
13 /****************************************************************************************/
14 /****** MENU DE NAVEGACION DE PERFILES **********************************/
15 /****************************************************************************************/
16 #content #infoProfiles {border: 1px solid #d00; width: 140px; margin: 0px; padding-top: 2px; padding-bottom: 2px}
17 .lblInfo {padding-left: 12px; line-height: 20px;}
18 #content nav {border: 1px solid #c55; width: 140px; margin: 0px; font-family: Monaco; font-size: 1.2em;}
19 #content nav ul{list-style: none; list-style-type: none; margin: 15px 15px 15px 15px; padding-left: 20px; border: 0px solid #eee}
20 #content nav ul li{line-height: 20px}
21
22 /****************************************************************************************/
23 /******** FORMULARIO DE PERFILES *************************************/
24 /****************************************************************************************/
25 #divProfile {border: 0px solid #dff; margin: 10px 0px; padding: 10px 10px; width: 500px}
26 .flsAntenna {margin: 10px 0px; width: 750px; padding: 10px 10px}
27 #divPattern textarea,input[type=text],label {font-family: Monaco; font-size: inherit;}
28 #divPattern input[type=text] {width: 200px}
29 #divPattern textarea {resize: none; overflow: hidden}
30 .divAntenna {float: left; margin: 10px; height: 150px}
31 .divAntenna label {display: block}
32 .divTx {display: block; float: left; margin: 10px; height: 150px}
33 .divTx label {display: block}
34 .divUes {display: block; margin: 10px}
35 .txtAntenna {max-width: 200px; max-height: 120px}
@@ -1,37 +1,44
1 1 {% extends "base.html" %}
2 2
3 3 {% block title %}ABS CONTROL:::::{% endblock %}
4 4
5 5 {% block content %}
6 <div id="content">
7 {% block leftcolumn %}
6 8 <div id="leftcolumn">
7 <div>
8 {% if profile_list %}
9 <ul>
10 <li><a href="#">Choose ...</</a></li>
11 {% for entry in profile_list %}
12 <li><a href="/view/{{ entry.id }}">{{ entry.name }}</a></li>
13 {% endfor %}
14 </ul>
15 {% else %}
16 <p>No profiles are available.</p>
17 {% endif %}
9 <div id="lsProfiles">
10 <div id="infoProfiles">
11 <label for="lblProfile" class="lblInfo">Profiles:</label><br />
12 {% if profile_list %}
13 <select name="lsProfiles">
14 <option>Choose ...</option>
15 {% for entry in profile_list %}
16 <option value="{{ entry.id }}">{{ entry.name }}</option>
17 {% endfor %}
18 </select>
19 {% else %}
20 <label for="lblMessage" class="lblInfo">No profiles.</label>
21 {% endif %}
22 </div>
18 23 </div>
19 24 {% block mnu_profile %}
20 25 <nav>
21 26 <ul>
22 <li><a href="new">New</a></li>
23 <li><a href="#">Save</a></li>
27 <li><a href="/abscontrol/new">New</a></li>
24 28 <li><a href="#">Save as</a></li>
25 29 <li><a href="#">Import</a></li>
26 30 <li><a href="#">Export</a></li>
27 31 <li><a href="#">Apply</a></li>
28 32 </ul>
29 33 </nav>
30 34 {% endblock %}
31 35 </div>
36 {% endblock %}
32 37 {% block maincolumn %}
33 38 <div id="maincolumn">
34 39
35 40 </div>
36 41 {% endblock %}
42 <div class="cleardivs"></div>
43 </div>
37 44 {% endblock %} No newline at end of file
@@ -1,13 +1,60
1 1 {% extends "abscontrol/index.html" %}
2 2 {% block title %}ABS CONTROL:::::NEW PROFILE{% endblock %}
3 3
4 4 {% block maincolumn%}
5 5 <div id="maincolumn">
6 <form action="/save/" method="post">
7 {% csrf_token %}
8 <label for="lblName">Profile:</label><br />
9 <input type="text" name="profile" id="" value="" />
10 <input type="submit" value="Save" />
6 <form action="/abscontrol/save/" method="post">
7 <div id="divProfile">
8 <label for="lblName">Profile:</label>
9 <input type="text" name="txtProfile" id="" value="" />
10 <input type="submit" value="Save" />
11 </div>
12 <div id="divPattern">
13 <div id="antennaUp">
14 <fieldset class="flsAntenna">
15 <legend>UP</legend>
16 <div class="divAntenna">
17 <label for="lblAntenna">Antenna</label>
18 <textarea name="txtAntennaUp" class="txtAntenna" cols="38" rows="8"></textarea>
19 </div>
20 <div class="divTx">
21 <label for="lblTx">Tx</label>
22 <textarea name="txtTxUp" class="txtTR" cols="20" rows="8"></textarea>
23 </div>
24 <div class="divTx">
25 <label for="lblRx">Rx</label>
26 <textarea name="txtRxUp" class="txtTR" cols="20" rows="8"></textarea>
27 </div>
28 <div class="cleardivs"></div>
29 <div class="divUes">
30 <label for="lblUes">Ues:</label>
31 <input type="text" name="txtUesUp" value="" />
32 </div>
33 </fieldset>
34 </div>
35 <div id="antennaDown">
36 <fieldset class="flsAntenna">
37 <legend>DOWN</legend>
38 <div class="divAntenna">
39 <label for="lblAntenna">Antenna</label>
40 <textarea name="txtAntennaDown" class="txtAntenna" cols="38" rows="8"></textarea>
41 </div>
42 <div class="divTx">
43 <label for="lblTx">Tx</label>
44 <textarea name="txtTxDown" class="txtTR" cols="20" rows="8"></textarea>
45 </div>
46 <div class="divTx">
47 <label for="lblRx">Rx</label>
48 <textarea name="txtRxDown" class="txtTR" cols="20" rows="8"></textarea>
49 </div>
50 <div class="cleardivs"></div>
51 <div class="divUes">
52 <label for="lblUes">Ues:</label>
53 <input type="text" name="txtUesDown" value="" />
54 </div>
55 </fieldset>
56 </div>
57 </div>
11 58 </form>
12 59 </div>
13 60 {% endblock %}
@@ -1,55 +1,50
1 {% load static %}
1 2 <!DOCTYPE html>
2 3 <html lang="en">
3 4 <head>
4 5 <meta charset="utf-8" />
5 6 {% comment %}
6 7 <!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
7 8 Remove this if you use the .htaccess -->
8 9 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
9 10 {% endcomment %}
10 <link rel="stylesheet" href="{{ STATIC_URL }}style.css" type="text/css" />
11 <link rel="stylesheet" href="{% static 'static/css/style.css' %}" type="text/css" />
11 12 <title>{% block title %}JRO WEB APPS::::{% endblock %}</title>
12 13 <meta name="description" content="JRO WEB APPLICATIONS" />
13 14 <meta name="author" content="Jose Antonio Sal y Rosas Celi" />
14 15
15 16 {# <meta name="viewport" content="width=device-width; initial-scale=1.0" /> #}
16 17 {% comment %}
17 18 <!-- Replace favicon.ico & apple-touch-icon.png in the root of your domain and delete these references -->
18 19 <link rel="shortcut icon" href="/favicon.ico" />
19 20 <link rel="apple-touch-icon" href="/apple-touch-icon.png" />
20 21 {% endcomment %}
21 22 </head>
22 23 <body>
23 24 <div id="schema">
24 25 <header>
25 26 {% block header %}
26 27 <nav>
27 28 <a href="/abscontrol">ABS</a> |
28 29 <a href="#">CR</a> |
29 30 <a href="#">DDS</a> |
30 31 <a href="#">JARS</a>
31 32 </nav>
32 33 {% endblock %}
33 34 </header>
35 {% block content %}
34 36 <div id="content">
35 {% block content %}
36 <nav>
37 <p>
38 <a href="/">Home</a>
39 </p>
40 <p>
41 <a href="/contact">Contact</a>
42 </p>
43 </nav>
37 <nav>
38 <p><a href="/">Home</a></p>
39 <p><a href="/contact">Contact</a></p>
40 </nav>
41 </div>
44 42 {% endblock %}
45 </div>
46 43 <footer>
47 44 {% block footer %}
48 <p>
49 &copy; Copyright by Jicamarca Radio Observatory
50 </p>
45 <p>&copy; Copyright by Jicamarca Radio Observatory</p>
51 46 {% endblock %}
52 47 </footer>
53 48 </div>
54 49 </body>
55 50 </html>
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now