Conversation
671c15a to
b355494
Compare
|
It's Autumn Cleaning time, so I'm closing this PR. Feel free to re-open when development becomes active again. |
|
Cool. When you're ready to do another push, go ahead and re-open it then. For now, we should still have access to it for what we need. We just had a lot of open PRs that I was asked to clean out. |
|
Ah, it was only 7 days since the last push. Okay, I'll re-open. From the way Github showed it, I thought it had been months. |
alexschiller
left a comment
There was a problem hiding this comment.
Notes:
100 in line comments, some redundant pointing out similar problems. Consider questions to be hypothetical and not requiring answers, but you should probably know the answer. Happy to discuss any comments further if anything unclear.
General punchlist of common suggestions
- Fix import orders in all files
- Fix importing of symbols-- import modules and call module.symbol instead
- Add empty blank line to the ends of files
- Use dictionary literals instead of manually adding via
dict[key] = value - Use single quotes instead of double quotes
- When possible, handle errors inside of functions instead of catching output when the function output fails
- Don't use general try-except Exceptions, make sure you are handling only the exceptions you expect
- Use triple equals in javascript
General
- Some refactoring of functions can occur to simplify things-- some functions were only used once and can easily be made a single line. In those cases it is more readable not to have to look up what that function does.
- The difference between a node, filenode, wikinode, project, parent all need to match how things are done in the OSF. Some of your relationships uses were different than I expected.
- The mithril and javascript sections would benefit from a refactor. The python was generally easy to read but the javascript was not always.
| @@ -0,0 +1,29 @@ | |||
| from website import settings | |||
There was a problem hiding this comment.
See these for import ordering, this applies to all imports you modified/added in all files.
https://www.python.org/dev/peps/pep-0008/#imports / http://cosdev.readthedocs.io/en/latest/style_guides/python.html#imports
| out_dict = {} | ||
| for k, v in in_dict.iteritems(): | ||
| if isinstance(v, unicode): | ||
| v = v.encode('utf8') |
There was a problem hiding this comment.
Encode/decode is generally written as 'utf-8' in the osf instead of just 'utf8'-- both work though.
| """Clear users' session(s) and log them out of OSF.""" | ||
|
|
||
| for key in ['auth_user_username', 'auth_user_id', 'auth_user_fullname', 'auth_user_access_token']: | ||
| for key in ['auth_user_username', 'auth_user_id', 'auth_user_fullname', |
There was a problem hiding this comment.
If you're going to split the line, each should probably go on its own line (see line 15 of same file)
| try: | ||
| discourse.logout() | ||
| except (discourse.DiscourseException, requests.exceptions.ConnectionError): | ||
| logger.exception('Error logging user out of Discourse') |
There was a problem hiding this comment.
Hypothetical questions that I don't need answers to:
- What happens if the user is not logged out of discourse but is logged out of the osf?
- What happens when they try to log back in?
- Should logout fail (I doubt we should force someone to remain logged in, but the fact that this error catch needs to exist does raise a few questions)?
| @@ -0,0 +1,7 @@ | |||
| import framework.discourse.common | |||
| # import here so they can all be imported through the module | |||
There was a problem hiding this comment.
It would be better if you pulled in discourse and simply called the function from where it actually lives. This is a lot of importing symbols when you should be keeping them name spaced better. There is a reason you had to noqa everything
e.g.,
from framework import discourse
discourse.project.sync_projects(...)| url: "${settings.DISCOURSE_SERVER_URL}/session/current.json", | ||
| xhrFields: { withCredentials: true }} | ||
| ).then(function(json) { | ||
| if (json.current_user && json.current_user.username == contextVars.currentUser.id) { |
|
|
||
| function discourseAutoLogin() { | ||
| if (contextVars.currentUser.id) { | ||
| if (typeof(Storage) !== "undefined" && sessionStorage.discourseLoggedIn == "true") { |
There was a problem hiding this comment.
use triple equals, single quotes
| } | ||
| }; | ||
|
|
||
| if (window.addEventListener) { |
There was a problem hiding this comment.
Is there a reason this cannot be run with the mithril controller is getting everything set up? I may be missing what it is supposed to be doing, but a lot of this looks like things that can be configured in the controller.
|
|
||
| <!-- Forum Feed (Latest Topics) --> | ||
| % if not node['anonymous']: | ||
| <div class="panel panel-default"> |
| % if not node['anonymous']: | ||
| <div class="panel panel-default"> | ||
| <div class="panel-heading clearfix"> | ||
| <h3 class="panel-title">Latest Forum Topics</h3> |
There was a problem hiding this comment.
bb37e0d to
8134590
Compare
…configure_discourse_server function was added as well, and may be used after the discourse settings are properly set in local settings.
…more data from the correct project and file nodes, and to add the discourse comment plugin to file pages, automatically making the correct groups, categories, and topics
…name. Ensured group sync test passes
…edded the discourse comments into the comments side panel
…rough them, in the db.
…o, and better topic creation.
…ted, moved, or renamed
…box or other files are renamed.
…ds a comment from the system to the topic
…d a minimum number of times. Fixed the SSO get method signature. Added automatic configuration of the welcome-to-discourse topic contents
…ttempt to use it triggers an additional try. gave it a 0.25s timeout, since it should be local
…dpoint on Discourse for creating projects and dealing with them only by project_guid. fixed tests to make sure they all pass. added some documentation.
…kis, deleting projects/components, and made auto discourse log-in smarter
…ment pane iframe height calculation.
|
I'm trying to install this on my local setup (finally!), and when I invoke the server I'm getting: I've invoked all the requirements that I could (using the -q flag). Is there anything that maybe isn't in a requirements file? |
|
@brianjgeiger Sorry about the delay in a response. I think this must be from some recent change to the develop branch of osf.io. I recently did a rebase, but haven't gone through running all the code again. I am a little reluctant to, because my environment has diverged substantially since I can't run docker in the specified way. (I don't have a recent-year mac). By and large, I aimed to use the same conventions as the OSF already was. That specific datetime field type is not important as long as it is consistent. |
|
This should definitely not try to be merged with develop. The branch itself should be, for the purposes of this review, its own island. If it's in a partway state, then I'm not going to be able to get it running. Can this be rolled back to a last-known working state? |
|
Well, NonNaiveDatetimeField is actually just a typo. It should be NonNaiveDateTimeField. |
|
@brianjgeiger I've fixed the typo and I can get it to run locally. However, the amount of testing I can do is limited right now since I'm having trouble being able to create an account on my new instance. I get the error: "Invalid Token This confirmation link is invalid." when trying to make a new account. |
|
Cool, thanks! I'll pull and give it a go again. |
Purpose
This PR is being made to link the ongoing Discourse Integration project code to the main OSF.
Changes
framework.discourse module for interaction. Discourse IDs and hooks added to project, file, and wiki node classes. Single-Sign-On for Discourse through the OSF. Completely different comment-pane. Forum-feed Mithril component. See the README.md file in framework/discourse for more.
Example screenshots:

Side effects
Replacing of standard comments with Discourse. Comments will work differently. The APIv2 comment functionality would be broken.