Conversation
|
Implementation for #290. |
|
The migration hasn't been included in the PR. |
|
Added migration script. |
hasjob/views/listing.py
Outdated
| % post.email_domain, category='info') | ||
| return redirect(url_for('index')) | ||
| post.confirm() | ||
| post.tweetid = retweet(post) |
There was a problem hiding this comment.
This needs to be inside if app.config['TWITTER_ENABLED']:
hasjob/twitter.py
Outdated
| def retweet(post): | ||
| # Need to add the By-line like A job by Company has been posted on hasjob, check it out + post.headline | ||
| tweet_id = tweet(post.headline, post.url_for(_external=True)) | ||
| return tweet_id |
There was a problem hiding this comment.
Use this instead:
def tweet_post(post_id):
post = JobPost.query.get(post_id)
if post.headlineb:
post.tweetid = tweet(post.headline, post.url_for(b=0, _external=True),
post.location, dict(post.parsed_location or {}), username=post.twitter)
tweet(post.headlineb, post.url_for(b=1, _external=True),
post.location, dict(post.parsed_location or {}), username=post.twitter)
else:
post.tweetid = tweet(post.headline, post.url_for(_external=True),
post.location, dict(post.parsed_location or {}), username=post.twitter)
db.session.commit()
hasjob/views/listing.py
Outdated
| post.tweetid = retweet(post) | ||
| db.session.commit() | ||
| if app.config['TWITTER_ENABLED']: | ||
| if post.headlineb: |
There was a problem hiding this comment.
Replace this if block entirely with tweet_post.delay(post.id)
|
Hi @jace, Have made all the changes according to your review. However tweet_post.delay(post.id)Doesn't seem to be working. Please check it out and let me know if I'm missing anything. |
|
@sam95 you need to install and use RQ for the |
|
Hi @iambibhas, I tried the above. But didn't work. Let me know if there is an alternative or if it works for you. |
|
@iambibhas can we see this through? @sam95 we'll need a CLA or copyright assignment from you. Since you're our first external contributor after switching to AGPLv3, we'll need to figure out how to do this. I'll get back on this. https://producingoss.com/en/copyright-assignment.html |
|
@jace sure, Let me know more about the CLA. |
|
@sam95 there is tiny issue in the rq job. you need to specify these 4 settings in your You can apply for a dev account on dev.twitter.com and then set these and then try to post a job on your local setup and that should trigger the |
|
While you wait for the twitter sign up bit, put some random value in those key/secret for now and try posting job, that way you'll only face error once you hit twitter. |
|
@iambibhas I tried adding those onto the |
|
Getting this error in the 14:00:53 hasjob: hasjob.twitter.tweet_post(17) (80c0e42a-9ead-4101-a0e7-2907032d3f25)
in tweet post
14:00:53 RuntimeError: Attempted to generate a URL without the application context being pushed. This has to be executed when application context is available.
Traceback (most recent call last):
File "/Users/sameerasy/hasgeek/.venv/lib/python2.7/site-packages/rq/worker.py", line 793, in perform_job
rv = job.perform()
File "/Users/sameerasy/hasgeek/.venv/lib/python2.7/site-packages/rq/job.py", line 599, in perform
self._result = self._execute()
File "/Users/sameerasy/hasgeek/.venv/lib/python2.7/site-packages/rq/job.py", line 605, in _execute
return self.func(*self.args, **self.kwargs)
File "./hasjob/twitter.py", line 24, in tweet_post
post.tweetid = tweet(post.headline, post.url_for(_external=True),
File "./hasjob/models/jobpost.py", line 305, in url_for
return url_for('jobdetail', hashid=self.hashid, domain=domain, _external=_external, **kwargs)
File "/Users/sameerasy/hasgeek/.venv/lib/python2.7/site-packages/Flask-1.0.2-py2.7.egg/flask/helpers.py", line 294, in url_for
'Attempted to generate a URL without the application context being'
RuntimeError: Attempted to generate a URL without the application context being pushed. This has to be executed when application context is available.
Traceback (most recent call last):
File "/Users/sameerasy/hasgeek/.venv/lib/python2.7/site-packages/rq/worker.py", line 793, in perform_job
rv = job.perform()
File "/Users/sameerasy/hasgeek/.venv/lib/python2.7/site-packages/rq/job.py", line 599, in perform
self._result = self._execute()
File "/Users/sameerasy/hasgeek/.venv/lib/python2.7/site-packages/rq/job.py", line 605, in _execute
return self.func(*self.args, **self.kwargs)
File "./hasjob/twitter.py", line 24, in tweet_post
post.tweetid = tweet(post.headline, post.url_for(_external=True),
File "./hasjob/models/jobpost.py", line 305, in url_for
return url_for('jobdetail', hashid=self.hashid, domain=domain, _external=_external, **kwargs)
File "/Users/sameerasy/hasgeek/.venv/lib/python2.7/site-packages/Flask-1.0.2-py2.7.egg/flask/helpers.py", line 294, in url_for
'Attempted to generate a URL without the application context being'
RuntimeError: Attempted to generate a URL without the application context being pushed. This has to be executed when application context is available.
Attachments area |
|
@sam95 this is because of the use of If you find a way to move that |
|
|

Basic flow for retweet feature