Exemplo n.º 1
0
def post(request, pk):
	"""Single post with comments and a comment form."""
	post = Post.objects.get(pk=int(pk))
	comments = Comment.objects.filter(post=post)

	#add form
	form = SignUpForm(request.POST or None)

	if form.is_valid():
		instance = form.save(commit=False)
		full_name = form.cleaned_data.get("full_name")
		if not full_name:
			full_name = "New full name"
		instance.full_name = full_name
		instance.save()
		return HttpResponseRedirect('')

	return render(
	request,
	'blog/post.html',
	context_instance = RequestContext(request,
		{
		"post" : post,
		"comments": comments,
		"form": CommentForm(), 
	 	"user": request.user,
 		"months" : mkmonth_lst(),
 		"categories": category_lst(),
		"form_signup" : form,
		})
	)
Exemplo n.º 2
0
def month(request, year, month):
    """Monthly archive."""
    posts = Post.objects.filter(created__year=year,
                                created__month=month,
                                visible=True).order_by("-created")

    #add form
    form = SignUpForm(request.POST or None)

    if form.is_valid():
        instance = form.save(commit=False)
        full_name = form.cleaned_data.get("full_name")
        if not full_name:
            full_name = "New full name"
        instance.full_name = full_name
        instance.save()
        return HttpResponseRedirect('')

    return render(request,
                  'blog/list.html',
                  context_instance=RequestContext(
                      request, {
                          "title": 'Blog by Time',
                          "posts": posts,
                          "user": request.user,
                          "months": mkmonth_lst(),
                          "categories": category_lst(),
                          "archive": True,
                          "form_signup": form,
                          "year": year,
                          "month": month,
                      }))
Exemplo n.º 3
0
def under_construction(request):
	"""Under Construction home view"""
	title = "Under Construction"

	#add form
	form = SignUpForm(request.POST or None)

	if form.is_valid():
		instance = form.save(commit=False)
		full_name = form.cleaned_data.get("full_name")
		if not full_name:
			full_name = "New full name"
		instance.full_name = full_name
		instance.save()
		return HttpResponseRedirect('thankyou')

	return render(
		request,
		'uc/uc_home.html',
		context_instance = RequestContext(request,
			{
			"title": title,
			"form" : form,
			})
		)
Exemplo n.º 4
0
def main(request):
	title = "Recent Revit Plugin Releases by Archilizer"
	""" Main listing """
	

	#add form
	form = SignUpForm(request.POST or None)

	if form.is_valid():
		instance = form.save(commit=False)
		full_name = form.cleaned_data.get("full_name")
		if not full_name:
			full_name = "New full name"
		instance.full_name = full_name
		instance.save()
		return HttpResponseRedirect('')

	return render(
		request,
		'release/main.html',
		context_instance = RequestContext(request,
			{
			"title" : title,
			"form_signup" : form,
			})
		)
Exemplo n.º 5
0
def post(request, pk):
    """Single post with comments and a comment form."""
    post = Post.objects.get(pk=int(pk))
    comments = Comment.objects.filter(post=post)

    #add form
    form = SignUpForm(request.POST or None)

    if form.is_valid():
        instance = form.save(commit=False)
        full_name = form.cleaned_data.get("full_name")
        if not full_name:
            full_name = "New full name"
        instance.full_name = full_name
        instance.save()
        return HttpResponseRedirect('')

    return render(request,
                  'blog/post.html',
                  context_instance=RequestContext(
                      request, {
                          "post": post,
                          "comments": comments,
                          "form": CommentForm(),
                          "user": request.user,
                          "months": mkmonth_lst(),
                          "categories": category_lst(),
                          "form_signup": form,
                      }))
Exemplo n.º 6
0
def module(request, pk):
	"""Individual module references"""
	module = TrainingModule.objects.get(pk=int(pk))
	next = module.get_next()
	prev = module.get_prev()

	#add form
	form = SignUpForm(request.POST or None)

	if form.is_valid():
		instance = form.save(commit=False)
		full_name = form.cleaned_data.get("full_name")
		if not full_name:
			full_name = "New full name"
		instance.full_name = full_name
		instance.save()
		return HttpResponseRedirect('thankyou')


	return render(
		request,
		'trainings/module.html',
		context_instance = RequestContext(request,
			{			
			'module': module,
			'next' : next,
			'prev' : prev,
			"form_signup" : form,
			})
		)
