Skip to content

Commit

Permalink
Merge pull request #125 from NFM-Studios/reverify-email
Browse files Browse the repository at this point in the history
Reverify email closes #123
  • Loading branch information
mikemaddem committed Feb 9, 2021
2 parents 97943e4 + c217263 commit d28ad53
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 17 deletions.
12 changes: 12 additions & 0 deletions changelog.md
@@ -1,5 +1,17 @@
Project Olly Changelog

# 1.0.2
- Allow staff to send email reverification email (in the case of an email server hiccup) - closes #123
- Fixed hard coded redirects in staff:users template
- Added additional UserProfile fields to staff:modify_user
- Fix javascript datetime error with multiple matches in matches:list
- Revamp staff:team_detail template
- Revamp staff:user_detail template
- Fixed datetime constraints for some Notification object creation events
- Added user notifications for match updates made within staff panel
- Remove duplicate django messages
- PEP8 improvements

# 1.0.1
- Add front end changes for match scheduling in match list page
- Fix captains list on team detail template.
Expand Down
2 changes: 1 addition & 1 deletion olly/base_settings.py
Expand Up @@ -174,4 +174,4 @@
LOGIN_REDIRECT_URL = '/'
LOGIN_URL = '/login/'

SITE_VERSION = "1.0.1"
SITE_VERSION = "1.0.2"
Binary file added project-static/images/game-placeholder.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions project-templates/matches/match_detail.html
Expand Up @@ -20,9 +20,11 @@
<div class="col-xs-12 banner-head bot20">
<div class="row">
<div class="col-xs-12 col-sm-4">
<img src="{{ MEDIA_URL }}{{ match.game.image }}"/>
<img style="width: auto" src="{% static 'images/game-placeholder.jpg' %}"/>
</div>
<div class="col-xs-12 col-sm-8">
</div>
<div class="row">
<div class="col-xs-12 col-sm-8 center">
<br>
<!--<h2><b>COMPETITION NAME HERE</b></h2>-->
<h3 style="font-weight:200;">{{ match.platform.name }}</h3>
Expand Down
12 changes: 12 additions & 0 deletions project-templates/staff/profiles/user_edit.html
Expand Up @@ -9,6 +9,18 @@
{% csrf_token %}
{{ field.errors }}

<label>Alternate Name:</label>
{{ form.alternate_name }}
<br>

<label>SteamID64:</label>
{{ form.steamid64 }}
<br>

<label>Discord:</label>
{{ form.discord }}
<br>

<label>Bronze:</label>
{{ form.num_bronze }}
<br>
Expand Down
28 changes: 20 additions & 8 deletions project-templates/staff/profiles/users.html
Expand Up @@ -38,26 +38,36 @@
<td>Standard User</td>
{% endif %}

<td><a href="/staff/users/modify/{{ up.user }}" class="btn btn-primary">Modify User</a></td>
<td><a href="{% url 'staff:modify_user' urlusername=up.user %}" class="btn btn-primary">Modify
User</a></td>

{% if up.user.id in bannedusernames %}
<td><a href="/staff/users/unban/{{ up.user }}" class="btn btn-warning">UNBAN USERNAME</a></td>
<td><a href="{% url 'staff:unban_user' urlusername=up.user %}" class="btn btn-warning">UNBAN
USERNAME</a></td>
{% else %}
<td><a href="/staff/users/ban/{{ up.user }}" class="btn btn-danger">BAN USERNAME</a></td>
<td><a href="{% url 'staff:ban_user' urlusername=up.user %}" class="btn btn-danger">BAN
USERNAME</a></td>
{% endif %}

{% if up.ip in bannedips %}
<td><a href="/staff/users/unbanip/{{ up.user }}" class="btn btn-warning">UNBAN IP</a></td>
<td><a href="{% url 'staff:unban_ip' urlusername=up.user %}" class="btn btn-warning">UNBAN
IP</a></td>
{% else %}
<td><a href="/staff/users/banip/{{ up.user }}" class="btn btn-danger">BAN IP</a></td>
<td><a href="{% url 'staff:ban_ip' urlusername=up.user %}" class="btn btn-danger">BAN IP</a>
</td>
{% endif %}

