Skip to content

Commit

Permalink
Fixing issues with profile loading values
Browse files Browse the repository at this point in the history
  • Loading branch information
fism88 committed May 3, 2012
1 parent be0256e commit 882b244
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/controllers/Profiles.java
Expand Up @@ -47,6 +47,7 @@ public static void updateInformation(String birthday, String relationshipStatus,
} catch (java.text.ParseException e) {
Logger.error("Birthday should be in format: MM/dd/yyyy", e);
}
validation.match(birthday, ("\\^\\(0\\[1-9\\]\\|1\\[012\\]\\)\\[- /.\\]\\(0\\[1-9\\]\\|\\[12\\]\\[0-9\\]\\|3\\[01\\]\\)\\[- /.\\]\\(19\\|20\\)\\d\\d$"));
}

profile.gender = gender;
Expand Down
3 changes: 3 additions & 0 deletions app/models/Profile.java
Expand Up @@ -37,6 +37,8 @@ public class Profile extends Model {
@OneToOne
public Photo gravatarPhoto;

@Match("\\^\\(0\\[1-9\\]\\|1\\[012\\]\\)\\[- /.\\]\\(0\\[1-9\\]\\|\\[12\\]\\[0-9\\]\\|3\\[01\\]\\)\\[- /.\\]\\(19\\|20\\)\\d\\d$")

public Date birthday; // The user's birthday, uses JQuery UI

@ManyToOne
Expand Down Expand Up @@ -149,5 +151,6 @@ public Profile(User owner, String bio, String gender, String quotes, String phon
this.phone = phone;
this.quotes = quotes;
this.website = website;
this.profilePhoto = Photo.findById(Bootstrap.defaultProfilePhotoID);
}
}
6 changes: 5 additions & 1 deletion app/models/User.java
Expand Up @@ -15,6 +15,7 @@
import play.modules.elasticsearch.annotations.ElasticSearchable;
import play.modules.elasticsearch.search.SearchResults;
import play.libs.Crypto;
import utils.Bootstrap;

@ElasticSearchable
@Entity
Expand Down Expand Up @@ -53,7 +54,7 @@ public class User extends Postable {
public String password;

// User's basic profile information
@OneToOne
@OneToOne(mappedBy="owner")
public Profile profile;

@OneToOne
Expand Down Expand Up @@ -197,6 +198,9 @@ public Profile getProfile(){
profile = new Profile(this);
profile.save();
}
if (profile.profilePhoto == null) {
profile.profilePhoto = Photo.findById(Bootstrap.defaultProfilePhotoID);
}
return profile;
}

Expand Down
5 changes: 4 additions & 1 deletion app/views/Users/profile.html
Expand Up @@ -146,7 +146,7 @@
#{if !profile.interestedIn}
<tr>
<td><label><b>Interested in:</b></label></td>
<td class="data">${profile.interestedIn}</td>
<td class="data">${profile.gender} >> test123${profile.interestedIn}</td>
</tr>
#{/if}
#{if profile.relationshipStatus}
Expand Down Expand Up @@ -229,6 +229,9 @@
#{/else}
</tr>
#{/if}
#{else}

#{/else}
#{if profile.address}
<tr>
<td><label><b>Address: </b></label></td>
Expand Down

0 comments on commit 882b244

Please sign in to comment.