-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add guest user permission for post apis.
- Loading branch information
1 parent
777c3a3
commit 3743bf3
Showing
18 changed files
with
207 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Generated by Django 4.2.13 on 2024-07-01 09:17 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("api", "0210_profile_accepted_montandon_license_terms"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="profile", | ||
name="limit_access_to_guest", | ||
field=models.BooleanField( | ||
default=False, | ||
help_text="User having this value as true explictly is treated as guest user.Despite of having all the permission, if this value is set to true, the user is deprived of all the non-guest user permission.", | ||
verbose_name="limit access to guest user permissions", | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="profile", | ||
name="limit_access_to_guest", | ||
field=models.BooleanField( | ||
default=True, | ||
help_text="User having this value as true explictly is treated as guest user.Despite of having all the permission, if this value is set to true, the user is deprived of all the non-guest user permission.", | ||
verbose_name="limit access to guest user permissions", | ||
), | ||
), | ||
] |
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
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 |
---|---|---|
@@ -1,10 +1,21 @@ | ||
import factory | ||
from django.contrib.auth import get_user_model | ||
|
||
from api.models import Profile | ||
|
||
|
||
class UserFactory(factory.django.DjangoModelFactory): | ||
class Meta: | ||
model = get_user_model() | ||
|
||
username = factory.Sequence(lambda n: "user_%d" % n) | ||
email = factory.Sequence(lambda n: "user_%[email protected]" % n) | ||
|
||
@factory.post_generation | ||
def create_profile(obj, create, extracted, **kwargs): | ||
if create: | ||
profile = Profile.objects.get(user=obj) | ||
profile.limit_access_to_guest = False | ||
profile.save(update_fields=["limit_access_to_guest"]) | ||
# Set new profile to the user object | ||
obj.profile = profile |
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
Oops, something went wrong.