Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Save remaining time on unsubscribe

  • Loading branch information...
commit 78c8cdcd01ce3800874c67e39bb2736d4df578ed 1 parent b84945f
@mjibson authored
View
1  charge.go
@@ -215,6 +215,7 @@ func doUncheckout(c mpg.Context) (*UserCharge, error) {
return err
}
u.Account = AFree
+ u.Until = uc.Next
if err := gn.Delete(gn.Key(&uc)); err != nil {
return err
}
View
1  static/js/site.js
@@ -142,6 +142,7 @@ goReadAppModule.controller('GoreadCtrl', function($scope, $http, $timeout, $wind
return;
}
$scope.unreadDate = data.UnreadDate;
+ $scope.untilDays = data.UntilDate ? moment.unix(data.UntilDate).diff(moment(), 'days') : 0;
$scope.feeds = data.Opml || $scope.feeds;
_.each(data.Feeds, function(e) {
if(e.Image) {
View
5 templates/base.html
@@ -524,9 +524,10 @@
<li class="all-subs" ng-show="loading">loading...</li>
</ul>
{{if .StripeKey}}
- <ul class="list-unstyled" ng-hide="accountType || trialRemaining == undefined">
+ <ul class="list-unstyled" ng-show="accountType == 0">
<li><button class="btn btn-success" ng-click="getAccount()">upgrade</button></li>
- <li>{{`{{trialRemaining}}`}} days remaining of free trial</li>
+ <li ng-show="trialRemaining > 0">{{`{{trialRemaining}}`}} days remaining of free trial</li>
+ <li ng-show="untilDays > 0">{{`{{untilDays}}`}} days remaining of subscription</li>
</ul>
{{end}}
<ul class="list-unstyled" ui-sortable="sortableOptions" ng-model="feeds">
View
7 types.go
@@ -37,10 +37,11 @@ type User struct {
Id string `datastore:"-" goon:"id"`
Email string `datastore:"e"`
Messages []string `datastore:"m,noindex"`
- Read time.Time `datastore:"r,noindex"`
+ Read time.Time `datastore:"r"`
Options string `datastore:"o,noindex"`
- Account int `datastore:"a,noindex"`
- Created time.Time `datastore:"d,noindex"`
+ Account int `datastore:"a"`
+ Created time.Time `datastore:"d"`
+ Until time.Time `datastore:"u"`
}
const (
View
4 user.go
@@ -197,7 +197,7 @@ func ListFeeds(c mpg.Context, w http.ResponseWriter, r *http.Request) {
l.Text += ", u.Read"
}
trialRemaining := 0
- if STRIPE_KEY != "" && ud.Opml != nil && u.Account == AFree {
+ if STRIPE_KEY != "" && ud.Opml != nil && u.Account == AFree && u.Until.Before(time.Now()) {
if u.Created.IsZero() {
u.Created = time.Now()
putU = true
@@ -440,6 +440,7 @@ func ListFeeds(c mpg.Context, w http.ResponseWriter, r *http.Request) {
Feeds []*Feed
Stars []string
UnreadDate time.Time
+ UntilDate int64
}{
Opml: uf.Outline,
Stories: fl,
@@ -448,6 +449,7 @@ func ListFeeds(c mpg.Context, w http.ResponseWriter, r *http.Request) {
Feeds: feeds,
Stars: stars,
UnreadDate: u.Read,
+ UntilDate: u.Until.Unix(),
}
b, err := json.Marshal(o)
if err != nil {
Please sign in to comment.
Something went wrong with that request. Please try again.