def save(self, *args, **kwargs): if self.title == '': self.title = '%s...?' % (self.description[:124]) self.slug = slugicefy(self.title) if not self.creator: self.creator = User.objects.get(pk=1) super(Question, self).save(*args, **kwargs)
def save(self, *args, **kwargs): self.slug = slugicefy(self.title) flatpage = None try: flatpage = FlatPage.on_site.get(url=self.url) except: pass if self.parent: self.url = '/'.join([self.parent.url[:-1], self.slug, '']) else: self.url = '/' if flatpage: flatpage.url = self.url flatpage.save() super(Menu, self).save(*args, **kwargs) for child in self.children.all(): child.save()
def save(self, *args, **kwargs): self.slug = slugicefy(self.name) super(CountryArea, self).save(*args, **kwargs)
def save(self, *args, **kwargs): self.slug = slugicefy(self.name) super(School, self).save(*args, **kwargs)
def save(self, *args, **kwargs): self.tag = self.tag.lower() self.slug = slugicefy(self.tag) super(Tag, self).save(*args, **kwargs) self.creator.tag(self.target)
def save(self, *args, **kwargs): self.slug = slugicefy(self.title) super(Event, self).save(*args, **kwargs)
def save(self, *args, **kwargs): self.slug = slugicefy(self.name) super(Stakeholder, self).save(*args, **kwargs)
def render_template(self, request, form, previous_fields, step, context=None): if not context: context = {} ctx = context previous_values = [] """ Determining the step status for the display of the side information. As the steps move up, so does the level of information """ if step == 0: # Sizes for the cloud sizes = ['tiny','small','normal','large','huge'] # Get all professions profession_clouds = {} for p in Profession.objects.all(): try: profession_clouds[p.exam.title].append(p.title.lower()) except: profession_clouds[p.exam.title] = [p.title.lower()] if request.user.is_authenticated(): # If user is authenticated add to the list all professions within the same field as the profession she has used fields = Field.objects.filter(subfield__profession__programme__author=request.user) for p in Profession.objects.filter(field__field__in=fields): try: profession_clouds[p.exam.title].append(p.title.lower()) except: profession_clouds[p.exam.title] = [p.title.lower()] # Create a profession cloud ctx['exams'] = Exam.objects.all() ctx['levels'] = [_('Level 1'), _('Level 2'), _('Level 3'), _('Level 4'), ] ctx['fields'] = Field.objects.all() ctx['profession_clouds'] = [] for exam in profession_clouds.keys(): ctx['profession_clouds'].append({'exam':exam, 'cloud':cloudify(profession_clouds[exam],sizes)}) if step == 3: default_competence_values = {} default_competences = KeyCompetence.objects.filter(default=True) for competence in default_competences: default_competence_values[competence.get_key_competence_display()] = competence.description ctx['key_competence_fields'] = [] for (choice_value, choice_title) in KeyCompetence.KEY_COMPETENCE_CHOICES: ctx['key_competence_fields'].append({'label_tag':choice_title, 'choice':choice_value, 'name':slugicefy(choice_title), 'value':default_competence_values.get(choice_title,'')}) if step == 5: # Needs a better filter when school approval is up and running ctx['courses'] = Course.objects.all() return super(ProgrammeWizard, self).render_template(request,form,previous_fields,step,ctx)