コード例 #1
0
def get_user_expiry(name, password, lang, _ip):
    user = Users.objects.filter(name__iexact=name, ).first()
    user_ip, create = BlockIP.objects.get_or_create(ip=_ip)

    if user and check_password(password, user.password):
        user_ip.faild_try = 0
        user_ip.block = False
        user_ip.save()

        if lang == "fa":
            oreder = date2jalali(user.order_date).strftime('%Y-%m-%d')
            expire = date2jalali(user.order_expire).strftime('%Y-%m-%d')

        else:
            oreder = datetime.strftime(user.order_date, '%Y-%m-%d')
            expire = datetime.strftime(user.order_expire, '%Y-%m-%d')

        result = {
            'name': user.name,
            'order': oreder,
            'expire': expire,
        }
        return result

    user_ip.faild_try += 1
    user_ip.save()
    if user_ip.faild_try > 5:
        user_ip.block = True
        user_ip.save()

    return False
コード例 #2
0
ファイル: main_tags.py プロジェクト: amir199675/municipal
def month(value):
    date = jalali_date.date2jalali(value)
    month = None
    if date.month == 1:
        month = 'فروردین'
    elif date.month == 2:
        month = 'اردیبهشت'
    elif date.month == 3:
        month = 'خرداد'
    elif date.month == 4:
        month = 'تیر'
    elif date.month == 5:
        month = 'مرداد'
    elif date.month == 6:
        month = 'شهریور'
    elif date.month == 7:
        month = 'مهر'
    elif date.month == 8:
        month = 'آبان'
    elif date.month == 9:
        month = 'آذر'
    elif date.month == 10:
        month = 'دی'
    elif date.month == 11:
        month = 'بهمن'
    elif date.month == 12:
        month = 'اسفند'

    return month
コード例 #3
0
def to_jalali(g_date, strftime=None):
    if g_date is None:
        return '-'
    elif isinstance(g_date, datetime):
        return datetime2jalali(g_date).strftime(
            strftime if strftime else '%y/%m/%d _ %H:%M:%S')
    elif isinstance(g_date, date):
        return date2jalali(g_date).strftime(
            strftime if strftime else '%y/%m/%d')
    return '-'
コード例 #4
0
def to_jalali(g_date, strftime=None):
	if g_date is None:
		return '-'
	elif isinstance(g_date, datetime):
		strftime = strftime if strftime else DEFAULTS['Strftime']['datetime']
		return datetime2jalali(g_date).strftime(strftime)
	elif isinstance(g_date, date):
		strftime = strftime if strftime else DEFAULTS['Strftime']['date']
		return date2jalali(g_date).strftime(strftime)
	return '-'
コード例 #5
0
def to_jalali(g_date, strftime=None):
	if g_date is None:
		return '-'
	elif isinstance(g_date, datetime):
		strftime = strftime if strftime else DEFAULTS['Strftime']['datetime']
		return datetime2jalali(g_date).strftime(strftime)
	elif isinstance(g_date, date):
		strftime = strftime if strftime else DEFAULTS['Strftime']['date']
		return date2jalali(g_date).strftime(strftime)
	return '-'
コード例 #6
0
def supply_list_view(request):
    if request.method == 'POST' and request.POST['supply_id'] and request.POST[
            'supply_price']:
        id = request.POST['supply_id']
        supply = SupplyOrder.objects.get(id=id)
        supply.price = request.POST['supply_price']
        supply.save()
        Activity.objects.create(
            type='خرید',
            title='خرید محصول ' + supply.name + 'به مقدار ' + supply.amount,
            description='در تاریخ ' +
            date2jalali(getNow().date()).strftime('%y/%m/%d'),
            moneyTrade=supply.price)

    supplies = SupplyOrder.objects.all()
    return render(request, 'supply_list.html', {'supplies': supplies})