Exemplo n.º 7
0
def month(request, year, month):
	"""Monthly archive."""
	posts = Post.objects.filter(created__year=year, created__month=month, visible=True).order_by("-created")

	#add form
	form = SignUpForm(request.POST or None)

	if form.is_valid():
		instance = form.save(commit=False)
		full_name = form.cleaned_data.get("full_name")
		if not full_name:
			full_name = "New full name"
		instance.full_name = full_name
		instance.save()
		return HttpResponseRedirect('')

	return render(
	request,
	'blog/list.html',
	context_instance = RequestContext(request,
		{
		"title": 'Blog by Time',
		"posts" : posts,
	 	"user": request.user,
	 	"months" : mkmonth_lst(),
 		"categories": category_lst(),
	 	"archive" : True,
		"form_signup" : form,
		"year" : year,
		"month" : month,
		})
	)
Exemplo n.º 8
0
def sign_up(request):
    # Protect against CSRF attacks
    if request.method == 'POST': # If the form has been submitted...
        form = SignUpForm(request.POST)
        if form.is_valid():
            m1 = hashlib.sha512()
            m2 = hashlib.sha512()
            username = form.cleaned_data['username']
            password = form.cleaned_data['password']
            first_name = form.cleaned_data['first_name']
            last_name = form.cleaned_data['last_name']
            email = form.cleaned_data['email']
            u = User.objects.create_user(username=username,
                                        password=password,
                                        first_name=first_name,
                                        last_name=last_name,
                                        email=email
                                        )
            u.is_active = False
            u.save()
            code = sendmail.generate_code()
            m1.update(code)
            m2.update(username)
            ConfirmationCode.objects.create(code=m1.hexdigest(), uid=m2.hexdigest())
            sendmail.sendmail(email, code)
            return HttpResponseRedirect('/activate/') # Redirect after POST
    else:
        form = SignUpForm() # An unbound form

    return render(request, 'signup/sign_up.html', {
        'form': form,
    })
Exemplo n.º 9
0
def signup(request):
    if request.method == 'POST':
        form = SignUpForm(request.POST)
        if form.is_valid():
            form.save()
            email = form.cleaned_data.get('email')
            raw_password = form.cleaned_data.get('password1')
            user = authenticate(username=email, password=raw_password)
            return redirect('login')
    else:
        form = SignUpForm()
    return render(request, 'signup.html', {'form': form})
Exemplo n.º 10
0
def signup(request):
    if request.method == "POST":
        form = SignUpForm(request.POST)
        if form.is_valid():
            form.save()
            username = form.cleaned_data.get("username")
            raw_password = form.cleaned_data.get("password1")
            user = authenticate(username=username, password=raw_password)
            login(request, user)
            return redirect("home")
    else:
        form = SignUpForm()
    return render(request, "signup/signup.html", {"form": form})
Exemplo n.º 11
0
def signup(request):
    if request.method == 'POST':
        form = SignUpForm(request.POST)
        if form.is_valid():
            form.save()
            username = form.cleaned_data.get('username')
            raw_password = form.cleaned_data.get('password1')
            user = authenticate(username=username, password=raw_password)
            login(request, user)
            return redirect('login_page')
    else:
        form = SignUpForm()
    return render(request, 'signup/signup_form.html', {'form': form})
Exemplo n.º 12
0
def Signup(request): 
	if request.method == 'POST': 
		form = SignUpForm(request.POST) 
		if form.is_valid(): 
			user = form.save() 
			user.refresh_from_db() # load the profile
			user.profile.birthdate = form.cleaned_data.get('birth_date') 
			user.save() 
			raw_password = form.cleaned_data.get('password1') 
			user = authenticate(username=user.username, password=raw_password) 
			login(request, user) return redirect('/') 
	else: 
		form = SignUpForm() 
	return render(request, 'signup.html', {'form': form}) 
Exemplo n.º 13
0
def signup(request):
    if request.method == 'POST':
        form = SignUpForm(request.POST)
        if form.is_valid():
            desired_group = request.POST["desired_group"]
            user = form.save()
            user.is_active = False
            my_group = Group.objects.get(name=desired_group)
            my_group.user_set.add(user)
            user.save()
            return redirect('account_inactive')
    else:
        form = SignUpForm()
    return render(request, 'registration/signup.html', {'form': form})
