diff --git a/members/migrations/0004_auto_20160915_1606.py b/members/migrations/0004_auto_20160915_1606.py new file mode 100644 index 0000000..b73c764 --- /dev/null +++ b/members/migrations/0004_auto_20160915_1606.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9 on 2016-09-15 16:06 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.utils.timezone + + +class Migration(migrations.Migration): + + dependencies = [ + ('members', '0003_memberrequest'), + ] + + operations = [ + migrations.RemoveField( + model_name='memberrequest', + name='submitted', + ), + migrations.AddField( + model_name='member', + name='created', + field=models.DateTimeField(default=django.utils.timezone.now), + ), + ] diff --git a/members/models.py b/members/models.py index 97398e0..75496fd 100644 --- a/members/models.py +++ b/members/models.py @@ -14,17 +14,19 @@ class Member(models.Model): POR = models.CharField(max_length=255) # place of residence AYY = models.BooleanField(default=False) jas = models.BooleanField(default=False) - + created = models.DateTimeField(default=timezone.now) + def get_dict(self): - return { - 'id':self.id, - 'first_name':self.first_name, - 'last_name':self.last_name, - 'email':self.email, - 'POR':self.POR, - 'AYY':self.AYY, - 'jas':self.jas, - } + return { + 'id':self.id, + 'first_name':self.first_name, + 'last_name':self.last_name, + 'email':self.email, + 'POR':self.POR, + 'AYY':self.AYY, + 'jas':self.jas, + 'created':self.created.isoformat(' '), + } @classmethod def create_from_dict(cls,d): @@ -77,11 +79,9 @@ class Member(models.Model): class MemberRequest(models.Model): member = models.ForeignKey(Member) - submitted = models.DateTimeField(default=timezone.now) def get_dict(self): return { 'id': self.id, 'member': self.member.get_dict(), - 'submitted': self.submitted.isoformat(" ") } diff --git a/members/static/html/jasenhakemukset.html b/members/static/html/jasenhakemukset.html index 71d61a4..c61cf02 100644 --- a/members/static/html/jasenhakemukset.html +++ b/members/static/html/jasenhakemukset.html @@ -17,7 +17,7 @@
Asuinpaikka: {{ x.member.POR }}
-
Lähetetty: {{ x.submitted }}
+
Lisätty: {{ x.member.created }}
diff --git a/members/static/html/jasenlista.html b/members/static/html/jasenlista.html index ccca7d5..b83549c 100644 --- a/members/static/html/jasenlista.html +++ b/members/static/html/jasenlista.html @@ -9,6 +9,7 @@ AYY-jäsen JAS-listalla Asuinpaikka + Lisätty @@ -19,6 +20,7 @@ {{ x.AYY }} {{ x.jas }} {{ x.POR }} + {{ x.created }} Muokkaa diff --git a/members/static/html/lisaa_jasen.html b/members/static/html/lisaa_jasen.html index b6f1ba1..4de1ed8 100644 --- a/members/static/html/lisaa_jasen.html +++ b/members/static/html/lisaa_jasen.html @@ -4,27 +4,27 @@
- +
- +
- +
- +
- +
- +
diff --git a/members/static/js/application_controllers.js b/members/static/js/application_controllers.js index ed0f7f2..9dd4655 100644 --- a/members/static/js/application_controllers.js +++ b/members/static/js/application_controllers.js @@ -27,18 +27,11 @@ var notySuccess = notyfication('success',2500); //controllers app.controller("applicationController", function($scope, $http, $location, $window) { - $scope.firstName = ""; - $scope.lastName = ""; - $scope.email = ""; - //$scope.year = "1"; - $scope.AYY = ""; - $scope.JAS = ""; - $scope.POR = ""; + $scope.member = {}; $scope.send = function() { - $http.post("/members/api/request", {"first_name":$scope.firstName, "last_name":$scope.lastName, "email":$scope.email, /*"year":$scope.year,*/ "AYY":$scope.AYY, "jas":$scope.JAS, "POR":$scope.POR}).then(function(data){ + $http.post("/members/api/request", $scope.member).then(function(data){ notySuccess("Hakemus lähetetty!"); $window.location.href = "/application/"; - //$route.reload(); }); } }); \ No newline at end of file diff --git a/members/static/js/members_controllers.js b/members/static/js/members_controllers.js index 341516b..4e09385 100644 --- a/members/static/js/members_controllers.js +++ b/members/static/js/members_controllers.js @@ -93,14 +93,9 @@ app.controller("getController", function($scope, $http, $window, $location){ }); app.controller("postController", function($scope, $http, $location) { - $scope.firstName = ""; - $scope.lastName = ""; - $scope.email = ""; - $scope.AYY = ""; - $scope.JAS = ""; - $scope.POR = ""; + $scope.member = {}; $scope.send = function() { - $http.post("/members/api/member/", {"first_name":$scope.firstName, "last_name":$scope.lastName, "email":$scope.email, "AYY":$scope.AYY, "jas":$scope.JAS, "POR":$scope.POR}).then(function(data){ + $http.post("/members/api/member/", $scope.member).then(function(data){ notySuccess("Jäsen lisätty!"); $location.path("/list"); }); diff --git a/members/templates/application_index.html b/members/templates/application_index.html index f58f6cd..b72ae74 100644 --- a/members/templates/application_index.html +++ b/members/templates/application_index.html @@ -27,18 +27,18 @@
- +
- +
- +
-
-
- +
- +
- +