Skip to content
Permalink
Browse files

Allow linking to Wiki page and disabling of downloads if the item is …

…in-game
  • Loading branch information...
Smashman committed Oct 30, 2014
1 parent 1963b21 commit 3ba0f8c962df824601cd2e30330bf7293ed85485
@@ -0,0 +1,28 @@
"""Add defindex and hiding of download to Mod table
Revision ID: 7f0e7d496f6
Revises: 4527cf3899ec
Create Date: 2014-10-30 01:31:03.986114
"""

# revision identifiers, used by Alembic.
revision = '7f0e7d496f6'
down_revision = '4527cf3899ec'

from alembic import op
import sqlalchemy as sa


def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.add_column('mods', sa.Column('defindex', sa.Integer(), nullable=True))
op.add_column('mods', sa.Column('hide_downloads', sa.Boolean(), nullable=True))
### end Alembic commands ###


def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.drop_column('mods', 'hide_downloads')
op.drop_column('mods', 'defindex')
### end Alembic commands ###
@@ -1,6 +1,8 @@
$(function() {
var bodygroups = $("#bodygroups");
var equip_regions = $("#equip_regions");
var defindex = $("#defindex");
var hide_downloads = $("#hide_downloads")
function call_count(search_data) {
$.ajax({
url: tf2_api,
@@ -22,4 +24,15 @@ $(function() {
};
multipleSelect_three(true, get_count);
$("#tags").multipleSelect({selectAll: false, placeholder: "No tags selected", allSelected: false});
if (!defindex.val()) {
hide_downloads.prop('disabled', true);
}
defindex.change(function(){
if ($(this).val()) {
hide_downloads.prop('disabled', false);
}
else{
hide_downloads.prop('disabled', true);
}
});
});
@@ -147,6 +147,9 @@ input[type=submit].input-default
&:hover
background-color: darken($mods_tf-highlight, 8%)

input[type=checkbox].input-default
width: initial

.form-row
margin-bottom: 5px
+clearfix
@@ -1,5 +1,5 @@
from flask.ext.wtf import Form
from wtforms import TextField, SelectField, SelectMultipleField, SubmitField, TextAreaField, FieldList, FormField
from wtforms import TextField, SelectField, SelectMultipleField, SubmitField, TextAreaField, FieldList, FormField, BooleanField
from wtforms.validators import Required
from wtforms.ext.sqlalchemy.fields import QuerySelectMultipleField

@@ -30,6 +30,13 @@ class EditMod(Form):
package_format = SelectField("Package format:", validators=[Required()])
equip_regions = QuerySelectMultipleField("Equip regions:", validators=[Required()])
bodygroups = QuerySelectMultipleField("Bodygroups:")
defindex = TextField('Defindex:', description="If your item is officially in-game, "
"find the defindex in the corner of the item on the "
"<a target=\"_blank\" "
"href=\"https://tf2b.com/itemlist.php\">TF2B item list</a>.")
hide_downloads = BooleanField('Hide downloads:', description="Enable to hide downloads if your item is in-game. "
"If you want to disable your item otherwise, simply"
"change the visibility to 'Hidden', below.")
visibility = SelectField("Visibility:", validators=[Required()])
publish = SubmitField("Save")

@@ -139,6 +139,8 @@ class Mod(db.Model):
manifest_steamid = db.Column(db.Integer)
item_slot = db.Column(db.String(64))
image_inventory = db.Column(db.String(256))
defindex = db.Column(db.Integer, nullable=True)
hide_downloads = db.Column(db.Boolean, default=False)
uploaded = db.Column(db.DateTime, default=datetime.datetime.utcnow)
visibility = db.Column(db.Enum('H', 'Pu', 'Pr', name='visibility_types'), default='H') # Hidden, Public, Unlisted
completed = db.Column(db.Boolean, default=False, nullable=False)
@@ -116,6 +116,16 @@ def edit(mod_id):
mod.package_format = edit_form.package_format.data
mod.visibility = edit_form.visibility.data

mod.defindex = edit_form.defindex.data
if not mod.defindex.isnumeric():
mod.defindex = None

mod.hide_downloads = edit_form.hide_downloads.data

if mod.hide_downloads and not mod.defindex:
mod.hide_downloads = False
flash("If the item is not officially in-game, please simply change the item visibility to hidden to remove downloads.", "danger")

mod.bodygroups = []
mod.equip_regions = []

@@ -172,6 +182,8 @@ def edit(mod_id):
edit_form.tags.data = [tag for tag in mod.tags]
edit_form.package_format.data = mod.package_format
edit_form.visibility.data = mod.visibility
edit_form.hide_downloads.data = mod.hide_downloads
edit_form.defindex.data = mod.defindex
if new_item:
edit_form.visibility.data = "Pu"
edit_form.publish.label.text += " and Publish!"
@@ -312,6 +324,8 @@ def package(mod_id, defindex):
mod_package = ModPackage.query.filter_by(mod_id=mod_id, defindex=defindex).first()
mod = Mod.query.get_or_404(mod_id)
check_mod_permissions(mod)
if mod.hide_downloads:
abort(404)
replacement = TF2Item.query.filter_by(defindex=defindex, inactive=False).first()
if mod and replacement:
if not current_user.is_admin():
Binary file not shown.
Binary file not shown.
@@ -21,10 +21,10 @@
<div class="form-row">
{{ field.label }}
<div class="input{{ " select" if field.type == "SelectField" }}{{ " error" if field.errors }}">
{{ field(placeholder=placeholder, class="input-default", rows=rows if rows) }}
{% if field.description %}
<div class="description">{{ field.description | safe }}</div>
{% endif %}
{{ field(placeholder=placeholder, class="input-default", rows=rows if rows) }}
{{ field_errors(field) }}
</div>
</div>
@@ -77,4 +77,9 @@
{{ mod_block(mod, loop.first) }}
{% endfor %}
</div>
{%- endmacro -%}
{%- macro wiki_link(defindex) -%}
<div class="workshop">
<a href="http://wiki.teamfortress.com/scripts/itemredirect.php?id={{ defindex }}" target="_blank" title="View on Official Team Fortress Wiki"><img src="{{ url_for('static', filename='images/wiki.png') }}"/></a>
</div>
{%- endmacro -%}
@@ -37,6 +37,8 @@
{{ form_field(edit_form.bodygroups) }}
<div class="form-row offset" id="item-count">The current settings return <span>{{ count | default(0) }}</span> compatible items.</div>
{{ form_field(edit_form.package_format) }}
{{ form_field(edit_form.defindex) }}
{{ form_field(edit_form.hide_downloads) }}
{{ form_field(edit_form.visibility) }}
<div class="form-row offset">{{ edit_form.publish(class="input-default") }}</div>
</form>
@@ -1,5 +1,6 @@
{% extends "layout.html" %}
{% from "mods/macros.html" import author_list, readable_visibility %}
{% from 'macros.html' import wiki_link %}
{% if mod.class_model | length > 1 %}
{% set mod_class = "multi-class" %}
{% else %}
@@ -34,6 +35,9 @@
<a href="//steamcommunity.com/sharedfiles/filedetails/?id={{ mod.workshop_id }}" target="_blank" title="View on Steam Workshop"><img src="{{ url_for('static', filename='images/workshop.png') }}"/></a>
</div>
{%- endif -%}
{%- if mod.defindex -%}
{{ wiki_link(mod.defindex) }}
{%- endif -%}
<div>
<span class="mod-stat-title">Downloads: </span>
<span class="mod-stat">{{ mod_stats.downloads | default(0) | format_thousands}}</span>
@@ -44,7 +48,7 @@
</div>
<div><span class="mod-stat-title">Class: </span>
{%- for key, class in sorted_classes -%}
<a href="{{ url_for('.search', class=class) }}">{{ class }}</a>{{ ", " if not loop.last }}
<a href="{{ url_for('.search', classes=class) }}">{{ class }}</a>{{ ", " if not loop.last }}
{%- endfor -%}
</div>
{%- if mod.bodygroups | length > 0 -%}
@@ -92,6 +96,7 @@
{{ mod.description | markdown }}
</div>
{%- endif -%}
{%- if not mod.hide_downloads -%}
{%- if current_user.is_authenticated() -%}
<div class="item-search">
<span>Filter for items to replace:</span>
@@ -111,7 +116,11 @@
</div>
</div>
{%- else -%}
<div><a href="{{ url_for("users.login") }}">Login via Steam</a> to repackage and download this mod.</div>
<div><a href="{{ url_for("users.login") }}"><img src="{{ url_for('static', filename='images/sits_small.png') }}"/></a> to repackage and download this mod.</div>
{%- endif -%}
{%- else -%}
This mod is no longer available to download due to being available officially in-game!
{% if mod.defindex %}Please see the <a href="http://wiki.teamfortress.com/scripts/itemredirect.php?id={{ mod.defindex }}" target="_blank" title="View on Official Team Fortress Wiki">Wiki page</a> for more information upon the item.{% endif %}
{%- endif -%}
</div>
{% endblock %}

0 comments on commit 3ba0f8c

Please sign in to comment.
You can’t perform that action at this time.