Skip to content

Commit

Permalink
Merge branch 'master' into widget
Browse files Browse the repository at this point in the history
  • Loading branch information
vidya-ram committed Jun 21, 2018
2 parents ddbd56b + a886b54 commit 6819dff
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 52 deletions.
3 changes: 2 additions & 1 deletion hasjob/forms/jobpost.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import baseframe.forms as forms
from baseframe.utils import is_public_email_domain
from coaster.utils import getbool, get_email_domain
from coaster.auth import current_auth
from flask_lastuser import LastuserResourceException

from ..models import User, JobType, JobApplication, PAY_TYPE, CURRENCY, Domain
Expand Down Expand Up @@ -381,7 +382,7 @@ class ApplicationForm(forms.Form):
def __init__(self, *args, **kwargs):
super(ApplicationForm, self).__init__(*args, **kwargs)
self.apply_email.choices = []
if g.user:
if current_auth:
self.apply_email.description = Markup(
_(u'Add new email addresses from <a href="{}" target="_blank">your profile</a>').format(
g.user.profile_url))
Expand Down
Binary file added hasjob/static/img/hasjob-logo-200x200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 8 additions & 8 deletions hasjob/templates/detail.html.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@
</div>
<div class="col-md-3">{% if not g.kiosk %}
<div class="list-group">
{%- if g.user %}
{%- if current_auth %}
{% if g.user.has_starred_post(post) %}
<a class="list-group-item pstar" href="#">
<i class="fa fa-fw fa-star" data-id="{{ post.hashid }}"></i>&nbsp;&nbsp;
<i class="fa fa-fw fa-star" data-id="{{ post.hashid }}"></i>&nbsp;&nbsp;
<span class="pstar-caption">Bookmarked</span>
</a>
{% else %}
<a class="list-group-item pstar" href="#">
<i class="fa fa-fw fa-star-o" data-id="{{ post.hashid }}"></i>&nbsp;&nbsp;
<i class="fa fa-fw fa-star-o" data-id="{{ post.hashid }}"></i>&nbsp;&nbsp;
<span class="pstar-caption">Bookmark this</span>
</a>
{%- endif %}
Expand Down Expand Up @@ -142,7 +142,7 @@
</a>
<div class="popup-box" id="report">
<a class="close-popup" href="#">&#10005;</a>
{%- if g.user %}
{%- if current_auth %}
<h2>What’s wrong with it?</h2>
{% include "inc/reportform.html.jinja2" %}
{%- else %}
Expand Down Expand Up @@ -196,7 +196,7 @@
</div>
</div>
{%- endif %}
{%- if is_siteadmin or (g.user and g.board and g.board.owner_is(g.user)) %}
{%- if is_siteadmin or (current_auth and g.board and g.board.owner_is(g.user)) %}
<div class="list-group-item">
<a class="popup" href="#makepinned">
<i class="fa fa-fw fa-thumb-tack"></i>&nbsp;&nbsp; Pin this
Expand All @@ -207,7 +207,7 @@
</div>
</div>
{%- endif %}
{%- if g.user and g.user.flags.has_boards %}
{%- if current_auth and g.user.flags.has_boards %}
<div class="list-group-item">
<a class="popup" href="#add-to-board">
<i class="fa fa-fw fa-plus"></i>&nbsp;&nbsp; Add to board
Expand Down Expand Up @@ -275,7 +275,7 @@
<p id="apply-info-para">
{%- if post.state.DRAFT %}{# Always show when in draft state #}
{{ post.how_to_apply|hideemail }}
{%- elif g.user %}
{%- elif current_auth %}
<a class="btn btn-primary" id="reveal-button" href="{{ post.url_for('reveal') }}">Show instructions</a> <span class="loading hidden"></span>
{%- else %}
<a class="btn btn-primary" href="{{ url_for('login') }}">Login with Google or GitHub</a>
Expand All @@ -285,7 +285,7 @@
</p>
{%- endif %}
</div>
{%- if not post.state.DRAFT and (g.user or g.kiosk) and applyform %}
{%- if not post.state.DRAFT and (current_auth or g.kiosk) and applyform %}
<div id="apply-section" class="section hidden">
</div>
{%- endif %}
Expand Down
20 changes: 12 additions & 8 deletions hasjob/templates/layout.html.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,24 @@
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en" {% block manifest %}{%- if g.kiosk %} manifest="{{ url_for('kiosk_manifest') }}" {%- endif %}{% endblock %}> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en" {{ self.manifest() }}> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en" {{ self.manifest() }}> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="en" class="no-js {%- if g.user %} userlogin {%- else %} no-userlogin {%- endif %}" {{ self.manifest() }}> <!--<![endif]-->
<!--[if gt IE 8]><!--> <html lang="en" class="no-js {%- if current_auth %} userlogin {%- else %} no-userlogin {%- endif %}" {{ self.manifest() }}> <!--<![endif]-->
{%- endblock -%}

{%- block titletags %}
<title>{% block title %}{{ title }}{% endblock %} | {% if g.board %}{{ g.board.title }}{% if g.board.not_root %} ({{ config['SITE_TITLE'] }}){% endif %}{% else %}{{ config['SITE_TITLE'] }}{% endif %}</title>
<meta name="DC.title" content="{{ self.title()|e }}" />
<meta property="og:title" content="{{ self.title()|e }}" />
<meta property="og:type" content="website">
{%- endblock %}

{%- block description %}{% if g.board and g.board.description %}{{ g.board.description|firstline }}{% else %}Hasjob is India’s best job board for tech startups{% endif %}{% endblock %}

{% block image_src -%}
<link rel="image_src" href="{{ url_for('static', filename='img/logo-star.png', _external=true) }}" />
<meta property="og:image" content="{{ url_for('static', filename='img/logo-star.png', _external=true) }}" />
<link rel="image_src" href="{{ url_for('static', filename='img/hasjob-logo-200x200.png', _external=true) }}" />
<meta property="og:image" content="{{ url_for('static', filename='img/hasjob-logo-200x200.png', _external=true) }}" />
<meta property="og:image:type" content="image/png" />
<meta property="og:image:width" content="200" />
<meta property="og:image:height" content="200" />
{%- endblock %}

{%- block layoutheaders %}
Expand Down Expand Up @@ -214,16 +218,16 @@
{% endmacro %}
{% if not g.kiosk %}
{% with site_links=[], user_links = [] %}
{%- if g.user and g.user.flags.is_candidate_alltime %}
{%- if current_auth and g.user.flags.is_candidate_alltime %}
{% set user_links = user_links + [{'title': "Applied jobs", 'url': url_for('applied')}] %}
{%- endif %}
{%- if g.user %}
{%- if current_auth %}
{% set user_links = user_links + [{'title': "Bookmarks", 'url': url_for('bookmarks')}] %}
{%- endif %}
{%- if g.user and g.user.flags.is_employer_alltime %}
{%- if current_auth and g.user.flags.is_employer_alltime %}
{% set user_links = user_links + [{'title': "My posts", 'url': url_for('my_posts')}] %}
{%- endif %}
{%- if g.user and g.user.flags.has_jobpost_unconfirmed_month %}
{%- if current_auth and g.user.flags.has_jobpost_unconfirmed_month %}
{% set user_links = user_links + [{'title': "Drafts", 'url': url_for('browse_drafts')}] %}
{%- endif %}
{%- if is_siteadmin %}
Expand Down Expand Up @@ -269,7 +273,7 @@
to find out when new jobs are posted. Hosted by
<a href="http://e2enetworks.com/">E2E Networks</a>.
{%- endif %}
{%- if not g.user and not g.anon_user %}
{%- if not current_auth and not g.anon_user %}
<img src="{{ url_for('sniffle') }}" width="1" height="1" alt=""/>
{%- endif %}
</p>
Expand Down
2 changes: 1 addition & 1 deletion hasjob/templates/postjob.html.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
{%- else %}
{#{{ renderfield(form.poster_name) }}-#} {# Deprecated 2013-11-20 -#}
{{ renderfield(form.poster_email) }}
{%- if g.user %}
{%- if current_auth %}
<p>
Only you, <strong>{{ g.user.fullname }}</strong>, will be able to respond to candidates.
To allow others to respond, add them as a collaborator.
Expand Down
2 changes: 1 addition & 1 deletion hasjob/templates/related_posts.html.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{%- if related_posts %}
{%- for post in related_posts -%}
<li class="col-xs-12 col-md-3 col-sm-4">
{{ stickie(post, post.url_for(), false, get_post_viewcounts, show_viewcounts=is_siteadmin or g.user and g.user.flags.is_employer_month, show_pay=is_siteadmin, starred=g.user and post.id in g.starred_ids) }}
{{ stickie(post, post.url_for(), false, get_post_viewcounts, show_viewcounts=is_siteadmin or current_auth and g.user.flags.is_employer_month, show_pay=is_siteadmin, starred=current_auth and post.id in g.starred_ids) }}
</li>
{%- endfor -%}
{%- endif %}
8 changes: 4 additions & 4 deletions hasjob/views/campaign.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def action_new(self, **kwargs):
@route('views.csv')
def view_counts(self, **kwargs):
campaign = self.obj
timezone = current_auth.actor.timezone if current_auth.is_authenticated else 'UTC'
timezone = current_auth.actor.timezone if current_auth else 'UTC'
viewdict = defaultdict(dict)

interval = chart_interval_for(campaign)
Expand Down Expand Up @@ -332,7 +332,7 @@ def csv(self, **kwargs):
def campaign_action_redirect(campaign, action):
if action.type != CAMPAIGN_ACTION.LINK:
abort(405)
if g.user:
if current_auth:
cua = CampaignUserAction.get(action, g.user)
if not cua:
cua = CampaignUserAction(action=action, user=g.user)
Expand Down Expand Up @@ -362,7 +362,7 @@ def campaign_action(campaign):

dismissed = 'dismiss' in request.form
if dismissed:
if g.user:
if current_auth:
view = campaign.view_for(g.user)
if view:
view.dismissed = True
Expand All @@ -382,7 +382,7 @@ def campaign_action(campaign):
campaign=campaign,
message=Markup("<p>Unknown action selected</p>"))
cua = None
if g.user:
if current_auth:
cua = CampaignUserAction.get(action, g.user)
if not cua:
cua = CampaignUserAction(action=action, user=g.user)
Expand Down
9 changes: 5 additions & 4 deletions hasjob/views/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from flask_rq import job
from flask_lastuser import signal_user_looked_up
from coaster.sqlalchemy import failsafe_add
from coaster.auth import current_auth
from baseframe import _, cache, get_timezone
from baseframe.signals import form_validation_error, form_validation_success

Expand Down Expand Up @@ -45,7 +46,7 @@ def index_is_paginated():

def has_post_stats(post):
is_siteadmin = lastuser.has_permission('siteadmin')
return is_siteadmin or post.admin_is(g.user) or (g.user and g.user.flags.get('is_employer_month'))
return is_siteadmin or post.admin_is(g.user) or (current_auth and g.user.flags.get('is_employer_month'))


@form_validation_success.connect
Expand Down Expand Up @@ -127,7 +128,7 @@ def load_user_data(user):
g.anon_user = anon_user

# Prepare event session if it's not already present
if g.user or g.anon_user and not g.esession:
if current_auth or g.anon_user and not g.esession:
g.esession = EventSession.get_session(uuid=session.get('es'), user=g.user, anon_user=g.anon_user)
if g.esession:
session['es'] = g.esession.uuid
Expand Down Expand Up @@ -253,7 +254,7 @@ def record_views_and_events(response):
if g.impressions:
g.event_data['impressions'] = g.impressions.values()

if g.user:
if current_auth:
for campaign in g.campaign_views:
if not CampaignView.exists(campaign, g.user):
db.session.begin_nested()
Expand All @@ -277,7 +278,7 @@ def record_views_and_events(response):
campaign_view_count_update.delay(campaign_id=campaign.id, anon_user_id=g.anon_user.id)

if g.esession: # Will be None for anon static requests
if g.user or g.anon_user:
if current_auth or g.anon_user:
ue = UserEvent.new_from_request(request)
else:
ue = UserEventBase.new_from_request(request)
Expand Down
17 changes: 9 additions & 8 deletions hasjob/views/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from sqlalchemy.exc import ProgrammingError
from flask import abort, redirect, render_template, request, Response, url_for, g, flash, jsonify, Markup
from coaster.auth import current_auth
from coaster.utils import getbool, parse_isoformat, for_tsquery
from coaster.views import render_with
from baseframe import _ # , dogpile
Expand Down Expand Up @@ -75,16 +76,16 @@ def json_index(data):
for pinned, post, is_bgroup in group:
rgroup['posts'].append(stickie_dict(
post=post, url=post.url_for(b=is_bgroup), pinned=pinned, is_bgroup=is_bgroup,
show_viewcounts=is_siteadmin or g.user and g.user.flags.get('is_employer_month'),
show_pay=is_siteadmin, starred=g.user and post.id in g.starred_ids
show_viewcounts=is_siteadmin or current_auth and g.user.flags.get('is_employer_month'),
show_pay=is_siteadmin, starred=current_auth and post.id in g.starred_ids
))
result['grouped'].append(rgroup)
if pinsandposts:
for pinned, post, is_bgroup in pinsandposts:
result['posts'].append(stickie_dict(
post=post, url=post.url_for(b=is_bgroup), pinned=pinned, is_bgroup=is_bgroup,
show_viewcounts=is_siteadmin or g.user and g.user.flags.get('is_employer_month'),
show_pay=is_siteadmin, starred=g.user and post.id in g.starred_ids
show_viewcounts=is_siteadmin or current_auth and g.user.flags.get('is_employer_month'),
show_pay=is_siteadmin, starred=current_auth and post.id in g.starred_ids
))

return jsonify(result)
Expand Down Expand Up @@ -372,7 +373,7 @@ def index(basequery=None, filters={}, md5sum=None, tag=None, domain=None, locati
is_index = True
else:
is_index = False
if basequery is None and not (g.user or g.kiosk or (board and not board.require_login)):
if basequery is None and not (current_auth or g.kiosk or (board and not board.require_login)):
showall = False
batched = False

Expand Down Expand Up @@ -403,12 +404,12 @@ def index(basequery=None, filters={}, md5sum=None, tag=None, domain=None, locati
# For logging
g.event_data['filters'] = data['data_filters']

if g.user:
if current_auth:
g.starred_ids = set(g.user.starred_job_ids(agelimit if not ageless else None))
else:
g.starred_ids = set()

if is_siteadmin or (g.user and g.user.flags.get('is_employer_month')):
if is_siteadmin or (current_auth and g.user.flags.get('is_employer_month')):
load_viewcounts(data['posts'])
show_viewcounts = True
else:
Expand All @@ -434,7 +435,7 @@ def index(basequery=None, filters={}, md5sum=None, tag=None, domain=None, locati
# Test values for development:
# if not g.user_geonameids:
# g.user_geonameids = [1277333, 1277331, 1269750]
if not location and 'l' not in request.args and g.user_geonameids and (g.user or g.anon_user) and (
if not location and 'l' not in request.args and g.user_geonameids and (current_auth or g.anon_user) and (
(not g.board.auto_locations) if g.board else True):
# No location filters? Prompt the user
ldata = location_geodata(g.user_geonameids)
Expand Down
Loading

0 comments on commit 6819dff

Please sign in to comment.