Changeset 1491
- Timestamp:
- 19/05/2010 14:25:43 (21 months ago)
- Location:
- trunk/gestorpsi
- Files:
-
- 6 modified
-
demographic/forms.py (modified) (2 diffs)
-
demographic/views.py (modified) (5 diffs)
-
media/js/gestorpsi.forms.js (modified) (1 diff)
-
templates/demographic/demographic_occupation.html (modified) (1 diff)
-
util/urls.py (modified) (1 diff)
-
util/views.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/gestorpsi/demographic/forms.py
r1404 r1491 22 22 23 23 class ProfessionForm(forms.ModelForm): 24 profession = forms.ModelChoiceField(queryset=Occupation.objects.all(), widget=forms.Select(attrs={'class':'giant asm'}), label=_('Profession Ocupation'))24 #profession = forms.ModelChoiceField(queryset=Occupation.objects.all(), widget=forms.Select(attrs={'class':'giant asm'}), label=_('Profession Ocupation')) 25 25 labor_market_status = forms.ChoiceField(choices=LABOR_MARKET_STATUS, widget=forms.Select(attrs={'class':'giant asm'}), label=_('Labor Market Status')) 26 26 workplace = forms.CharField(required=False, widget=forms.Textarea(attrs={'class':'giant asm'}), label=_('Profession Workplace')) … … 30 30 class Meta: 31 31 model = Profession 32 fields = (' profession','labor_market_status', 'workplace', 'working_hours', 'comments', 'status')32 fields = ('labor_market_status', 'workplace', 'working_hours', 'comments', 'status') 33 33 34 34 class EducationalLevelForm(forms.ModelForm): -
trunk/gestorpsi/demographic/views.py
r1472 r1491 24 24 from gestorpsi.demographic.forms import EducationalLevelForm, ProfessionForm 25 25 from gestorpsi.demographic.models import EducationalLevel, Profession 26 27 from gestorpsi.cbo.models import Occupation 26 28 27 29 from gestorpsi.client.views import _access_check … … 81 83 def occupation(request, object_id, occupation_id=0): 82 84 object = get_object_or_404(Client, pk=object_id, person__organization=request.user.get_profile().org_active) 85 83 86 # check access by requested user 84 87 if not _access_check(request, object): … … 86 89 87 90 occupation_object = get_object_or_None(Profession, id=occupation_id) or Profession() 91 88 92 profession_form = ProfessionForm(instance=occupation_object) 93 89 94 professions = [p for p in object.profession_set.all()] 90 95 return render_to_response('demographic/demographic_occupation.html', { … … 93 98 'professions': professions, 94 99 'profession_form': profession_form, 100 'occupation': occupation_object, 95 101 }, context_instance=RequestContext(request)) 96 102 … … 104 110 occupation_object = get_object_or_None(Profession, id=occupation_id) or Profession() 105 111 profession_form = ProfessionForm(request.POST, instance=occupation_object) 112 113 print profession_form.errors 114 print request.POST.get('ocup_class') 115 print Occupation.objects.get(pk=request.POST.get('ocup_class')) 116 106 117 profession = profession_form.save(commit=False) 118 profession.profession = Occupation.objects.get(pk=request.POST.get('ocup_class')) 107 119 profession.client = object 108 120 profession.save() -
trunk/gestorpsi/media/js/gestorpsi.forms.js
r1464 r1491 854 854 855 855 }); 856 856 857 /******** 858 * OCUPATION SEARCH 859 *********/ 860 861 $('a.show_ocup_search').click(function() { 862 $('.ocup_search').toggle(); 863 $('table#ocup_results tbody').html(''); 864 }); 865 866 $('input[name=ocup_search_key]').keyup(function() { 867 var typed = $(this).val(); 868 if(typed.length >= 2) { 869 $.getJSON('/util/ocupation/?query=' + typed, function(json) { 870 line = ''; 871 jQuery.each(json, function() { 872 line += '<tr><td class="ocup_id">' + this.id + '</td><td class="ocup_label"><a style="cursor:pointer;">' + this.name + '</a></td></tr>'; 873 }); 874 $('table#ocup_results tbody').html(line); 875 $('table#ocup_results tr td a').click(function() { 876 $('input[name=ocup_class]').val($(this).parents('tr').children('td.ocup_id').text()); 877 $('span.ocup_name').text($(this).parents('tr').children('td.ocup_label').children('a').text()); 878 $('.ocup_search').hide(); 879 $('table#ocup_results tbody tr').show(); 880 $('input[name=ocup_search_key]').val(''); 881 }); 882 883 }); 884 } else { 885 $('table#ocup_results tbody').html(''); 886 } 887 }); 888 889 890 /* MAIN FUNCTION */ 857 891 }); -
trunk/gestorpsi/templates/demographic/demographic_occupation.html
r1365 r1491 51 51 52 52 <fieldset> 53 <legend>{% trans "Occupation Detail" %}</legend> 54 <div class="form_as_ul"> 55 {{ profession_form.as_ul }} 56 </div> 53 <legend>{% trans "Occupation Detail " %}</legend> 54 55 56 <label>Occupation Code <a style="cursor: pointer;" class="show_ocup_search">Search Code?</a><br> 57 <input type="text" id="id_ocup_class" name="ocup_class" value="{{ occupation.profession.id }}"> 58 </label> 59 60 <br /> 61 <br /> 62 63 <label> 64 <span class="ocup_name">{{ occupation }}</span> 65 </label> 66 67 <br /> 68 <br /> 69 <br /> 70 71 <label class="ocup_search hidden" style="display: none;">Occupation Search<br> 72 <input type="text" class="big" name="ocup_search_key"> 73 </label> 74 75 <div class="overflow ocup_search hidden" style="display: none;"> 76 <table class="zebra" id="ocup_results"> 77 <thead> 78 <tr> 79 <th></th> 80 <th></th> 81 </tr> 82 </thead> 83 <tbody></tbody> 84 </table> 85 </div> 86 87 <div class="form_as_ul"> 88 {{ profession_form.as_ul }} 89 </div> 90 57 91 </fieldset> 92 <br /> 58 93 59 94 </p> -
trunk/gestorpsi/util/urls.py
r1245 r1491 17 17 from django.conf.urls.defaults import * 18 18 from django.contrib.auth.decorators import login_required 19 from gestorpsi.util.views import cnae 19 from gestorpsi.util.views import cnae, ocupation 20 20 21 21 urlpatterns = patterns('', 22 22 (r'^cnae/$', login_required(cnae)), 23 (r'^ocupation/$', login_required(ocupation)), 23 24 ) -
trunk/gestorpsi/util/views.py
r1310 r1491 24 24 from django.template import Context 25 25 from gestorpsi.util.models import Cnae 26 from gestorpsi.cbo.models import Occupation 26 27 27 28 def get_object_or_new(klass, *args, **kwargs): … … 57 58 return HttpResponse(simplejson.dumps(results)) 58 59 60 def ocupation(request): 61 print "ocupation" 62 ''' 63 filter Cnae's return a dict with cnae codes and sub classes names 64 ''' 65 results = [] 66 for i in Occupation.objects.filter(title__icontains=request.GET.get('query')): 67 results.append({'id': i.id, 'name': i.title }) 68 69 return HttpResponse(simplejson.dumps(results)) 70 59 71 def write_pdf(template_src, context_dict, filename='output.pdf'): 60 72 template = get_template(template_src)
