Example #1
0
def register(request):
    context = {}
    template = 'contest/register.html'
    if contest_phase() != 'after':
        form = RegistrationForm()
        if request.method == 'POST':
            form = RegistrationForm(request.POST)
            if form.is_valid():
                uname = form['username'].value()
                pwd = form['password'].value()
                p = Profile()
                p.username = uname
                p.set_password(pwd)
                p.save()
                context['successful_registration'] = uname
                return redirect('home')
            else:
                form = RegistrationForm()

        return render(request, template, {'form': form})
    else:
        messages.warning(request,
                         "No Competition Online Come Back After Some Time")

        return render(request, "404.html")
Example #2
0
 def handle(self):
     for i in range(10):
         user = User.objects.create_user(username='******' + str(i),
                                         password='******' + str(i + 1))
         user.save()
     for i in range(10):
         profile = Profile(user=User.objects.get(username='******' + str(i)),
                           i,
                           date(2005 + i, i + 1, (i + 1) * 2))
         profile.save()
     tags = [
         'django', 'python', 'shell', 'user', 'android', 'net', 'c', 'java',
         'web', 'html'
     ]
     for i in tags:
         tag = Tag(title=i)
         tag.save()
     for i in range(10):
         q = Question(
             title=
             "Cannot to set datetime with input field. Always return DateTime.MinValue",
             text=
             "My programm are supposed to have date filtr and gives article with proper date. But when i input any date in my datetime field my values don't change and are always DateTime.MinValue. Idk why and how i can fix it.",
             is_published=True,
             rating=i,
             author=Profile.objects.get(id=i + 1),
             likes=Profile.objects.get(id=(i + 2) // 2),
             tags=Tag.objects.all()[:i])
     for i in range(10):
         ans = Answer(
             text="Nice question!",
             added_at=date(2019, i + 1, (i + 1) * 2),
             question=Question.objects.get(id=i + 1),
             author=Profile.objects.get(id=(i + 2) // 2),
         )
     for i in range(10):
         ans = Answer(
             text="I don't know!",
             added_at=date(2019, i + 2, i + 3),
             question=Question.objects.get(id=(i + 2) // 2),
             author=Profile.objects.get(id=(i + 3) // 2),
         )
Example #3
0
def register(request):
    context = {}
    template = 'contest/register.html'
    if contest_phase() != 'after':
        context['form'] = RegistrationForm()
        if request.method == 'POST':
            form = RegistrationForm(request.POST)
            if form.is_valid():
                uname = form['username'].value()
                pwd = form['password'].value()
                p = Profile()
                p.username = uname
                p.set_password(pwd)
                p.save()
                context['successful_registration'] = uname
            else:
                context['form'] = form
    return render(request, template, context)
Example #4
0
def register(request):
    context = {}
    template = 'contest/register.html'
    context['form'] = RegistrationForm()
    if request.method == 'POST':
        form = RegistrationForm(request.POST)
        if form.is_valid():
            uname = form['username'].value()
            pwd = form['password'].value()
            p = Profile()
            p.username = uname
            p.set_password(pwd)
            p.save()
            context['successful_registration'] = uname
        else:
            context['form'] = form
    return render(request, template, context)
Example #5
0
	def handle(sself, *args, **options):
		for i in range(10):
			try:
				user = User.objects.get(username='******'+str(i))
			except User.DoesNotExist:
				user = User.objects.create_user(username='******' + str(i), password='******' + str(i + 1))
				user.is_superuser=False
				user.is_staff=False
				user.save()

		for i in range(10):
			try:
				profile = Profile.objects.get(user=User.objects.get(username='******' + str(i)))
			except Profile.DoesNotExist:
				profile = Profile(user=User.objects.get(username='******' + str(i)), rating=i, birthday=date(2005 + i, i + 1, (i + 1) * 2))
				profile.save()

		tags = ['django', 'python', 'shell', 'user', 'android', 'net', 'c', 'java', 'web', 'html']
		for i in tags:
			try:
				tag = Tag.objects.get(title=i)
			except Tag.DoesNotExist:	
				tag = Tag(title=i)
				tag.save()

		for i in range(10):
			try:
				q = Question.objects.get(title="Cannot to set datetime with input field. Always return DateTime.MinValue" + str(i), 
				text= str(i) + "My programm are supposed to have date filtr and gives article with proper date. But when i input any date in my datetime field my values don't change and are always DateTime.MinValue. Idk why and how i can fix it.",
				is_published=True,
				author=Profile.objects.get(id=i + 1),
				)
			except Question.DoesNotExist:
				q = Question(title="Cannot to set datetime with input field. Always return DateTime.MinValue" + str(i), 
					text=str(i) +"My programm are supposed to have date filtr and gives article with proper date. But when i input any date in my datetime field my values don't change and are always DateTime.MinValue. Idk why and how i can fix it.",
					date_published = datetime.now(),
					is_published=True,
					rating=i,
					author=Profile.objects.get(id=i + 1),
					#likes=likes.set(Profile.objects.get(id=(i + 2)//2)),
					#tags=Tag.objects.get(id=i+1)
					)
				#q.likes.set(Profile.objects.get(id=(i + 2)//2))
				#q.tags.set(Tag.objects.get(id=i+1))
				q.save()
				q.likes.add(Profile.objects.get(id=(i + 2)//2))
				q.tags.add(Tag.objects.get(id=i+1))

		for i in range(10):
			try:
				ans = Answer.objects.get(text="Nice question!",
				added_at = date(2019, i + 1, (i + 1) * 2),
				question=Question.objects.get(id=i + 1),
				author=Profile.objects.get(id=(i + 2)//2),
				)
			except Answer.DoesNotExist:
				ans = Answer(text="Nice question!",
					added_at = date(2019, i + 1, (i + 1) * 2),
					question=Question.objects.get(id=i + 1),
					author=Profile.objects.get(id=(i + 2)//2),
					)
				ans.save()

		for i in range(10):
			try:
				ans = Answer.objects.get(text="I don't know!",
				added_at = date(2019, i + 2, i + 3),
				question=Question.objects.get(id=(i+2)//2),
				author=Profile.objects.get(id=(i+3)//2),
				)
			except Answer.DoesNotExist:
				ans = Answer(text="I don't know!",
					added_at = date(2019, i + 2, i + 3),
					question=Question.objects.get(id=(i+2)//2),
					author=Profile.objects.get(id=(i+3)//2),
					)
				ans.save()
Example #6
0
def add():
    p = Profile()
    p.username = input('Username:'******'Password:'))
    p.save()