mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-04-17 23:51:47 +00:00
Compare commits
2 Commits
c12dae6676
...
2871dcd281
| Author | SHA1 | Date | |
|---|---|---|---|
|
2871dcd281
|
|||
|
a743d18dc9
|
@@ -359,7 +359,7 @@ class PrintView(generic.View):
|
|||||||
'object': obj,
|
'object': obj,
|
||||||
'current_user': self.request.user,
|
'current_user': self.request.user,
|
||||||
'object_name': object_name,
|
'object_name': object_name,
|
||||||
'info_string': get_info_string(self.request.user) + "- {obj.current_version_id}]",
|
'info_string': get_info_string(self.request.user) + f"- {obj.current_version_id}]",
|
||||||
}
|
}
|
||||||
|
|
||||||
return context
|
return context
|
||||||
@@ -371,7 +371,7 @@ class PrintView(generic.View):
|
|||||||
class PrintListView(generic.ListView):
|
class PrintListView(generic.ListView):
|
||||||
def get_context_data(self, *args, **kwargs):
|
def get_context_data(self, *args, **kwargs):
|
||||||
context = super().get_context_data(*args, **kwargs)
|
context = super().get_context_data(*args, **kwargs)
|
||||||
context['current_user'] = self.request.user,
|
context['current_user'] = self.request.user
|
||||||
context['info_string'] = get_info_string(self.request.user) + "]"
|
context['info_string'] = get_info_string(self.request.user) + "]"
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|||||||
@@ -105,8 +105,7 @@ class Command(BaseCommand):
|
|||||||
|
|
||||||
for i in range(100):
|
for i in range(100):
|
||||||
prefix = random.choice(asset_prefixes)
|
prefix = random.choice(asset_prefixes)
|
||||||
asset_id = str(get_available_asset_id(wanted_prefix=prefix))
|
asset_id = get_available_asset_id(wanted_prefix=prefix)
|
||||||
asset_id = prefix + asset_id
|
|
||||||
asset = models.Asset(
|
asset = models.Asset(
|
||||||
asset_id=asset_id,
|
asset_id=asset_id,
|
||||||
description=random.choice(asset_description),
|
description=random.choice(asset_description),
|
||||||
|
|||||||
@@ -102,7 +102,8 @@ class AssetManager(models.Manager):
|
|||||||
|
|
||||||
def get_available_asset_id(wanted_prefix=""):
|
def get_available_asset_id(wanted_prefix=""):
|
||||||
last_asset = Asset.objects.filter(asset_id_prefix=wanted_prefix).last()
|
last_asset = Asset.objects.filter(asset_id_prefix=wanted_prefix).last()
|
||||||
return 9000 if last_asset is None else wanted_prefix + str(last_asset.asset_id_number + 1)
|
last_asset_id = last_asset.asset_id_number if last_asset else 0
|
||||||
|
return wanted_prefix + str(last_asset_id + 1)
|
||||||
|
|
||||||
|
|
||||||
def validate_positive(value):
|
def validate_positive(value):
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ class DuplicateMixin:
|
|||||||
class AssetDuplicate(DuplicateMixin, AssetIDUrlMixin, AssetCreate):
|
class AssetDuplicate(DuplicateMixin, AssetIDUrlMixin, AssetCreate):
|
||||||
def get_initial(self, *args, **kwargs):
|
def get_initial(self, *args, **kwargs):
|
||||||
initial = super().get_initial(*args, **kwargs)
|
initial = super().get_initial(*args, **kwargs)
|
||||||
initial["asset_id"] = models.get_available_asset_id(wanted_prefix=self.get_object().asset_id_prefix)
|
initial["asset_id"] = models.get_available_asset_id()
|
||||||
return initial
|
return initial
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class ItemListExport(PrintListView):
|
|||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context['filename'] = f"TrainingItemList.pdf"
|
context['filename'] = "TrainingItemList.pdf"
|
||||||
context["categories"] = models.TrainingCategory.objects.all()
|
context["categories"] = models.TrainingCategory.objects.all()
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user