Skip to content

Commit

Permalink
rename Config model to FDOConfig
Browse files Browse the repository at this point in the history
Signed-off-by: Rupanshi Jain <[email protected]>
  • Loading branch information
rdotjain committed Aug 26, 2022
1 parent 06089be commit b72a752
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
19 changes: 19 additions & 0 deletions zezere/migrations/0015_rename_config_fdoconfig.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 4.0.4 on 2022-08-26 10:38

from django.conf import settings
from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('zezere', '0014_config'),
]

operations = [
migrations.RenameModel(
old_name='Config',
new_name='FDOConfig',
),
]
2 changes: 1 addition & 1 deletion zezere/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class Meta:
fields = ["mac_address"]


class Config(models.Model):
class FDOConfig(models.Model):
owner = models.ForeignKey(
User, on_delete=models.PROTECT, default=None, blank=True, null=True
)
Expand Down
12 changes: 6 additions & 6 deletions zezere/views_portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from rules.contrib.views import permission_required
from ipware import get_client_ip

from zezere.models import Device, RunRequest, device_getter, SSHKey, Config
from zezere.models import Device, RunRequest, device_getter, SSHKey, FDOConfig


@login_required
Expand Down Expand Up @@ -125,8 +125,8 @@ def ov(request):
@login_required
@require_POST
def add_ov(request):
OV_BASE_URL = Config.objects.get(owner=request.user).ov_base_url
AUTH_TOKEN = Config.objects.get(owner=request.user).auth_token
OV_BASE_URL = FDOConfig.objects.get(owner=request.user).ov_base_url
AUTH_TOKEN = FDOConfig.objects.get(owner=request.user).auth_token

payload = None
no_of_vouchers = request.POST["no_of_vouchers"]
Expand Down Expand Up @@ -169,7 +169,7 @@ def add_ov(request):
@login_required
def configure(request):
if request.method == "GET":
config = Config.objects.filter(owner=request.user).first()
config = FDOConfig.objects.filter(owner=request.user).first()
auth_token = config.auth_token if config else ""
ov_base_url = config.ov_base_url if config else ""
return render(
Expand All @@ -185,9 +185,9 @@ def configure(request):
messages.error(request, "Please fill in all fields")
return redirect("portal_configure")

config = Config.objects.filter(owner=owner).first()
config =FDOConfig.objects.filter(owner=owner).first()
if config is None:
config = Config(owner=owner)
config = FDOConfig(owner=owner)
config.auth_token = auth_token
config.ov_base_url = ov_base_url
config.save()
Expand Down

0 comments on commit b72a752

Please sign in to comment.