diff options
author | akhilbatra898 <akhil.batra@research.iiit.ac.in> | 2017-07-15 09:44:23 +0530 |
---|---|---|
committer | akhilbatra898 <akhil.batra@research.iiit.ac.in> | 2017-07-15 09:57:26 +0530 |
commit | 0fd661ea6bae299b69e65f90966304012eb794d2 (patch) | |
tree | 73bcd903e77fc656863b5241df39f028f8e528f5 /qtip/web/bench | |
parent | 2e4a3dfc8b45ae6dc72aa85510ce920dbafe54ad (diff) |
Add Authentication and Basic CRUD for Repos
- Map urls to the CRUD views
- Add html templates for the views
- Set authentication settings
Change-Id: Ifcfe39a8341d44376e322d195e995fcaa1716d7d
Signed-off-by: akhilbatra898 <akhil.batra@research.iiit.ac.in>
Diffstat (limited to 'qtip/web/bench')
-rw-r--r-- | qtip/web/bench/migrations/0004_auto_20170715_0325.py | 20 | ||||
-rw-r--r-- | qtip/web/bench/models.py | 4 | ||||
-rw-r--r-- | qtip/web/bench/urls.py | 21 | ||||
-rw-r--r-- | qtip/web/bench/views.py | 35 |
4 files changed, 80 insertions, 0 deletions
diff --git a/qtip/web/bench/migrations/0004_auto_20170715_0325.py b/qtip/web/bench/migrations/0004_auto_20170715_0325.py new file mode 100644 index 00000000..74296cce --- /dev/null +++ b/qtip/web/bench/migrations/0004_auto_20170715_0325.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.3 on 2017-07-15 03:25 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('bench', '0003_auto_20170713_0225'), + ] + + operations = [ + migrations.AlterField( + model_name='repo', + name='name', + field=models.CharField(max_length=200), + ), + ] diff --git a/qtip/web/bench/models.py b/qtip/web/bench/models.py index 0594dbd9..863af739 100644 --- a/qtip/web/bench/models.py +++ b/qtip/web/bench/models.py @@ -11,6 +11,7 @@ from __future__ import unicode_literals from django.db import models +from django.urls import reverse # Create your models here. @@ -19,6 +20,9 @@ class Repo(models.Model): name = models.CharField(max_length=200, blank=False) github_link = models.URLField(unique=True) + def get_absolute_url(self): + return reverse('repo_update', args=[self.pk]) + class Task(models.Model): start_time = models.DateTimeField(auto_now_add=True) diff --git a/qtip/web/bench/urls.py b/qtip/web/bench/urls.py new file mode 100644 index 00000000..3af4eb83 --- /dev/null +++ b/qtip/web/bench/urls.py @@ -0,0 +1,21 @@ +############################################################################## +# Copyright (c) 2017 akhil.batra@research.iiit.ac.in and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.conf.urls import include, url + +import views + +urlpatterns = [ + url('^', include('django.contrib.auth.urls')), + url('^repos/$', views.ReposView.as_view(), name='repos'), + url('^repos/(?P<pk>\d+)$', views.RepoUpdate.as_view(), name='repo_update'), +] diff --git a/qtip/web/bench/views.py b/qtip/web/bench/views.py index da5c56c3..786b67d5 100644 --- a/qtip/web/bench/views.py +++ b/qtip/web/bench/views.py @@ -1,6 +1,41 @@ +############################################################################## +# Copyright (c) 2017 akhil.batra@research.iiit.ac.in and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + # -*- coding: utf-8 -*- from __future__ import unicode_literals +from django.contrib.auth.mixins import LoginRequiredMixin +# from django.utils.decorators import method_decorator +from django.views.generic.edit import CreateView, UpdateView + +import models + # from django.shortcuts import render # Create your views here. + + +class ReposView(LoginRequiredMixin, CreateView): + model = models.Repo + fields = '__all__' + + def get_context_data(self, **kwargs): + context = super(ReposView, self).get_context_data(**kwargs) + context["repos"] = self.model.objects.all() + return context + + +class RepoUpdate(LoginRequiredMixin, UpdateView): + model = models.Repo + fields = '__all__' + + def get_context_data(self, **kwargs): + context = super(RepoUpdate, self).get_context_data(**kwargs) + context["repos"] = self.model.objects.all() + return context |