コード例 #7
0
def jalali_admin_safe_readonly(readonly_field, strftime=None):
	"""
	:param readonly_field: django.contrib.admin.helpers.AdminReadOnlyField
	:param strftime: format output
	:return: str
	"""
	instance = readonly_field.form.instance
	field_name = readonly_field.field['field']

	if not hasattr(instance, field_name):
		return readonly_field

	field = getattr(instance, field_name)
	if isinstance(field, datetime):
		strftime = strftime if strftime else DEFAULTS['Strftime']['datetime']
		return ObjectContents(datetime2jalali(field).strftime(strftime))
	elif isinstance(field, date):
		strftime = strftime if strftime else DEFAULTS['Strftime']['date']
		return ObjectContents(date2jalali(field).strftime(strftime))
	elif field is None:
		return ObjectContents('-')

	return readonly_field
コード例 #8
0
def jalali_admin_safe_readonly(readonly_field, strftime=None):
	"""
	:param readonly_field: django.contrib.admin.helpers.AdminReadOnlyField
	:param strftime: format output
	:return: str
	"""
	instance = readonly_field.form.instance
	field_name = readonly_field.field['field']

	if not hasattr(instance, field_name):
		return readonly_field

	field = getattr(instance, field_name)
	if isinstance(field, datetime):
		strftime = strftime if strftime else DEFAULTS['Strftime']['datetime']
		return ObjectContents(datetime2jalali(field).strftime(strftime))
	elif isinstance(field, date):
		strftime = strftime if strftime else DEFAULTS['Strftime']['date']
		return ObjectContents(date2jalali(field).strftime(strftime))
	elif field is None:
		return ObjectContents('-')

	return readonly_field
コード例 #9
0
def handle_jobtime(request):
    if request.method != 'POST':
        return JsonResponse({})  # handle nothing
    employee = request.user
    response = {}
    if employee.workBegan is None:
        employee.workBegan = getNow()
        employee.save()
        response['work'] = 1
    else:
        Activity.objects.create(
            type='گزارش کارمند',
            title=' ساعت کاری آقا/خانم ' + employee.first_name + ' ' +
            employee.last_name,
            description='در تاریخ ' +
            date2jalali(getNow().date()).strftime('%y/%m/%d') + 'آقا/خانم ' +
            employee.first_name + ' ' + employee.last_name + 'از ساعت ' +
            employee.workBegan.strftime('%H:%M') + ' تا ساعت ' +
            getNow().strftime('%H:%M') + ' مشغول به کار بودند.',
            moneyTrade=0)
        employee.workBegan = None
        employee.save()
        response['work'] = 0
    return JsonResponse(response)
コード例 #10
0
ファイル: main_tags.py プロジェクト: amir199675/municipal
def year(value):
    date = jalali_date.date2jalali(value)
    year = date.year

    return year
コード例 #11
0
ファイル: main_tags.py プロジェクト: amir199675/municipal
def shamsi(value):
    try:
        date = jalali_date.date2jalali(value)
        return str(date.year) + '/' + str(date.month) + '/' + str(date.day)
    except:
        return 'ثبت نشده'
コード例 #12
0
ファイル: admin.py プロジェクト: vahidamintabar/mailroom
 def jalali_date(self, obj):
     return date2jalali(obj.date).strftime('%y/%m/%d')
コード例 #13
0
ファイル: main_tags.py プロジェクト: amir199675/municipal
def day(value):
    date = jalali_date.date2jalali(value)
    day = date.day

    return day
コード例 #14
0
ファイル: admin.py プロジェクト: Hamidnet220/hesab
def convert_date_to_jalali(obj):
    return date2jalali(obj.date)
コード例 #15
0
ファイル: main_tags.py プロジェクト: amir199675/kohnavardi
def shamsi(value):
    date = jalali_date.date2jalali(value)
    return date
コード例 #16
0
ファイル: models.py プロジェクト: mrsaemir/manyxwebsite
 def since(self):
     from jalali_date import date2jalali
     return date2jalali(self.date_joined).strftime('13%y-%m-%d')
コード例 #17
0
ファイル: admin.py プロジェクト: moh3nmx/hamitarh
 def jrequestDate(self, obj):
     if obj.requestDate:
         return str(date2jalali(obj.requestDate)).replace('-', '/')
     else:
         return '-'
コード例 #18
0
ファイル: models.py プロジェクト: moh3nmx/hamitarh
 def review_directory_path(obj, filename):
     return 'AdReview/ad_{0}/{1}__{2}'.format(
         obj.id,
         date2jalali(datetime.today()).strftime('%y_%m_%d'), filename)