Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
finish user edit, only birthday left
Browse files Browse the repository at this point in the history
  • Loading branch information
vasupol11 committed Nov 30, 2015
1 parent d07f8e2 commit 78f2a7f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
2 changes: 1 addition & 1 deletion User/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# Create your models here.1
class UserProfile(models.Model):
user = models.OneToOneField(User, related_name='profile')
firstname = models.CharField(max_length=30, null=True)
firstname = models.CharField(max_length=30, null=True, blank=True)
lastname = models.CharField(max_length=30, null=True)
birthday = models.DateField(blank=True, null=True)
gender = models.CharField(max_length=5, choices=GENDER, null=True)
Expand Down
3 changes: 2 additions & 1 deletion ui/static/app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ app.config(function($stateProvider, $urlRouterProvider) {
})
.state('root.user.edit', {
url: '/edit',
templateUrl: 'templates/useredit.html'
templateUrl: 'templates/useredit.html',
controller: 'EditUserController'
})
.state('root.event', {
url: '/events/{event:int}',
Expand Down
14 changes: 14 additions & 0 deletions ui/static/app/userprofile.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@ app.controller('UserProfileInfoController', function($scope, $http, $location, $

});

app.controller('EditUserController', function($scope, $http, $window){

var userId;
$http.get('/api/auth/check').success(function(data){
userId = data.id
});

$scope.saveInfo = function(){
$http.put('/api/user/'+userId+'/userInfo/',$scope.userprofile).success(function(data){
$window.location.reload();
});
}
});

app.controller('UserFriendController', function($scope, $http, $location, $stateParams){
var userID = $stateParams.user;
$http.get('/api/user/friends/' + userID).success(function(data){
Expand Down
18 changes: 9 additions & 9 deletions ui/static/templates/useredit.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,29 @@
<h3 class="panel-title">Edit profile</h3>
</div>
<div class="panel-body">
<form action="" class="form form-horizontal">
<form action="" class="form form-horizontal" ng-submit="saveInfo()">
<div class="form-group">
<label for="firstname" class="col-sm-3 control-label">First Name</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="firstname" required>
<input type="text" class="form-control" id="firstname" required ng-model = "userprofile.firstname">
</div>
</div>
<div class="form-group">
<label for="lastname" class="col-sm-3 control-label">Last Name</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="lastname" required>
<input type="text" class="form-control" id="lastname" required ng-model = "userprofile.lastname">
</div>
</div>
<div class="form-group">
<label for="birthday" class="col-sm-3 control-label">Birthday</label>
<div class="col-sm-9">
<input type="date" class="form-control" id="birthday">
<input type="date" class="form-control" id="birthday" ng-model = "userprofile.birthday" disabled>
</div>
</div>
<div class="form-group">
<label for="gender" class="col-sm-3 control-label">Gender</label>
<div class="col-sm-9">
<select class="form-control" name="gender">
<select class="form-control" name="gender" ng-model = "userprofile.gender">
<option value selected>--------</option>
<option value="M">Male</option>
<option value="F">Female</option>
Expand All @@ -35,25 +35,25 @@ <h3 class="panel-title">Edit profile</h3>
<div class="form-group">
<label for="faculty" class="col-sm-3 control-label">Faculty</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="faculty">
<input type="text" class="form-control" id="faculty" ng-model = "userprofile.faculty">
</div>
</div>
<div class="form-group">
<label for="major" class="col-sm-3 control-label">Major</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="major">
<input type="text" class="form-control" id="major" ng-model = "userprofile.major">
</div>
</div>
<div class="form-group">
<label for="country" class="col-sm-3 control-label">Country</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="country">
<input type="text" class="form-control" id="country" ng-model = "userprofile.country">
</div>
</div>
<div class="form-group">
<label for="city" class="col-sm-3 control-label">City</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="city">
<input type="text" class="form-control" id="city" ng-model = "userprofile.city">
</div>
</div>
<div class="form-group">
Expand Down

0 comments on commit 78f2a7f

Please sign in to comment.