Compare commits
4 Commits
2add0a087e
...
12b6c90481
Author | SHA1 | Date | |
---|---|---|---|
12b6c90481 | |||
8e4a9da39b | |||
3563d2e6a0 | |||
c80534ad20 |
12
.gitignore
vendored
Normal file
12
.gitignore
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# Ignore specific JSON files
|
||||||
|
/assort.json
|
||||||
|
/questassort.json
|
||||||
|
|
||||||
|
# Ignore cache
|
||||||
|
item_cache.json
|
||||||
|
|
||||||
|
# Ignore the log file
|
||||||
|
/log.log
|
||||||
|
|
||||||
|
# Ignore the backup directory
|
||||||
|
/bkp/
|
9
app.py
9
app.py
@ -4,6 +4,7 @@ import requests
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import traceback
|
import traceback
|
||||||
|
import time
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
@ -202,6 +203,14 @@ def save_assort_data():
|
|||||||
if 'details' in part:
|
if 'details' in part:
|
||||||
del part['details']
|
del part['details']
|
||||||
|
|
||||||
|
# Backup the existing assort.json
|
||||||
|
if not os.path.exists('./bkp'):
|
||||||
|
os.makedirs('./bkp')
|
||||||
|
backup_file_path = os.path.join('./bkp', f"assort_backup_{int(time.time())}.json")
|
||||||
|
if os.path.exists(ASSORT_FILE_PATH):
|
||||||
|
os.rename(ASSORT_FILE_PATH, backup_file_path)
|
||||||
|
logging.debug(f"Backup of assort data created at {backup_file_path}")
|
||||||
|
|
||||||
with open(ASSORT_FILE_PATH, 'w') as f:
|
with open(ASSORT_FILE_PATH, 'w') as f:
|
||||||
json.dump(cleaned_assort_data, f, indent=2) # Use 2 spaces for indentation
|
json.dump(cleaned_assort_data, f, indent=2) # Use 2 spaces for indentation
|
||||||
logging.debug("Assort data saved successfully")
|
logging.debug("Assort data saved successfully")
|
||||||
|
@ -1,142 +1,162 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Trader Assort</title>
|
<title>Trader Assort</title>
|
||||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
|
||||||
<style>
|
<style>
|
||||||
.price-box {
|
.price-box {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
background-color: #f8f9fa;
|
background-color: #f8f9fa;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
margin-bottom: 15px;
|
margin-bottom: 15px;
|
||||||
}
|
}
|
||||||
.price-box img {
|
|
||||||
width: 30px;
|
.price-box img {
|
||||||
margin-right: 10px;
|
width: 30px;
|
||||||
}
|
margin-right: 10px;
|
||||||
.price-box span {
|
}
|
||||||
font-size: 1.2em;
|
|
||||||
font-weight: bold;
|
.price-box span {
|
||||||
}
|
font-size: 1.2em;
|
||||||
.price-box small {
|
font-weight: bold;
|
||||||
font-size: 0.8em;
|
}
|
||||||
color: #888;
|
|
||||||
}
|
.price-box small {
|
||||||
.card {
|
font-size: 0.8em;
|
||||||
margin-bottom: 15px;
|
color: #888;
|
||||||
}
|
}
|
||||||
.card-header img {
|
|
||||||
width: 45px;
|
.card {
|
||||||
margin-right: 10px;
|
margin-bottom: 15px;
|
||||||
}
|
}
|
||||||
.barter-list {
|
|
||||||
list-style-type: none;
|
.card-header img {
|
||||||
padding-left: 0;
|
width: 45px;
|
||||||
display: flex;
|
margin-right: 10px;
|
||||||
flex-direction: row;
|
}
|
||||||
}
|
|
||||||
.barter-list li {
|
.barter-list {
|
||||||
display: flex;
|
list-style-type: none;
|
||||||
align-items: center;
|
padding-left: 0;
|
||||||
}
|
display: flex;
|
||||||
.barter-list li img {
|
flex-direction: row;
|
||||||
width: 45px;
|
}
|
||||||
margin-right: 10px;
|
|
||||||
}
|
.barter-list li {
|
||||||
.parts-tree {
|
display: flex;
|
||||||
display: flex;
|
align-items: center;
|
||||||
flex-direction: row;
|
}
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
.barter-list li img {
|
||||||
.parts-tree > li {
|
width: 45px;
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
}
|
}
|
||||||
.part-item {
|
|
||||||
display: flex;
|
.parts-tree {
|
||||||
flex-direction: row;
|
display: flex;
|
||||||
align-items: center;
|
flex-direction: row;
|
||||||
background-color: #f8f9fa;
|
flex-wrap: wrap;
|
||||||
padding: 5px;
|
}
|
||||||
border-radius: 5px;
|
|
||||||
margin-bottom: 5px;
|
.parts-tree>li {
|
||||||
}
|
margin-right: 10px;
|
||||||
.part-item img {
|
}
|
||||||
width: 30px;
|
|
||||||
margin-right: 5px;
|
.part-item {
|
||||||
}
|
display: flex;
|
||||||
</style>
|
flex-direction: row;
|
||||||
</head>
|
align-items: center;
|
||||||
<body>
|
background-color: #f8f9fa;
|
||||||
<div class="container">
|
padding: 5px;
|
||||||
<h1>Trader Assort</h1>
|
border-radius: 5px;
|
||||||
<div class="list-group">
|
margin-bottom: 5px;
|
||||||
{% for item in items %}
|
}
|
||||||
<div class="card">
|
|
||||||
<div class="card-header d-flex align-items-center">
|
.part-item img {
|
||||||
<img src="{{ item.details.image512pxLink }}" alt="{{ item.details.name }}">
|
width: 30px;
|
||||||
<strong>{{ item.details.name }}</strong>
|
margin-right: 5px;
|
||||||
<div class="ml-2 text-muted">{{ item.offer_name }}</div> <!-- Add offer name here -->
|
}
|
||||||
<div class="price-box ml-auto">
|
|
||||||
<div><img src="{{ ruble_image.image512pxLink }}" alt="RUB"><span>{{ item.details.basePrice }} RUB</span></div>
|
.card-body {
|
||||||
<small>Base Price (for reference)</small>
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.barter-section {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.left-section {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<h1>Trader Assort</h1>
|
||||||
|
<div class="list-group"> {% for item in items %} <div class="card">
|
||||||
|
<div class="card-header d-flex align-items-center">
|
||||||
|
<img src="{{ item.details.image512pxLink }}" alt="{{ item.details.name }}">
|
||||||
|
<strong>{{ item.details.name }}</strong>
|
||||||
|
<div class="ml-2 text-muted">{{ item.offer_name }}</div>
|
||||||
|
<!-- Add offer name here -->
|
||||||
|
<div class="price-box ml-auto">
|
||||||
|
<div>
|
||||||
|
<img src="{{ ruble_image.image512pxLink }}" alt="RUB">
|
||||||
|
<span>{{ item.details.basePrice }} RUB</span>
|
||||||
|
</div>
|
||||||
|
<small>Base Price (for reference)</small>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="card-body">
|
||||||
<div class="card-body">
|
<div class="barter-section">
|
||||||
<a href="{{ url_for('edit_item', item_id=item._id) }}" class="btn btn-primary btn-sm float-right">Edit</a>
|
<div class="left-section">
|
||||||
|
{% if item.barter_scheme|length > 0 %}
|
||||||
{% if item.parts|length > 0 %}
|
<div>
|
||||||
<h2>
|
<strong>Barter Requirements:</strong>
|
||||||
<button class="btn btn-outline-primary" type="button" data-toggle="collapse" data-target="#parts-{{ item._id }}" aria-expanded="false" aria-controls="parts-{{ item._id }}">
|
</div>
|
||||||
Parts
|
<ul class="barter-list"> {% for scheme in item.barter_scheme %} {% for req in scheme %} <li>
|
||||||
</button>
|
<span>{{ req.count }} ×</span>
|
||||||
</h2>
|
<img src="{{ req.details.image512pxLink }}" alt="{{ req.details.name }}">
|
||||||
<div id="parts-{{ item._id }}" class="collapse">
|
</li> {% endfor %} {% endfor %} </ul>
|
||||||
<ul class="parts-tree">
|
{% endif %}
|
||||||
{% include 'parts.html' with context %}
|
{% if item.quest_requirement %}
|
||||||
</ul>
|
<p>
|
||||||
</div>
|
<strong>Quest Requirement:</strong>
|
||||||
{% endif %}
|
{{ item.quest_requirement.quest }} {% if item.quest_requirement.type == 'success' %} <i class="fas fa-check-circle text-success"></i> {% elif item.quest_requirement.type == 'fail' %} <i class="fas fa-times-circle text-danger"></i> {% elif item.quest_requirement.type == 'started' %} <i class="fas fa-question-circle text-primary"></i> {% endif %}
|
||||||
|
</p>
|
||||||
{% if item.barter_scheme|length > 0 %}
|
{% endif %}
|
||||||
<div><strong>Barter Requirements:</strong></div>
|
</div>
|
||||||
<ul class="barter-list">
|
<a href="{{ url_for('edit_item', item_id=item._id) }}" class="btn btn-primary btn-sm">Edit</a>
|
||||||
{% for scheme in item.barter_scheme %}
|
</div>
|
||||||
{% for req in scheme %}
|
{% if item.parts|length > 0 %}
|
||||||
<li>
|
<h2>
|
||||||
<span>{{ req.count }} ×</span>
|
<button class="btn btn-outline-primary" type="button" data-toggle="collapse" data-target="#parts-{{ item._id }}" aria-expanded="false" aria-controls="parts-{{ item._id }}"> Parts </button>
|
||||||
<img src="{{ req.details.image512pxLink }}" alt="{{ req.details.name }}">
|
</h2>
|
||||||
</li>
|
<div>
|
||||||
{% endfor %}
|
<div id="parts-{{ item._id }}" class="collapse">
|
||||||
{% endfor %}
|
<ul class="parts-tree"> {% include 'parts.html' with context %} </ul>
|
||||||
</ul>
|
</div>
|
||||||
{% endif %}
|
</div>
|
||||||
|
|
||||||
{% if item.quest_requirement %}
|
|
||||||
<p>
|
|
||||||
<strong>Quest Requirement:</strong>
|
|
||||||
{{ item.quest_requirement.quest }}
|
|
||||||
{% if item.quest_requirement.type == 'success' %}
|
|
||||||
<i class="fas fa-check-circle text-success"></i>
|
|
||||||
{% elif item.quest_requirement.type == 'fail' %}
|
|
||||||
<i class="fas fa-times-circle text-danger"></i>
|
|
||||||
{% elif item.quest_requirement.type == 'started' %}
|
|
||||||
<i class="fas fa-question-circle text-primary"></i>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</p>
|
</div>
|
||||||
{% endif %}
|
</div> {% endfor %}
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
|
||||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
|
</body>
|
||||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user