{% if verification %}
{% if not up.user_verified %}
<td><a href="/staff/users/verify/{{ up.user }}" class="btn btn-primary"> Verify User</a>
<td><a href="{% url 'staff:verify_user' urlusername=up.user %}" class="btn btn-primary">
Force Verify
User</a>
</td>
<td><a href="{% url 'staff:resend_verify_email' urlusername=up.user %}"
class="btn btn-primary"> Resend verification email</a></td>
{% else %}
<td><a href="/staff/users/verify/{{ up.user }}" class="btn btn-primary"> Unverify User</a>
<td><a href="{% url 'staff:verify_user' urlusername=up.user %}" class="btn btn-primary">
Unverify User</a>
</td>
{% endif %}
{% endif %}
Expand All @@ -67,6 +77,8 @@
</table>
{% include "pagination.html" with page=userprofiles %}
<td><a href="{% url 'staff:get_rank' %}" class="btn btn-primary">Calculate rank for all users</a></td>
<td><a href="{% url 'staff:reset_xp' %}" onclick="return confirm('Are you sure you want to reset XP for all users?\nThis cannot be undone!')" class="btn btn-danger">Reset XP for all users</a></td>
<td><a href="{% url 'staff:reset_xp' %}"
onclick="return confirm('Are you sure you want to reset XP for all users?\nThis cannot be undone!')"
class="btn btn-danger">Reset XP for all users</a></td>
</div>
{% endblock %}
4 changes: 3 additions & 1 deletion staff/forms.py
Expand Up @@ -205,7 +205,9 @@ class RemovePlayerFormPost(forms.Form):
class ModifyUserForm(forms.ModelForm):
class Meta:
model = UserProfile
fields = ('num_bronze', 'num_silver', 'num_gold', 'current_earning', 'xp', 'credits', 'user_type')
fields = (
'num_bronze', 'num_silver', 'num_gold', 'current_earning', 'xp', 'credits', 'user_type', 'alternate_name',
'steamid64', 'discord')


class CreateProductForm(forms.ModelForm):
Expand Down
1 change: 1 addition & 0 deletions staff/urls.py
Expand Up @@ -38,6 +38,7 @@
path('users/search/', login_required(views.searchusers), name='searchusers'),
path('users/modify/<urlusername>/', login_required(views.modifyuser), name='modify_user'),
path('users/<urlusername>/', login_required(views.userdetail), name='userdetail'),
path('users/<urlusername>/resend_verify_email/', login_required(views.resend_verify_email), name='resend_verify_email'),
path('users/verify/<urlusername>/', login_required(views.verify), name='verify_user'),

path('tournaments/', login_required(views.tournaments), name='tournamentlist'),
Expand Down
39 changes: 35 additions & 4 deletions staff/views/users.py
@@ -1,8 +1,14 @@
from django.contrib import messages
from django.conf import settings
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.shortcuts import render, redirect

from django.conf import settings
from django.contrib import messages
from django.contrib.sites.shortcuts import get_current_site
from django.core.mail import EmailMessage
from django.shortcuts import render, redirect, get_object_or_404
from django.template.loader import render_to_string
from django.utils.encoding import force_bytes, force_text
from django.utils.http import urlsafe_base64_encode, urlsafe_base64_decode, is_safe_url

from profiles.tokens import account_activation_token
from profiles.models import BannedUser
from staff.forms import *
from wagers.models import *
Expand Down Expand Up @@ -170,6 +176,31 @@ def userdetail(request, urlusername):
return render(request, 'staff/profiles/user_detail.html', {'userprofile': userprofile})


def resend_verify_email(request, urlusername):
user = UserProfile.objects.get(user__username=request.user.username)
allowed = ['superadmin', 'admin']
if user.user_type not in allowed:
return render(request, 'staff/permissiondenied.html')
else:
# should be a get request
user = User.objects.get(username=urlusername)
current_site = get_current_site(request)
mail_subject = 'Activate your ' + settings.SITE_NAME + ' account.'
message = render_to_string('profiles/activate_email.html', {
'user': user,
'domain': current_site.domain,
'uid': urlsafe_base64_encode(force_bytes(user.pk)),
'token': account_activation_token.make_token(user),
})
to_email = user.email
email = EmailMessage(
mail_subject, message, from_email=settings.FROM_EMAIL, to=[to_email]
)
email.send()
messages.success(request, "Resent verification email")
return redirect('staff:users')


def verify(request, urlusername):
user = UserProfile.objects.get(user__username=request.user.username)
allowed = ['superadmin', 'admin']
Expand Down
9 changes: 8 additions & 1 deletion teams/tests.py
@@ -1,7 +1,8 @@
from django.test import TestCase, RequestFactory
from .models import Team
from .models import Team, TeamInvite
from django.contrib.auth.models import User
from .views import *
from .forms import RemovePlayerFormPost


class TeamTestCase(TestCase):
Expand Down Expand Up @@ -55,3 +56,9 @@ def test_teamdetailview(self):
request.user = self.user
response = MyTeamDetailView.get(None, request, pk=self.team.id)
self.assertEqual(response.status_code, 200)

def test_teameditview(self):
request = self.factory.get('teams:edit', pk=self.team.id)
request.user = self.user
response = edit_team_view(request, pk=self.team.id)
self.assertEqual(response.status_code, 200)

0 comments on commit d28ad53

Please sign in to comment.