Skip to content

Commit

Permalink
Merge pull request #1660 from codalab/develop
Browse files Browse the repository at this point in the history
Merge develop into master
  • Loading branch information
Didayolo authored Nov 13, 2024
2 parents fd81bdc + 64a32ef commit 3f7b465
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 18 deletions.
30 changes: 19 additions & 11 deletions .github/workflows/release-version-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@ jobs:

- name: Get release information
id: get_release
uses: dawidd6/action-get-latest-release@v3
with:
release: true
run: |
response=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/releases/latest)
echo "$response" | jq '.tag_name, .name, .published_at, .body, .html_url' | tee /tmp/release_info
echo "::set-output name=tag_name::$(echo "$response" | jq -r .tag_name)"
echo "::set-output name=name::$(echo "$response" | jq -r .name)"
echo "::set-output name=published_at::$(echo "$response" | jq -r .published_at)"
echo "::set-output name=body::$(echo "$response" | jq -r .body)"
echo "::set-output name=html_url::$(echo "$response" | jq -r .html_url)"
- name: Update version.json
run: |
Expand All @@ -25,7 +31,7 @@ jobs:
"release_name": "${{ steps.get_release.outputs.name }}",
"published_at": "${{ steps.get_release.outputs.published_at }}",
"body": "${{ steps.get_release.outputs.body }}"
"release_url": "${{ steps.get_release.outputs.html_url }}"
"html_url": "${{ steps.get_release.outputs.html_url }}"
}' > version.json
- name: Create new branch
Expand All @@ -41,10 +47,12 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: update-version-${{ steps.get_release.outputs.tag_name }}
title: "Update version.json for release ${{ steps.get_release.outputs.tag_name }}"
body: "This PR updates version.json with the latest release information."
base: develop # Target branch for the pull request
run: |
curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/pulls \
-d '{
"title": "Update version.json for release ${{ steps.get_release.outputs.tag_name }}",
"body": "This PR updates version.json with the latest release information.",
"head": "update-version-${{ steps.get_release.outputs.tag_name }}",
"base": "develop"
}'
4 changes: 4 additions & 0 deletions src/apps/profiles/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ class LoginForm(forms.Form):

username = forms.CharField(max_length=150)
password = forms.CharField(max_length=150, widget=forms.PasswordInput)


class ActivationForm(forms.Form):
email = forms.EmailField(max_length=254, required=True)
1 change: 1 addition & 0 deletions src/apps/profiles/urls_accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

urlpatterns = [
url(r'^signup', views.sign_up, name="signup"),
path('resend_activation/', views.resend_activation, name='resend_activation'),
path('login/', views.log_in, name='login'),
path('logout/', views.LogoutView.as_view(), name='logout'),
path('password_reset/', views.CustomPasswordResetView.as_view(), name='password_reset'),
Expand Down
33 changes: 29 additions & 4 deletions src/apps/profiles/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from api.serializers.profiles import UserSerializer, OrganizationDetailSerializer, OrganizationEditSerializer, \
UserNotificationSerializer
from .forms import SignUpForm, LoginForm
from .forms import SignUpForm, LoginForm, ActivationForm
from .models import User, Organization, Membership
from oidc_configurations.models import Auth_Organization
from .tokens import account_activation_token
Expand Down Expand Up @@ -82,8 +82,8 @@ def activate(request, uidb64, token):
messages.success(request, f'Your account is fully setup! Please login.')
return redirect('accounts:login')
else:
messages.error(request, f"Activation link is invalid. Please double check your link.")
return redirect('accounts:signup')
messages.error(request, f"Activation link is invalid or expired. Please double check your link.")
return redirect('accounts:resend_activation')
return redirect('pages:home')


Expand Down Expand Up @@ -135,6 +135,31 @@ def sign_up(request):
return render(request, 'registration/signup.html', context)


def resend_activation(request):
context = {}
if request.method == 'POST':
form = ActivationForm(request.POST)
if form.is_valid():

email = form.cleaned_data.get('email')
user = User.objects.filter(email=email).first()

if user and not user.is_active:
activateEmail(request, user, email)
return redirect('pages:home')
else:
if not user:
messages.error(request, "No account found with this email.")
elif user.is_active:
messages.error(request, "This account is already active.")
else:
context['form'] = form

if not context.get('form'):
context['form'] = ActivationForm()
return render(request, 'registration/resend_activation.html', context)


def log_in(request):

# Fectch next redirect page after login
Expand Down Expand Up @@ -173,7 +198,7 @@ def log_in(request):
else:
return redirect(next)
else:
messages.error(request, "Account is not active. Activate your account using the link sent to you by email.")
context['activation_error'] = "Your account is not activated. Please check your email for the activation link"
else:
messages.error(request, "Wrong Credentials!")
else:
Expand Down
2 changes: 1 addition & 1 deletion src/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ <h4 class="ui inverted header">CodaBench</h4>
</div>
{% if VERSION_INFO.tag_name != 'invalid' and VERSION_INFO.tag_name != 'unknown' %}
<div id="version">
<a href="{{ VERSION_INFO.release_url }}" target="_blank">{{ VERSION_INFO.tag_name }}</a>
<a href="{{ VERSION_INFO.html_url }}" target="_blank">{{ VERSION_INFO.tag_name }}</a>
</div>
{% endif %}
</div>
Expand Down
5 changes: 5 additions & 0 deletions src/templates/registration/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
<h2 class="ui blue centered header">
Login
</h2>
{% if activation_error %}
<div class="ui red message">
{{ activation_error }} or click <a href="{% url 'accounts:resend_activation' %}">here</a> to send the activation email again
</div>
{% endif %}
<div class="ui stacked segment">
<form class="ui form" method="POST">
{% csrf_token %}
Expand Down
33 changes: 33 additions & 0 deletions src/templates/registration/resend_activation.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{% extends 'base.html' %}
{% load static %}

{% block content %}
<div class="six wide centered column">
<h2 class="ui blue centered header">
Resend Activation
</h2>
<div class="ui stacked segment">
<h5>Activation link expired?</h5>
<p>Enter your email in the form below and we'll send you a new activation link for your account.</p>
<div class="ui divider"></div>
<form class="ui form" method="post">
{% csrf_token %}

<div class="field">
<div class="ui left icon input">
<i class="envelope icon"></i>
<input type="email"
name="email"
placeholder="email"
id="id_email"
value="{{ form.email.value|default:''}}"
maxlength="{{ form.email.field.max_length }}"
required>
</div>
</div>
<button class="ui blue fluid submit button" type="submit">Resend Activation Email</button>
</form>
</div>

</div>
{% endblock %}
2 changes: 1 addition & 1 deletion src/utils/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __call__(self, instance, filename):
return path


def make_url_sassy(path, permission='r', duration=60 * 60 * 24, content_type='application/zip'):
def make_url_sassy(path, permission='r', duration=60 * 60 * 24 * 5, content_type='application/zip'):
assert permission in ('r', 'w'), "SASSY urls only support read and write ('r' or 'w' permission)"

client_method = None # defined based on storage backend
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"release_name": "Release 1.11.0",
"published_at": "2024-09-16",
"body": "",
"release_url": "https://github.com/codalab/codabench/releases/tag/v1.11.0"
"html_url": "https://github.com/codalab/codabench/releases/tag/v1.11.0"
}

0 comments on commit 3f7b465

Please sign in to comment.