Esempio n. 1
0
def actually_create_band(user, band_name):
    band = Band()
    band.title = band_name
    band.total_space = settings.BAND_INIT_SPACE
    band.save()

    manager = BandMember()
    manager.user = user
    manager.band = band
    manager.role = BandMember.MANAGER
    manager.save()
Esempio n. 2
0
def actually_create_band(user, band_name):
    band = Band()
    band.title = band_name
    band.total_space = settings.BAND_INIT_SPACE
    band.save()

    manager = BandMember()
    manager.user = user
    manager.band = band
    manager.role = BandMember.MANAGER
    manager.save()
Esempio n. 3
0
def user_register_plan(request, plan_url):
    "plan_url of 'free' means free plan"
    if request.user.is_authenticated():
        return change_plan(request, plan_url)

    if request.method == 'POST':
        form = RegisterForm(request.POST)
        if form.is_valid():
            plan_id = 0
            plan = None

            # create the user
            user = User.objects.create_user(form.cleaned_data.get('username'),
                form.cleaned_data.get('email'),
                form.cleaned_data.get('password'))
            user.save()

            # create a band
            band = Band()
            band.title = form.cleaned_data.get('artist_name')
            band.total_space = settings.BAND_INIT_SPACE
            band.save()

            # create a profile
            profile = Profile()
            profile.user = user
            profile.solo_band = band
            profile.activated = False
            profile.activate_code = create_hash(32)
            profile.logon_count = 0
            profile.band_count_limit = settings.FREE_BAND_LIMIT
            profile.save()

            # make them a manager
            manager = BandMember()
            manager.user = user
            manager.band = band
            manager.role = BandMember.MANAGER
            manager.save()

            # send an activation email
            subject = design.account_confirmation
            context = Context({
                'user': user,
                'activate_url': request.build_absolute_uri(reverse('confirm', args=[user.username, profile.activate_code])),
                'host': request.get_host(),
            })
            message_txt = get_template('email/activation.txt').render(context)
            message_html = get_template('email/activation.html').render(context)
            send_html_mail(subject, message_txt, message_html, [user.email])

            return HttpResponseRedirect(reverse("register_pending"))
    else:
        try:
            plan = AccountPlan.objects.get(url=plan_url)
            plan_id = plan.id
        except AccountPlan.DoesNotExist:
            plan = None
            plan_id = 0

        form = RegisterForm(initial={'plan': plan_id})
    return render_to_response('register.html', {'form': form}, context_instance=RequestContext(request))
Esempio n. 4
0
def user_register_plan(request, plan_url):
    "plan_url of 'free' means free plan"
    if request.user.is_authenticated():
        return change_plan(request, plan_url)

    if request.method == 'POST':
        form = RegisterForm(request.POST)
        if form.is_valid():
            plan_id = 0
            plan = None

            # create the user
            user = User.objects.create_user(form.cleaned_data.get('username'),
                                            form.cleaned_data.get('email'),
                                            form.cleaned_data.get('password'))
            user.save()

            # create a band
            band = Band()
            band.title = form.cleaned_data.get('artist_name')
            band.total_space = settings.BAND_INIT_SPACE
            band.save()

            # create a profile
            profile = Profile()
            profile.user = user
            profile.solo_band = band
            profile.activated = False
            profile.activate_code = create_hash(32)
            profile.logon_count = 0
            profile.band_count_limit = settings.FREE_BAND_LIMIT
            profile.save()

            # make them a manager
            manager = BandMember()
            manager.user = user
            manager.band = band
            manager.role = BandMember.MANAGER
            manager.save()

            # send an activation email
            subject = design.account_confirmation
            context = Context({
                'user':
                user,
                'activate_url':
                request.build_absolute_uri(
                    reverse('confirm',
                            args=[user.username, profile.activate_code])),
                'host':
                request.get_host(),
            })
            message_txt = get_template('email/activation.txt').render(context)
            message_html = get_template('email/activation.html').render(
                context)
            send_html_mail(subject, message_txt, message_html, [user.email])

            return HttpResponseRedirect(reverse("register_pending"))
    else:
        try:
            plan = AccountPlan.objects.get(url=plan_url)
            plan_id = plan.id
        except AccountPlan.DoesNotExist:
            plan = None
            plan_id = 0

        form = RegisterForm(initial={'plan': plan_id})
    return render_to_response('register.html', {'form': form},
                              context_instance=RequestContext(request))