Skip to content

Commit

Permalink
Merge pull request #1057 from DemocracyLab/sprint-94-release
Browse files Browse the repository at this point in the history
Sprint 94 release
  • Loading branch information
marlonkeating authored Oct 23, 2023
2 parents 2693a0b + 2bf4b02 commit ede7788
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 60 deletions.
1 change: 0 additions & 1 deletion civictechprojects/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,6 @@ def accept_project_volunteer(request, application_id):
# Redirect to login if not logged in
if not request.user.is_authenticated:
return redirect(section_url(FrontEndSection.LogIn, {'prev': request.get_full_path()}))

volunteer_relation = VolunteerRelation.objects.get(id=application_id)
about_project_url = section_url(FrontEndSection.AboutProject, {'id': str(volunteer_relation.project.id)})
if volunteer_relation.is_approved:
Expand Down
50 changes: 29 additions & 21 deletions common/components/common/projects/ProjectVolunteerButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type LeaveProjectParams = {|
type Props = {|
project: ?ProjectDetailsAPIData,
positionToJoin: ?PositionInfo,
positions: $ReadOnlyArray<PositionInfo>,
onVolunteerClick: () => void,
|};
type State = {|
Expand Down Expand Up @@ -151,28 +152,35 @@ class ProjectVolunteerButton extends React.PureComponent<Props, State> {
}

_renderVolunteerButton(): React$Node {
return this.state.isAlreadyVolunteering ? (
const hasProjectPositions = !_.isEmpty(this.state.project.project_positions) && this.state.project.project_positions.some(position => !position.isHidden);
if (this.state.isAlreadyVolunteering) {
// TODO: Make this its own component and hook up to My Projects page
<Button
className="AboutProject-button"
type="button"
variant="destructive"
onClick={this.handleShowLeaveModal}
>
Leave Project
</Button>
) : (
<Button
variant="primary"
className="AboutProject-button"
type="button"
disabled={this.state.buttonDisabled}
title={this.state.buttonTitle}
onClick={this.handleShowJoinModal}
>
Volunteer With Project
</Button>
);
return (
<Button
className="AboutProject-button"
type="button"
variant="destructive"
onClick={this.handleShowLeaveModal}
>
Leave Project
</Button>
);
} else if (hasProjectPositions) {
return (
<Button
variant="primary"
className="AboutProject-button"
type="button"
disabled={this.state.buttonDisabled}
title={this.state.buttonTitle}
onClick={this.handleShowJoinModal}
>
Volunteer With Project
</Button>
);
} else {
return null;
}
}

_renderLinkToSignInButton(): React$Node {
Expand Down
36 changes: 2 additions & 34 deletions common/components/common/projects/ProjectVolunteerModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const volunteerPeriodsInDays: $ReadOnlyArray<SelectOption> = [
["6 months - 1 year", 365],
].map(textDaysPair => ({ label: textDaysPair[0], value: textDaysPair[1] }));

const OtherRoleOption: SelectOption = { label: "Other", value: "Other" };

/**
* Modal for volunteering to join a project
Expand Down Expand Up @@ -80,7 +79,6 @@ class ProjectVolunteerModal extends React.PureComponent<Props, State> {
value: position.roleTag.tag_name,
label: tagOptionDisplay(position.roleTag),
}))
.concat(OtherRoleOption)
);

let state: State = {
Expand Down Expand Up @@ -187,12 +185,6 @@ class ProjectVolunteerModal extends React.PureComponent<Props, State> {
{!_.isEmpty(this.props.positions)
? this._renderExistingPositionDropdown()
: null}
{_.isEmpty(this.props.positions) ||
(this.state.existingPositionOption &&
this.state.existingPositionOption.value ===
OtherRoleOption.value)
? this._renderOtherRoleDropdown()
: null}
<Form.Label>
How long do you expect to be able to contribute to this
project?
Expand Down Expand Up @@ -242,21 +234,12 @@ class ProjectVolunteerModal extends React.PureComponent<Props, State> {
);
}

_selectedExistingPositionTag(): ?string {
return this.state.existingPositionOption &&
this.state.existingPositionOption.value !== OtherRoleOption.value
_selectedTag(): ?string {
return this.state.existingPositionOption
? this.state.existingPositionOption.value
: null;
}

_selectedOtherRoleTag(): ?string {
return this.state.roleTag && this.state.roleTag.tag_name;
}

_selectedTag(): ?string {
return this._selectedExistingPositionTag() || this._selectedOtherRoleTag();
}

_renderExistingPositionDropdown(): React$Node {
return (
<div className="form-group">
Expand All @@ -276,21 +259,6 @@ class ProjectVolunteerModal extends React.PureComponent<Props, State> {
);
}

_renderOtherRoleDropdown(): React$Node {
return (
<div className="form-group">
<label htmlFor="project_technologies">Role You are Applying For</label>
<TagSelector
value={[this.state.roleTag]}
category={TagCategory.ROLE}
allowMultiSelect={false}
isClearable={false}
onSelection={this.onRoleChange.bind(this)}
/>
</div>
);
}

_renderVolunteerPeriodDropdown(): React$Node {
return (
<Select
Expand Down
10 changes: 9 additions & 1 deletion common/helpers/front_end.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ def section_path(section, args_dict=None):
section_path_url = _section_path_special_cases(section_string, args_dict)
if section_path_url:
return section_path_url
section_path_url = '/' + url_generators[section_string]['generator'].format(**id_arg)
#check if it is a page section
is_page_section = has_page_section(section_string)
if(is_page_section):
section_path_url = '/' + url_generators[section_string]['generator'].format(**id_arg)
else:
section_path_url = section
section_path_url += args_dict_to_query_string(args_dict)
return section_path_url

Expand All @@ -62,6 +67,9 @@ def get_page_section(url):
url_generator = get_page_section_generator(url)
return url_generator and url_generator['section']

def has_page_section(section_name):
from common.urls import url_generators
return section_name in url_generators

def get_page_path_parameters(url, page_section_generator=None):
page_section_generator = page_section_generator or get_page_section_generator(url)
Expand Down
4 changes: 1 addition & 3 deletions democracylab/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from django.http import HttpResponse, JsonResponse
from django.views.decorators.csrf import csrf_exempt
import simplejson as json
import ast
from .emails import send_verification_email, send_password_reset_email
from .forms import DemocracyLabUserCreationForm, DemocracyLabUserAddDetailsForm
from .models import Contributor, get_request_contributor, get_contributor_by_username
Expand All @@ -20,7 +19,6 @@

def login_view(request, provider=None):
provider_ids = [p.id for p in registry.get_list()]

if request.method == 'POST':
email = request.POST['username']
password = request.POST['password']
Expand All @@ -32,7 +30,7 @@ def login_view(request, provider=None):
if user is not None and user.is_authenticated:
login(request, user)
prev_page_args = json.loads(prev_page_args_string) if prev_page_args_string else None
redirect_url = '/' if prev_page.strip('/') == '' else section_url(prev_page, prev_page_args)
redirect_url = '/' if prev_page.strip('/') == '' else section_url(prev_page,prev_page_args)
return redirect(redirect_url)
else:
messages.error(request, 'Incorrect Email or Password')
Expand Down

0 comments on commit ede7788

Please sign in to comment.