בעיה בהוספת תוכנית discourse-subscriptions

סיכום מבוסס בינה מלאכותית

A user, pfaffman, reports an issue with adding a new plan in the discourse-subscriptions plugin on a development environment, encountering a TypeError related to discourse_subscriptions_currency. The error occurs when trying to access the currency setting, which is undefined in the route context. justin explains this is due to a recent switch to Ember CLI in developer instances and confirms a fix is coming with a PR. pfaffman notes that the issue also prevents new plans from appearing, and later identifies another problematic instance in s-show.js.es6. pfaffman also points out a potential issue with Discourse.User.current().username.toLowerCase() needing to be this.current_user.username.toLowerCase(). justin confirms the issue is resolved with the merged PR, referencing the fix in the discourse-subscriptions meta post.

I"m trying to create a new plan on my development environment. Clicking “add new plan” does this:

TypeError: Cannot read property 'discourse_subscriptions_currency' of undefined
    at Class.model (javascripts/discourse/routes/admin-plugins-discourse-subscriptions-products-show-plans-show:22)
    at Class.deserialize (route.js:1040)
    at UnresolvedRouteInfoByParam.getModel (router_js.js:895)
    at router_js.js:691
    at invokeCallback (rsvp.js:493)
    at publish (rsvp.js:476)
    at rsvp.js:19
    at invoke (backburner.js:338)
    at Queue.flush (backburner.js:229)
    at DeferredActionQueues.flush (backburner.js:426)

and also

Error while processing route: adminPlugins.discourse-subscriptions.products.show.plans.show Cannot read property 'discourse_subscriptions_currency' of undefined TypeError: Cannot read property 'discourse_subscriptions_currency' of undefined
    at Class.model (javascripts/discourse/routes/admin-plugins-discourse-subscriptions-products-show-plans-show:22:44)

I can’t tell if this is some issue with my setup or . . . something else. This works in the console started with the same ENV settings (of stripe keys and such):

> SiteSetting.discourse_subscriptions_currency
=> "USD"

I"m able to create and update products, but I’m not able to create a plan.

I think this is why:

https://github.com/discourse/discourse-subscriptions/pull/66

Ah yes! This is due to the switch to Ember CLI on developer instances – shouldn’t affect production sites for now.

I have a PR that should drop in the next couple of days that refactors this and adds a new feature, too.

Might this also make it impossible to see new plans? I’ve added plans but they aren’t showing up.

(I’m trying to add a hook to GroupUser that watches the group and then pulls the most-recent subscription ID and adds it to my plugin’s model…)

EDIT: Meanwhile, my PR just got accepted. . .

I blame @cvx :wink: I’ll make sure in my work that I sweep the codebase for more instances of the Discourse constant so we’re ready for the future.

Aha. Found the other place and that was what was making it not present plans for sale; I thought I was going crazy. There’s another instance in s-show.js.es6, but you’ll find it the same way I did.

Oh, and also a Discourse.User.current().username.toLowerCase(), which I guess should be this.current_user.username.toLowerCase()?

This should now be fixed with the merging of this:

https://meta.discourse.org/t/discourse-subscriptions/140818/355?u=justin