Esempio n. 1
0
def _send_sms(message, to):
    from apps.sms.models import SMSLogger
    """ sends sms to given msisdn """
    slog = SMSLogger(phone=to, text=message, mid=None, status='2',
        provider=settings.SMS_PROVIDER)
    slog.send_message()
    """
Esempio n. 2
0
def register_user(request):
    form = UserRegisterForm(request.POST or None, request=request)
    if request.method == 'POST':
        if form.is_valid():
            user = form.save(commit=False)
            sms = SMSLogger(provider='disms',
                            text=settings.USER_REGISTER_SMS % {
                                'login': form.cleaned_data['email'],
                                'password': form.cleaned_data['password']
                            }, phone=form.cleaned_data['phone']
            )
            sms.send_message()
            user.set_password(form.cleaned_data['password'])
            user.is_active = True
            user.is_verified = True
            user.save()
            auth_user = auth.authenticate(username=user.email, password=form.cleaned_data['password'])
            auth.login(request, auth_user)

            #    auth.login(request, auth_user)

            # process invite
            expired = datetime.now() + \
                      timedelta(hours=settings.INVITE_EXPIRES_HOURS)
            invite = get_object_or_None(
                Invite, email=form.cleaned_data['email'],
                expire_date__lte=expired
            )
            if invite:
                invite.is_verified = True
                invite.receiver = user
                invite.save()
                return {'redirect': 'accounts:register-success', 'user': user}
            else:
                return {'redirect': 'catalog:index'}
    days = xrange(1, 32)
    months = xrange(1, 13)
    years = xrange(1930, 2012)
    return {'form': form, 'days': days, 'months': months, 'years': years}