diff --git a/bdagro/models.py b/bdagro/models.py index 4167352..cb5a508 100644 --- a/bdagro/models.py +++ b/bdagro/models.py @@ -1,3 +1,49 @@ from django.db import models +from django.db.models.deletion import CASCADE +import uuid + +class Project(models.Model): + + title = models.CharField(max_length=200) + description = models.TextField(null=True, blank=True) + + demo_link = models.CharField(max_length=2000, null=True, blank=True) + source_link = models.CharField(max_length=2000, null=True, blank=True) + tags = models.ManyToManyField('Tag', blank=True) + vote_total = models.IntegerField(default=0, null=True, blank=True) + vote_ratio = models.IntegerField(default=0, null=True, blank=True) + created = models.DateTimeField(auto_now_add=True) + id = models.UUIDField(default=uuid.uuid4, unique=True, + primary_key=True, editable=False) + + def __str__(self): + return self.title + + +class Review(models.Model): + VOTE_TYPE = ( + ('up', 'Up Vote'), + ('down', 'Down Vote'), + ) + project = models.ForeignKey(Project, on_delete=models.CASCADE) + body = models.TextField(null=True, blank=True) + value = models.CharField(max_length=200, choices=VOTE_TYPE) + created = models.DateTimeField(auto_now_add=True) + id = models.UUIDField(default=uuid.uuid4, unique=True, + primary_key=True, editable=False) + + + def __str__(self): + return self.value + + +class Tag(models.Model): + name = models.CharField(max_length=200) + created = models.DateTimeField(auto_now_add=True) + id = models.UUIDField(default=uuid.uuid4, unique=True, + primary_key=True, editable=False) + + def __str__(self): + return self.name diff --git a/bdagro/templates/main.html b/bdagro/templates/main.html new file mode 100644 index 0000000..f216741 --- /dev/null +++ b/bdagro/templates/main.html @@ -0,0 +1,21 @@ + + +
+ + + +Footer
+ + + + diff --git a/bdagro/templates/navbar.html b/bdagro/templates/navbar.html new file mode 100644 index 0000000..8ee11cf --- /dev/null +++ b/bdagro/templates/navbar.html @@ -0,0 +1,2 @@ +ID | +Project | +Positive Votes | +Votes | + +||
---|---|---|---|---|---|
{{project.id}} | +{{project.title}} | +{{project.vote_total}} | +{{project.vote_ratio}}% | +{{project.created}} | +View | +
{{project.description}}
+ +{% endblock %} \ No newline at end of file diff --git a/bdagro/views.py b/bdagro/views.py index cfe8761..0245622 100644 --- a/bdagro/views.py +++ b/bdagro/views.py @@ -1,4 +1,5 @@ from django.shortcuts import render +from bdagro.models import Project from user.decorators import unauthenticated_user @@ -6,3 +7,15 @@ @unauthenticated_user def home(request): return render(request,"home.html") + + +def projects(request): + projects=Project.objects.all() + context={'projects': projects } + return render(request, 'projects/projects.html', context) + + + +def project(request,pk): + projectObj=Project.objects.get(id=pk) + return render( request, 'projects/single-project.html',{'project': projectObj}) \ No newline at end of file diff --git a/db.sqlite3 b/db.sqlite3 index 67d8ae3..43f8b02 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