1

I need some advice / ideas if someone is inclined to help: I have a javascript interface for manipulating pictures. Basically it's about moving photos around. Once it's done the position of images is saved into a Django form and then saved to database with the owner saved as the current user. Now the trick is that I would like to be able to allow non registered users to play with this interface and then if they like the result they hit save and are redirected to an account registration page and only then the form is actually saved with their user as the owner.

What comes to my mind now is to keep the values of the form in session but I don't know what will happen to the session once the anonymous user registers and becomes another user. I was also thinking of using a 'next' parameter in the registration process with the url filled with get parameters that would be the content of the form but then I don't know if userena is ready to allow that. Any light on this is welcome.

4

3 回答 3

2

好吧,我们在我们的网站上做了类似的事情。当未注册的用户附加照片时,我们将对象保存到数据库并分配当用户以表单进入页面时生成的唯一哈希。当用户点击提交时,我们在 url 中传递此哈希,下一步,当用户想要注册时,我们只需通过此哈希从数据库中获取对象并将 user_id 分配给它们。

此外,我们还有一个 cron 作业,它会清理并删除所有丢失的对象

PS对不起我的英语我希望你能明白我的意思

于 2012-07-24T10:53:24.720 回答
1

在没有用户的情况下保存对象并将该对象的引用存储在会话(或(签名)cookie)中。如果用户注册,则使用新创建的用户更新所有对象。

于 2012-07-24T11:50:49.347 回答
1

另一种方法是将数据存储在浏览器中(html5 localstorage 和 fallbacks,或类似的),并且只有在用户注册后才将其插入数据库。您需要确保这两件事都发生在同一个浏览器“实例”中,但在服务器端事情会更容易。

于 2012-07-25T22:33:52.247 回答