def render(self, context): request = context['request'] coordinat = self.coordinat.resolve(context) if not coordinat: return '' latitude, longitude = map(lambda x: singleposformat(float(x)), str(coordinat).split(',')) return '%s %s, %s %s' % (tr( 'Utara', request), latitude, tr('Timur', request), longitude)
def render(self, context): request = context['request'] coordinat = self.coordinat.resolve(context) if not coordinat: return '' latitude, longitude = map(lambda x: singleposformat(float(x)), str(coordinat).split(',')) return '%s %s, %s %s' % ( tr('Utara', request), latitude, tr('Timur', request), longitude)
def show_menu_lang(context, name='menu-lang'): request = context['request'] menu = [] try: for line in Block.objects.get(name=name).content.splitlines(): line = line.rstrip() try: title, url = line.rsplit(' ', 1) except: continue url += '?destination=%s' % request.path menu.append({'title': tr(title.strip(), request), 'url': url}) except Block.DoesNotExist: pass # Mark the best-matching URL as active active = None active_len = 0 # Normalize path path = request.path.rstrip('/') + '/' for item in menu: # url = '/lang/en?destination=/hp/memilih-handphone if request.session.get( 'lang', 'id') == item['url'].split('?')[0].split('/')[-1]: active = item active_len = len(url) if active is not None: active['active'] = True return {'menu': menu}
def show_menu(context, name='menu'): request = context['request'] menu = [] try: for line in Block.objects.get(name=name).content.splitlines(): line = line.rstrip() try: title, url = line.rsplit(' ', 1) except: continue menu.append({'title': tr(title.strip(), request), 'url': url}) except Block.DoesNotExist: pass # Mark the best-matching URL as active active = None active_len = 0 # Normalize path path = request.path.rstrip('/') + '/' for item in menu: # Normalize path url = item['url'].rstrip('/') + '/' # Root is only active if you have a "Home" link if path != '/' and url == '/': continue if path.startswith(url) and len(url) > active_len: active = item active_len = len(url) if active is not None: active['active'] = True return {'menu': menu}
def show_menu_lang(context, name='menu-lang'): request = context['request'] menu = [] try: for line in Block.objects.get(name=name).content.splitlines(): line = line.rstrip() try: title, url = line.rsplit(' ', 1) except: continue url += '?destination=%s' % request.path menu.append({'title': tr(title.strip(), request), 'url': url}) except Block.DoesNotExist: pass # Mark the best-matching URL as active active = None active_len = 0 # Normalize path path = request.path.rstrip('/') + '/' for item in menu: # url = '/lang/en?destination=/hp/memilih-handphone if request.session.get('lang','id') == item['url'].split('?')[0].split('/')[-1]: active = item active_len = len(url) if active is not None: active['active'] = True return {'menu': menu}
def cms(request): return { 'site_name': tr(settings.SITE_NAME, request), 'site_copyright': settings.SITE_COPYRIGHT, 'google_analytics_id': getattr(settings, 'GOOGLE_ANALYTICS_ID', None), 'google_custom_search_id': getattr(settings, 'GOOGLE_CUSTOM_SEARCH_ID', None), }
def login(request): if request.user.is_authenticated(): return HttpResponseRedirect('/sudah-login-%s' % request.user.username) if not request.POST: return direct_to_template(request, 'login.html') username = request.POST['username'] password = request.POST['password'] user = auth.authenticate(username=username, password=password) # just check if user is not None and user.is_active: auth.login(request, user) # session return HttpResponseRedirect('/') return direct_to_template(request, 'login.html', { 'error': tr('Login gagal', request), })
def publish_choices(): return ( (True, tr('Terbitkan')), (False, tr('Jangan terbitkan')) )
def genders(): return ( (True, tr('Laki-laki')), (False, tr('Perempuan')), )
from django.db import models from livecenter.models import Location from livecenter.tools import GeoModel from translate.lang import tr KATA_TIPE = tr('Tipe') TIPE_PINJAMAN = ( ('Type A', '%s %s' % (KATA_TIPE, 'A')), ('Type B', '%s %s' % (KATA_TIPE, 'B')), ('Type C', '%s %s' % (KATA_TIPE, 'C')) ) SYARAT_AGUNAN = ( ('Ya', tr('Ya')), ('Tidak', tr('Tidak')) ) JFPR = ( ('Ada', tr('Ada')), ('Belum', tr('Belum')) ) class Finance(GeoModel): name_org = models.CharField('nama organisasi', max_length=100) contact_name = models.CharField('nama kontak', max_length=100) address = models.CharField('alamat', max_length=100) sub_district = models.ForeignKey(Location, null=True, related_name='+', verbose_name='kecamatan') district = models.ForeignKey(Location, null=True, related_name='+', verbose_name='kabupaten') mobile = models.CharField('telepon selular', max_length=20, blank=True)
def training_choices(): kali = tr('kali') items = [] for i in range(20): items.append((i, '%d %s' % (i, kali))) return items
def training_choices(): kali = tr('kali') items = [] for i in range(20): items.append((i,'%d %s' % (i, kali))) return items
def publish_choices(): return ((True, tr('Terbitkan')), (False, tr('Jangan terbitkan')))