Exemplo n.º 14
0
def category(request, categorySlug, pk):
	"""Get specified category"""
	posts = Post.objects.all().order_by('-created').filter(visible=True)
	category_posts = []
	for post in posts:
		if post.categories.filter(slug=categorySlug):
			category_posts.append(post)

	"""Add pagination"""
	pages = Paginator(category_posts, 5)

	"""Get the category"""
	category = Category.objects.filter(slug=categorySlug)[0]

	"""Get the specified page"""
	try:
		returned_page = pages.page(pk)
	except EmptyPage:
		returned_page = pages.page(pages.num_pages)


	#add form
	form = SignUpForm(request.POST or None)

	if form.is_valid():
		instance = form.save(commit=False)
		full_name = form.cleaned_data.get("full_name")
		if not full_name:
			full_name = "New full name"
		instance.full_name = full_name
		instance.save()
		return HttpResponseRedirect('')
		

	"""Display all the posts"""
	return render(
	request,
	'blog/category.html',
	context_instance = RequestContext(request,
		{
		"title": 'Blog by Category',
		"posts" : returned_page.object_list,
		"page": returned_page,
		"category": category, 
	 	"months" : mkmonth_lst(),
 		"categories": category_lst(),
		"form_signup" : form,
		})
	)
Exemplo n.º 15
0
def getData(request):
    if (request.method == 'POST'):

        form = SignUpForm(request.POST)
        if (form.is_valid()):
            user = form.save()
            user.refresh_from_db()
            user.save()

            login(request, user)
            return redirect('/home/')
        else:
            return render(request, 'signup-form/index.html', {'form': form})
    else:
        form = SignUpForm()
        return render(request, 'signup-form/index.html', {'form': form})
Exemplo n.º 16
0
def update_profile(request,id):
    if request.method == 'POST':
        user_form = UserForm(request.POST, instance=request.user)
        profile_form = SignUpForm(request.POST, instance=request.user.profile)
        if user_form.is_valid() and profile_form.is_valid():
            user_form.save()
            profile_form.save()
            #messages.success(request, _('Your profile was successfully updated!'))
            return redirect('settings:profile')
        else:
            #messages.error(request, _('Please correct the error below.'))
            print "error"
    else:
        user_form = UserForm(instance=request.user)
        profile_form = SignUpForm(instance=request.user.profile)
    return render(request, 'profiles/profile.html', {
        'user_form': user_form,
        'profile_form': profile_form
    })
Exemplo n.º 17
0
def signup(request):
    #if request.method == 'GET':
    #    response_data = {}
    #    response_data['result'] = 'error'
    #    response_data['message'] = 'You need to post something'
    #    return HttpResponse(json.dumps(response_data), content_type="application/json")

    if request.method == 'POST':
        form = SignUpForm(request.POST)
        if form.is_valid():
            form.save()
            username = form.cleaned_data.get('username')
            raw_password = form.cleaned_data.get('password1')
            user = authenticate(username=username, password=raw_password)
            login(request, user)
            return redirect('home')
    else:
        form = SignUpForm()
    return render(request, 'signup/signup.html', {'form': form})
Exemplo n.º 18
0
def signup(request):
    if request.method == 'POST':
        form = SignUpForm(request.POST)
        if form.is_valid():
            form.save()
            username = form.cleaned_data.get('username')
            raw_password = form.cleaned_data.get('password1')
            user = authenticate(username=username, password=raw_password)
            login(request, user)

            uid = generate_uid()
            with connection.cursor() as cursor:
                cursor.execute(
                    "INSERT INTO Users (uid, login, password) " + "VALUES " +
                    "(%s,%s,%s)", [uid, username, raw_password])
            return redirect('/home')
    else:
        form = SignUpForm()
    return render(request, 'signup/signup.html', {'form': form})
Exemplo n.º 19
0
def about(request):
    """About us page"""

    #add form
    form = SignUpForm(request.POST or None)

    if form.is_valid():
        instance = form.save(commit=False)
        full_name = form.cleaned_data.get("full_name")
        if not full_name:
            full_name = "New full name"
        instance.full_name = full_name
        instance.save()
        return HttpResponseRedirect('thankyou')

    return render(request,
                  'about_us.html',
                  context_instance=RequestContext(request, {
                      "form_signup": form,
                  }))
Exemplo n.º 20
0
def signup(request):
    if request.method == 'POST':
        form = SignUpForm(request.POST)
        if form.is_valid():
            form.save()
            username = form.cleaned_data.get('username')
            email = form.cleaned_data.get('email')
            raw_password = form.cleaned_data.get('password1')
            raw_password2 = form.cleaned_data.get('password2')
            first_name = form.cleaned_data.get('firstname')
            last_name = form.cleaned_data.get('lastname')
            university = form.get('university')
            user = authenticate(username=username, password=raw_password)
            login(request, user)
            # return redirect('/home')
            return HttpResponseRedirect('/home')
    else:
        form = SignUpForm()
    universities = retrieveUniversities()
    return render(request, 'signup.html', {'form': form, 'universities': universities})
