diff --git a/idlerpg/migrations/0005_alter_character_status.py b/idlerpg/migrations/0005_alter_character_status.py new file mode 100644 index 0000000..b5a4846 --- /dev/null +++ b/idlerpg/migrations/0005_alter_character_status.py @@ -0,0 +1,18 @@ +# Generated by Django 5.0.5 on 2024-05-13 04:35 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('idlerpg', '0004_remove_character_no_characters_with_same_name_per_game_and_more'), + ] + + operations = [ + migrations.AlterField( + model_name='character', + name='status', + field=models.CharField(choices=[('DISABLED', 'Disabled'), ('LOGGEDIN', 'Logged in'), ('OFFLINE', 'Offline')], default='OFFLINE', max_length=8), + ), + ] diff --git a/idlerpg/models.py b/idlerpg/models.py index 9a04a4e..20fb569 100644 --- a/idlerpg/models.py +++ b/idlerpg/models.py @@ -79,12 +79,10 @@ class Character(models.Model): CHARACTER_STATUS_DISABLED = 'DISABLED' CHARACTER_STATUS_LOGGED_IN = 'LOGGEDIN' CHARACTER_STATUS_OFFLINE = 'OFFLINE' - CHARACTER_STATUS_ONLINE = 'ONLINE' CHARACTER_STATUSES = { CHARACTER_STATUS_DISABLED: "Disabled", CHARACTER_STATUS_LOGGED_IN: "Logged in", CHARACTER_STATUS_OFFLINE: "Offline", - CHARACTER_STATUS_ONLINE: "Online", } NICK_CHANGE_P = 30 @@ -169,8 +167,8 @@ class Character(models.Model): Raises: ValueError: if the provided password was incorrect, or the character isn't logged out """ - if self.status != self.CHARACTER_STATUS_ONLINE: - raise ValueError(f"character '{self.name}' can't be logged in, isn't online!") + if self.status != self.CHARACTER_STATUS_OFFLINE: + raise ValueError(f"character '{self.name}' can't be logged in, isn't offline!") if not check_password(password, self.password): raise ValueError(f"incorrect password for character '{self.name}'!") diff --git a/tests/test_idlerpg_character.py b/tests/test_idlerpg_character.py index beec53c..1692ab5 100644 --- a/tests/test_idlerpg_character.py +++ b/tests/test_idlerpg_character.py @@ -56,7 +56,6 @@ class CharacterTest(TestCase): char.log_out() # logout has a penalty of its own, so this post-logout value is what will be altered old_next_level = char.next_level - char.status = Character.CHARACTER_STATUS_ONLINE with patch('django.utils.timezone.now', return_value=login_time): char.log_in('bss', 'bss!bss@test_log_in') @@ -74,7 +73,6 @@ class CharacterTest(TestCase): """Test that we can't log in the character if we don't have the right password.""" char = Character.objects.get(pk=1) char.log_out() - char.status = Character.CHARACTER_STATUS_ONLINE with self.assertRaises(ValueError): char.log_in('bad pass', 'bss!bss@test_bad_password')