Skip to content

Commit

Permalink
Merge pull request #215 from nucleogenesis/fix--tos-about
Browse files Browse the repository at this point in the history
Fixes: Terms of Service, About Button, Sign in for new users
  • Loading branch information
nucleogenesis authored Jan 8, 2025
2 parents db48c76 + 2e85391 commit d2acbe0
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build and deploy
on:
push:
branches:
- main
- develop
workflow_dispatch:

jobs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@
<script>
import urls from 'kolibri.urls';
import AppBarPage from 'kolibri.coreVue.components.AppBarPage';
import { mapActions, mapState } from 'vuex';
import NewProfileModal from './NewProfileModal';
import ProfilesList from './ProfilesList';
export default {
name: 'SelectProfilePage',
components: {
AppBarPage,
NewProfileModal,
ProfilesList,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import './fix.css';
import { UserKinds, NavComponentSections } from 'kolibri.coreVue.vuex.constants';
import registerNavItem from 'kolibri.utils.registerNavItem';
import urls from 'kolibri.urls';
Expand Down
10 changes: 10 additions & 0 deletions kolibri_instant_schools_plugin/assets/src/views/SideNav/fix.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* This is a hack introduced to hide the hashed username displayed within the side nav. */

.user-information p:nth-child(3) {
/* Hide hashed username */
display: none !important;
}
.user-information p:nth-child(4) {
/* Better spacing between account type & full name */
margin-top: 0.5em !important;
}
13 changes: 6 additions & 7 deletions kolibri_instant_schools_plugin/assets/src/views/SignUpPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,17 @@
v-if="showTerms"
:title="$tr('termsOfServiceModalHeader')"
:size="'large'"
:cancelText="$tr('close')"
@cancel="showTerms = false"
>
<!--
aboutfaq/Terms returns the "Terms" kind of "AboutFAQ" model record
configured in the Django admin panel
-->
<iframe
class="terms"
src="/content/databases/about/tos.txt"
src="/en/user/api/aboutfaq/Terms"
></iframe>
<KButton
:text="$tr('close')"
:primary="false"
:disabled="false"
@click="showTerms = false"
/>
</KModal>
</div>
</ImmersivePage>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
appearance="raised-button"
:text="$tr('back')"
:to="aboutRoute"
style="margin: 0.5em 0"
/>

<iframe
Expand Down
20 changes: 5 additions & 15 deletions kolibri_instant_schools_plugin/auth/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,31 +32,21 @@ def retrieve(self, request, pk=None):
class PhoneNumberSignupSerializer(FacilityUserSerializer):

def validate_username(self, value):
if FacilityUser.objects.filter(username__iexact=value).exists():
# Check if the phone number is already associated with an account
usernames = get_usernames(hash_phone(value))
if usernames:
raise serializers.ValidationError(
_('An account already exists for this phone number. To add a new profile ' +
'under this account, you must first login. If you have forgotten your ' +
'password, you can reset it using the link on the login page.'))
return value

return create_new_username(value)


class PhoneNumberSignUpViewSet(SignUpViewSet):

serializer_class = PhoneNumberSignupSerializer

def extract_request_data(self, request):
data = super(PhoneNumberSignUpViewSet, self).extract_request_data(request)

# if there are already users for this number, use one, to trigger a validation error, else create a new one
usernames = get_usernames(hash_phone(data["username"]))
if usernames:
data["username"] = hash_phone(usernames[0])
else:
data["username"] = create_new_username(data["username"])

return data


class PasswordResetTokenViewset(viewsets.ViewSet):

def create(self, request):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.25 on 2025-01-08 00:30

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('kolibri_instant_schools_plugin', '0005_aboutfaq'),
]

operations = [
migrations.AlterField(
model_name='aboutfaq',
name='kind',
field=models.TextField(choices=[('FAQ', 'FAQ'), ('About', 'About'), ('Terms', 'Terms')]),
),
]
2 changes: 1 addition & 1 deletion kolibri_instant_schools_plugin/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class AboutFAQ(models.Model):
html = models.TextField()
kind = models.TextField(choices=(("FAQ", "FAQ"), ("About", "About")))
kind = models.TextField(choices=(("FAQ", "FAQ"), ("About", "About"), ("Terms", "Terms")))

class Meta:
app_label = "kolibri_instant_schools_plugin"
Expand Down

0 comments on commit d2acbe0

Please sign in to comment.