Exemplo n.º 21
0
def services(request):
	"""Trainings page"""
	trainings = TrainingModule.objects.all()

	#add form
	form = SignUpForm(request.POST or None)

	if form.is_valid():
		instance = form.save(commit=False)
		full_name = form.cleaned_data.get("full_name")
		if not full_name:
			full_name = "New full name"
		instance.full_name = full_name
		instance.save()
		return HttpResponseRedirect('thankyou')

	# gotodiv = False

	# if request_name(request) == 'development':
	# 	gotodiv = 'development'

	# elif request_name(request) == 'management':
	# 	gotodiv = 'management'

	# elif request_name(request) == 'training':
	# 	gotodiv = 'training'

	# TEST 
	# import pdb; pdb.set_trace()
	# TEST

	return render(
		request,
		'trainings/services.html',
		context_instance = RequestContext(request,
			{			
			'trainings': trainings,
			"form_signup" : form,
			# "gotodiv" : gotodiv,
			})
		)
Exemplo n.º 22
0
def category(request, categorySlug, pk):
    """Get specified category"""
    posts = Post.objects.all().order_by('-created').filter(visible=True)
    category_posts = []
    for post in posts:
        if post.categories.filter(slug=categorySlug):
            category_posts.append(post)
    """Add pagination"""
    pages = Paginator(category_posts, 5)
    """Get the category"""
    category = Category.objects.filter(slug=categorySlug)[0]
    """Get the specified page"""
    try:
        returned_page = pages.page(pk)
    except EmptyPage:
        returned_page = pages.page(pages.num_pages)

    #add form
    form = SignUpForm(request.POST or None)

    if form.is_valid():
        instance = form.save(commit=False)
        full_name = form.cleaned_data.get("full_name")
        if not full_name:
            full_name = "New full name"
        instance.full_name = full_name
        instance.save()
        return HttpResponseRedirect('')
    """Display all the posts"""
    return render(request,
                  'blog/category.html',
                  context_instance=RequestContext(
                      request, {
                          "title": 'Blog by Category',
                          "posts": returned_page.object_list,
                          "page": returned_page,
                          "category": category,
                          "months": mkmonth_lst(),
                          "categories": category_lst(),
                          "form_signup": form,
                      }))
Exemplo n.º 23
0
def Signup(request):
    if request.method == 'POST':
        form = SignUpForm(request.POST)
        if form.is_valid():
            user = form.save()
            user.refresh_from_db(
            )  # load the profile instance created by the signal
            user.email = form.cleaned_data.get('email')
            # this must be in the forms.py as a CharField
            user.profile.hint = form.cleaned_data[
                'hint']  # get with tuple or dict style
            print("print profile user label")
            print(user.profile.hint)
            user.save()
            raw_password = form.cleaned_data.get('password1')
            user = authenticate(username=user.username, password=raw_password)
            login(request, user)
            return redirect('/thanks/')
    else:
        form = SignUpForm()
    return render(request, 'signup.html', {'form': form})
Exemplo n.º 24
0
def signup(request):
    if request.method == 'POST':
        form = SignUpForm(request.POST)
        if form.is_valid():
            user = form.save()
            user.refresh_from_db(
            )  # load the profile instance created by the signal
            #user.profile.birth_date = form.cleaned_data.get('birth_date')
            #user.profile.first_name = form.cleaned_data.get('first_name')
            #user.profile.last_name = form.cleaned_data.get('last_name')
            #user.profile.email = form.cleaned_data.get('email')

            user.save()

            raw_password = form.cleaned_data.get('password1')
            user = authenticate(username=user.username, password=raw_password)
            login(request, user)
            #return render(request, 'home.html')
            return redirect('/home/')
    else:
        form = SignUpForm()
    return render(request, 'signup.html', {'form': form})
Exemplo n.º 25
0
def under_construction(request):
    """Under Construction home view"""
    title = "Under Construction"

    #add form
    form = SignUpForm(request.POST or None)

    if form.is_valid():
        instance = form.save(commit=False)
        full_name = form.cleaned_data.get("full_name")
        if not full_name:
            full_name = "New full name"
        instance.full_name = full_name
        instance.save()
        return HttpResponseRedirect('thankyou')

    return render(request,
                  'uc/uc_home.html',
                  context_instance=RequestContext(request, {
                      "title": title,
                      "form": form,
                  }))
