Esempio n. 1
0
def add_meta_info_fields_to_sender_form(sender, initial):
    form = sender
    form.fields['meta_description'] = london.forms.TextField(name='meta_description', widget=LetterCounterTextarea(maximum=160), required=False)
    form.fields['meta_keywords'] = london.forms.TextField(name='meta_keywords', widget=LetterCounterTextarea(maximum=160), required=False)
    
    meta_obj = None
    try:
        meta_obj = MetaInfo.query().get(owner=form.instance)
    except:
        pass
    
    if meta_obj:
        initial['meta_description'] = meta_obj['meta_description']
        initial['meta_keywords'] = meta_obj['meta_keywords']    
 def _meta_description_for(self, obj, caller):
     try:
         return MetaInfo.query().get(owner=obj)['meta_description'] or ''
     except MetaInfo.DoesNotExist:
         return ''
 def _meta_keywords_for(self, obj, caller):
     try:
         return MetaInfo.query().get(owner=obj)['meta_keywords'] or ''
     except MetaInfo.DoesNotExist:
         return ''
Esempio n. 4
0
def save_meta_info_from_sender_form(sender):
    new_meta_obj, new = MetaInfo.query().get_or_create(owner=sender.instance)
    new_meta_obj['meta_keywords']=sender.cleaned_data['meta_keywords']
    new_meta_obj['meta_description']=sender.cleaned_data['meta_description']
    new_meta_obj.save()