Andres Vargas avatar Andres Vargas committed a0e37f2

traduccion fixed

Comments (0)

Files changed (8)

media/js/custom.js

 
 $(document).ready(function(){
+var d = new Date();
+var year = d.getYear()
+var datepickerconf= {
+changeMonth: true,
+changeYear: true,
+ yearRange: '-100:+0'
+}
 
-$("#id_born_date").datepicker();
+$("#id_born_date").datepicker(datepickerconf);
 
 });
 
 # Language code for this installation. All choices can be found here:
 # http://www.i18nguy.com/unicode/language-identifiers.html
-LANGUAGE_CODE = 'en-mx'
+LANGUAGE_CODE = 'es-mx'
 
 SITE_ID = 1
 

simple_survey/admin.py

 from django.contrib import admin
+from django.contrib.contenttypes import generic
 
-from models import Survey, Question, Response, Answer
+from models import Survey, Question, Response
+from models import ChoiceOption, AnswerChoice, GroupChoice
 
-class QuestionInline(admin.TabularInline):
-    model = Question
+admin.site.register(Question, None)
 
-class SurveyAdmin(admin.ModelAdmin):
-    list_display = ['id', 'name', ]
-    search_fields = ['name', ]
-    inlines = [
-        QuestionInline,
-    ]
-
-class AnswerInline(admin.TabularInline):
-    model = Answer
-    readonly_fields = ['answer', 'question','profile']
-    extra = 0
+class Inline(admin.TabularInline):
+    model = AnswerChoice
 
 class ResponseAdmin(admin.ModelAdmin):
-    list_display = ['id', 'survey', ]
-    list_filter = ['survey',]
-    readonly_fields = ['survey',]
-    inlines = [
-        AnswerInline,
-    ]
-    
-admin.site.register(Response, ResponseAdmin)    
-admin.site.register(Survey, SurveyAdmin)
+    inlines = [Inline,]
+admin.site.register(Response, ResponseAdmin)
+admin.site.register(Survey, None)
+admin.site.register(ChoiceOption)
+admin.site.register(GroupChoice)
+admin.site.register(AnswerChoice)
 
-

simple_survey/forms.py

 from django.utils.html import escape
 from django.forms.models import modelformset_factory
 
-from models import Survey, Question, Response, Answer
+from models import Survey, Question, Response, AnswerChoice as Answer
 
 class AnswerForm(forms.ModelForm):
     class Meta:

simple_survey/models.py

+# coding: utf-8
 import hashlib
 import datetime
 from profiles.models import Profile
 from django.db import models
 from django.contrib.auth.models import User, Group
 
+from django.contrib.contenttypes.models import ContentType
+from django.contrib.contenttypes import generic
+
+ABCD=1
+YESNO = 2
+TYPE_CHOICES = (
+    (ABCD,"A,B,C .."),
+    (YESNO,u"Sí o No"),
+)
+
 class Survey(models.Model):
     name = models.CharField(max_length=255)
     
     
 class Question(models.Model):
     question = models.TextField()
+    group = models.ForeignKey("GroupChoice")
     survey = models.ForeignKey(Survey)
     
     def __unicode__(self):
         return self.question
 
+
+class ChoiceOption(models.Model):
+    option = models.CharField(max_length=30)
+
+    def __unicode__(self):
+        return self.option
+
+class GroupChoice(models.Model):
+    options = models.ManyToManyField(ChoiceOption)
+    name = models.CharField(max_length=30)
+
+    def __unicode__(self):
+        return self.name
+
+class AnswerChoice(models.Model):
+    choice_option = models.ForeignKey(ChoiceOption)
+    response = models.ForeignKey("Response")
+
 class Response(models.Model):
-    survey = models.ForeignKey(Survey)
-
-class Answer(models.Model):
-    answer = models.TextField()
-    response = models.ForeignKey(Response)
     question = models.ForeignKey(Question)
     profile = models.ForeignKey(Profile)
         
     def __unicode__(self):
-        return self.answer
+        return u"Response of %s" %self.question

simple_survey/views.py

 from django import forms
 from django.contrib.auth.decorators import login_required
 
-from models import Survey, Answer, Response
+from models import Survey, AnswerChoice as Answer, Response
 from forms import get_answer_formset
 
 @login_required
 def list_surveys(request):
     surveys = Survey.objects.all()
-    profile = request.user.get_profile()    
+    profile = request.user.get_profile()
     answers = profile.answer_set.all()
     surveys_id = []
     for a in answers:

templates/userena/signin_form.html

 {% extends 'userena/base_userena.html' %}
 {% load i18n %}
 
-{% block title %}{% trans "Signin" %}{% endblock %}
+{% block title %}{% trans "Acceso" %}{% endblock %}
 
 {% block content %}
 </div>
     {% endfor %}
   </fieldset>
   <input type="submit" value="{% trans "Acceder" %}" />
-  <p class="forgot-password"><a href="{% url userena_password_reset %}" title="{% trans "Forgot your password?" %}">{% trans "Forgot your password?" %}</a></p>
+  <p class="forgot-password"><a href="{% url userena_password_reset %}" title="Olvidate tu contraseña">¿Olvidaste tu contraseña?</a></p>
 </form>
 {% endblock %}
-from django.conf.urls.defaults import patterns, include, url
+from django.conf.urls.defaults import *
 from django.views.generic.simple import direct_to_template
 from django.contrib import admin
 from django.conf import settings
 urlpatterns = patterns('',
      url(r'^admin/', include(admin.site.urls)),
     url(r'^accounts/signup/$', 'profiles.views.signup',name="profiles-register"),
+    (r'^jsi18n/(?P<packages>\S+?)/$', 'django.views.i18n.javascript_catalog', {'packages':('survey',)}),
     (r'^accounts/', include('userena.urls')),
-    (r'^surveys/', include("simple_survey.urls")),
+    (r'^survey/', include("simple_survey.urls")),
     url(r'^$', 'profiles.views.index', name="index"),
 )
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.