Example #1
0
 def __init__(self, *args, **kwargs):
     self.request = get_request()
     if self.request.POST:
         super(BaseForm, self).__init__(self.request.POST, *args, **kwargs)
     else:
         super(BaseForm, self).__init__(*args, **kwargs)
     if 'photo' in self.fields:
         del self.fields['photo']
     self.fields['publish'].choices = publish_choices()
Example #2
0
 def __init__(self, *args, **kwargs):
     self.request = get_request()
     if self.request.POST:
         super(BaseForm, self).__init__(self.request.POST, *args, **kwargs)
     else:
         super(BaseForm, self).__init__(*args, **kwargs)
     if 'photo' in self.fields:
         del self.fields['photo']
     self.fields['publish'].choices = publish_choices()
Example #3
0
 def allowed(self):
     request = get_request()
     return self.publish or get_request().user == self.user or self.publish is None
Example #4
0
 def before_save(self, is_insert=True):
     self.is_insert = is_insert
     self.updated = datetime.now()
     if is_insert:
         self.user = get_request().user
Example #5
0
def geo_pos(form):
    request = get_request()
    return hasattr(form.instance, 'geo_pos') and form.instance.geo_pos or \
        (hasattr(request, 'POST') and 'geo_pos' in request.POST and \
        request.POST['geo_pos']) or \
        ', '.join(map(lambda x: str(x), DEFAULT_LOCATION))
Example #6
0
def tr(kalimat, request=None):
    request = request or get_request()
    to = request.session.get('lang', 'id')
    return translate(kalimat, to=to)
Example #7
0
def tr(kalimat, request=None):
    request = request or get_request()
    to = request.session.get('lang','id')
    return translate(kalimat, to=to)
Example #8
0
 def save(self, *args, **kwargs):
     request = get_request()
     self.instance.category = request.POST.getlist('category')
     super(LivelihoodForm, self).save(*args, **kwargs)
Example #9
0
def t_(text, request=None):
    request = request or get_request()
    return html2text(translate(text, to=request.session.get('lang', 'id')))
Example #10
0
def t_(text, request=None):
    request = request or get_request()
    return html2text(translate(text, to=request.session.get('lang','id')))
Example #11
0
def geo_pos(form):
    request = get_request()
    return hasattr(form.instance, 'geo_pos') and form.instance.geo_pos or \
        (hasattr(request, 'POST') and 'geo_pos' in request.POST and \
        request.POST['geo_pos']) or \
        ', '.join(map(lambda x: str(x), DEFAULT_LOCATION))
Example #12
0
 def allowed(self):
     request = get_request()
     return self.publish or get_request(
     ).user == self.user or self.publish is None
Example #13
0
 def before_save(self, is_insert=True):
     self.is_insert = is_insert
     self.updated = datetime.now()
     if is_insert:
         self.user = get_request().user