Exemplo n.º 26
0
def main(request):
	""" Main listing """
	posts = Post.objects.all().order_by("-created").filter(visible=True)
	paginator = Paginator(posts, 12)

	try: page = int(request.GET.get("page", '1'))
	except ValueError: page = 1

	try:
		posts = paginator.page(page)
	except (InvalidPage, EmptyPage):
		posts = paginator.page(paginator.num_pages)

	#add form
	form = SignUpForm(request.POST or None)

	if form.is_valid():
		instance = form.save(commit=False)
		full_name = form.cleaned_data.get("full_name")
		if not full_name:
			full_name = "New full name"
		instance.full_name = full_name
		instance.save()
		return HttpResponseRedirect('')

	return render(
		request,
		'blog/list.html',
		context_instance = RequestContext(request,
			{
			"title": 'Blog',
			"posts": posts, 
		 	"user" : request.user,
	 		"months" : mkmonth_lst(),
	 		"categories": category_lst(),
			"form_signup" : form,
			})
		)
Exemplo n.º 27
0
def main(request):
    """ Main listing """
    posts = Post.objects.all().order_by("-created").filter(visible=True)
    paginator = Paginator(posts, 12)

    try:
        page = int(request.GET.get("page", '1'))
    except ValueError:
        page = 1

    try:
        posts = paginator.page(page)
    except (InvalidPage, EmptyPage):
        posts = paginator.page(paginator.num_pages)

    #add form
    form = SignUpForm(request.POST or None)

    if form.is_valid():
        instance = form.save(commit=False)
        full_name = form.cleaned_data.get("full_name")
        if not full_name:
            full_name = "New full name"
        instance.full_name = full_name
        instance.save()
        return HttpResponseRedirect('')

    return render(request,
                  'blog/list.html',
                  context_instance=RequestContext(
                      request, {
                          "title": 'Blog',
                          "posts": posts,
                          "user": request.user,
                          "months": mkmonth_lst(),
                          "categories": category_lst(),
                          "form_signup": form,
                      }))
Exemplo n.º 28
0
def about(request):
	"""About us page"""

	#add form
	form = SignUpForm(request.POST or None)

	if form.is_valid():
		instance = form.save(commit=False)
		full_name = form.cleaned_data.get("full_name")
		if not full_name:
			full_name = "New full name"
		instance.full_name = full_name
		instance.save()
		return HttpResponseRedirect('thankyou')
		
	return render(
		request,
		'about_us.html',
		context_instance = RequestContext(request,
			{
			"form_signup" : form,
			})
		)
Exemplo n.º 29
0
def signup(request):
    is_login = request.user.is_authenticated()
    user_name = request.user.username

    is_error = []

    user_login = ''
    user_name = ''
    user_surname = ''
    user_email = ''
    user_phone_number = ''

    if request.method == 'POST':
        signup_form = SignUpForm(request.POST)
        if signup_form.is_valid():
            user_name = signup_form.cleaned_data['user_name']
            user_surname = signup_form.cleaned_data['user_surname']
            user_email = signup_form.cleaned_data['user_email']
            user_email = check_email(user_email)
            user_phone_number = signup_form.cleaned_data['user_phone_number']
            user_phone_number = check_number(user_phone_number)
            user_login = signup_form.cleaned_data['user_login']
            user_password = signup_form.cleaned_data['user_password']
            user_password_again = signup_form.cleaned_data[
                'user_password_again']

            if not user_name:
                is_error.append('user_name')
            if not user_surname:
                is_error.append('user_surname')
            if not user_email and not user_phone_number:
                is_error.append('user_contacts')
            if not user_password or not user_password_again:
                is_error.append('user_passwords')

            users = User.objects.all()
            user_list = [elem.username for elem in users]

            if not user_login:
                is_error.append('user_login')
            elif user_login in user_list:
                is_error.append('user_login_exist')

            if user_password == user_password_again and not len(is_error):
                user = User.objects.create_user(user_login,
                                                user_email,
                                                user_password,
                                                first_name=user_name,
                                                last_name=user_surname)

                UserData.objects.create(owner_name=user_login,
                                        liked_data='',
                                        order_data='')
                login(request, user)
                return HttpResponseRedirect('/')
            elif user_password and user_password_again:
                is_error.append('different_passwords')
    else:
        signup_form = SignUpForm()

    return render(request, 'signup.html', locals())