-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
community/: Add a form for uploading google forms
Not everyone, will be able to fill forms. Only the logged in users will be able to fill them and some of the forms, can only be filled by developers or contributors who are a part of more than one team. At every step, the check is performed whether the user is authenticated or not, to avoid false form submissions. Closes #265
- Loading branch information
Showing
7 changed files
with
306 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* globals Cookies */ | ||
$(document).ready(function () { | ||
|
||
var community_google_form_op = $('.community-google-form-op'); | ||
var newcomer_promotion_form_op = $('.newcomer-promotion-form-op'); | ||
var calendar_event_form_op = $('.calendar-event-form-op'); | ||
var get_issue_assigned_form_op = $('.get-issue-assigned-form-op'); | ||
var participated_in_gsoc_form_op = $('.participated-in-gsoc-form-op'); | ||
var mentor_students_form_op = $('.mentor-students-form-op'); | ||
|
||
var community_google_form = $('.community-google-form'); | ||
var newcomer_promotion_form = $('.newcomer-promotion-form'); | ||
var calendar_event_form = $('.calendar-event-form'); | ||
var get_issue_assigned_form = $('.get-issue-assigned-form'); | ||
var participated_in_gsoc_form = $('.participated-in-gsoc-form'); | ||
var mentor_students_form = $('.mentor-students-form'); | ||
|
||
var is_user_authenticated = Cookies.get('authenticated'); | ||
var authenticated_username = Cookies.get('username'); | ||
|
||
var username_input = $('[name=user]'); | ||
username_input.attr('value', authenticated_username || 'Anonymous User'); | ||
username_input.attr('disabled', true); | ||
|
||
$('form').attr( | ||
'action',window.location.pathname + | ||
'?form_submitted=True&form_type=community' | ||
); | ||
|
||
$.getJSON("/static/contributors-data.json", function (data) { | ||
var contributor_data = data[authenticated_username]; | ||
var teams = contributor_data.teams; | ||
if(teams.length === 1){ | ||
community_google_form_op.get(0).remove(); | ||
calendar_event_form_op.get(0).remove(); | ||
mentor_students_form_op.get(0).remove(); | ||
community_google_form.get(0).remove(); | ||
calendar_event_form.get(0).remove(); | ||
mentor_students_form.get(0).remove(); | ||
} | ||
}); | ||
|
||
function display_error_message(message){ | ||
if(message){ | ||
$('.important-message').text(message); | ||
} | ||
else { | ||
$('.important-message').text('You tried to open a form, which is ' + | ||
'available to only authenticated users. Please join the community' + | ||
' or Login(if already a member of organization)'); | ||
} | ||
$('.form-submission-popup').css('display', 'flex'); | ||
} | ||
|
||
function display_form_or_error(form_object){ | ||
if(is_user_authenticated && authenticated_username){ | ||
$('.community-form').css('display', 'flex'); | ||
form_object.css('display', 'block'); | ||
} | ||
else { | ||
display_error_message(); | ||
} | ||
} | ||
|
||
community_google_form_op.on('click', function () { | ||
display_form_or_error(community_google_form); | ||
}); | ||
|
||
newcomer_promotion_form_op.on('click', function () { | ||
display_form_or_error(newcomer_promotion_form); | ||
}); | ||
|
||
calendar_event_form_op.on('click', function () { | ||
display_form_or_error(calendar_event_form); | ||
}); | ||
|
||
get_issue_assigned_form_op.on('click', function () { | ||
display_form_or_error(get_issue_assigned_form); | ||
}); | ||
|
||
participated_in_gsoc_form_op.on('click', function () { | ||
display_form_or_error(participated_in_gsoc_form); | ||
}); | ||
|
||
mentor_students_form_op.on('click', function () { | ||
display_form_or_error(mentor_students_form); | ||
}); | ||
|
||
$(':input').focusin(function () { | ||
if (is_user_authenticated===undefined && | ||
authenticated_username===undefined) { | ||
$('.community-form').css('display', 'none'); | ||
display_error_message(); | ||
} | ||
}); | ||
|
||
$('.user_disabled_input').focusin(function () { | ||
display_error_message('Sorry! But you are not allowed to change this' + | ||
' field value.'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.