Commit 834b656a authored by Aedin Hunter A. Clay's avatar Aedin Hunter A. Clay

added forms and models for quest and questboard

parent e2f57ed9
from django import forms
from .models import Questboard, Quest
class QuestboardForm(forms.ModelForm):
class Meta:
model = Questboard
fields = ['name', 'description', 'required_stars']
class QuestForm(forms.ModelForm):
class Meta:
model = Quest
fields = ['name', 'description', 'stars', 'for_everyone', 'board_pk' ,'student1','student2', 'student3']
widgets = {'board_pk' : forms.HiddenInput(),
'student1' : forms.HiddenInput(),
'student2' : forms.HiddenInput(),
'student3' : forms.HiddenInput()}
\ No newline at end of file
from django.db import models
# Create your models here.
class Questboard(models.Model):
name = models.CharField(max_length = 50)
description = models.CharField(max_length = 300)
required_stars = models.IntegerField()
class Quest(models.Model):
board_pk = models.IntegerField(default = 0)
name = models.CharField(max_length = 60, default = '')
description = models.CharField(max_length = 300, default = '')
stars = models.IntegerField(default = 0)
for_everyone = models.BooleanField(default = False)
student1 = models.CharField(max_length = 60, default = '')
student2 = models.CharField(max_length = 60, default = '')
student3 = models.CharField(max_length = 60, default = '')
def is_for_everyone(self):
if self.students is not None:
return self.students.for_everyone
else:
return False
def is_students_full(self):
return self.student1 != '' and self.student2 != '' and self.student3 != ''
def is_students_empty(self):
return self.student1 == '' and self.student2 == '' and self.student3 == ''
def is_editable(self):
return self.for_everyone or self.is_students_empty()
from django.db import models
# Create your models here.
from django.shortcuts import redirect, render
from board.models import Questboard
form board.forms import QuestboardForm
def redirect_to_home(request):
return redirect('home/')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment