Fix upload limit related pieces and uploader links

This commit is contained in:
Kira 2019-12-29 02:37:50 -08:00
parent 4196b80bf8
commit 4c61ee2557
5 changed files with 36 additions and 27 deletions

View File

@ -1,7 +1,7 @@
class UsersController < ApplicationController
respond_to :html, :xml, :json
skip_before_action :api_check
before_action :member_only, only: [:custom_style]
before_action :member_only, only: [:custom_style, :upload_limit]
def new
raise User::PrivilegeError.new("Already signed in") unless CurrentUser.is_anonymous?
@ -45,6 +45,15 @@ class UsersController < ApplicationController
def search
end
def upload_limit
@presenter = UserPresenter.new(CurrentUser.user)
pieces = CurrentUser.upload_limit_pieces
@approved_count = pieces[:approved]
@deleted_count = pieces[:deleted]
@pending_count = pieces[:pending]
respond_with(CurrentUser.user)
end
def show
@user = User.find(User.name_or_id_to_id(params[:id]))
@presenter = UserPresenter.new(@user)

View File

@ -562,7 +562,7 @@ class User < ApplicationRecord
memoize :upload_limit_pieces
def post_upload_throttle
return post_upload_limit if is_privileged_or_higher?
return hourly_upload_limit if is_privileged_or_higher?
[hourly_upload_limit, tag_edit_limit].min
end
memoize :post_upload_throttle

View File

@ -1,33 +1,34 @@
<div id="post-add">
<div style="margin-bottom: 1rem;" class="section">
<h2>Before uploading, read
the <%= link_to "how to upload guide", wiki_pages_path(id: "howto:upload") %>.</h2>
the <%= link_to "how to upload guide", wiki_page_path(id: "howto:upload") %>.</h2>
<p>Make sure you're not posting something on
the <%= link_to "Avoid Posting List", help_pages_path(id: 'avoid_posting') %><br>
Review the <%= link_to "Uploading Guidelines", help_pages_path(id: "uploading_guidelines") %>
the <%= link_to "Avoid Posting List", help_page_path(id: 'avoid_posting') %><br>
Review the <%= link_to "Uploading Guidelines", help_page_path(id: "uploading_guidelines") %>
<br>
Unsure what to tag your post
with? <%= link_to "Tagging Checklist", help_pages_path(id: "tagging_checklist") %></p>
with? <%= link_to "Tagging Checklist", help_page_path(id: "tagging_checklist") %></p>
</div>
<div id="uploader"></div>
<%# if current_user.is_member_or_lower? && (current_user.upload_limit <= 5 || current_user.post_upload_throttle <= 5) %>
<!-- <div id="post-uploads-remaining" class="section<%# if [current_user.upload_limit, current_user.post_upload_throttle].min <= 0 %> sect_red<%# end %>" style="width:640px;">-->
<!-- <p>-->
<!-- You currently have <span class="post-uploads-remaining-count"><%#= current_user.upload_limit %></span> upload<%#= current_user.upload_limit!=1?"s":"" %> remaining.-->
<% if CurrentUser.is_member_or_lower? && (CurrentUser.upload_limit <= 5 || CurrentUser.post_upload_throttle <= 5) %>
<% @limit_pieces = CurrentUser.upload_limit_pieces %>
<div id="post-uploads-remaining" class="box-section section<% if [CurrentUser.upload_limit, CurrentUser.post_upload_throttle].min <= 0 %> sect_red<% end %>" style="width:640px;">
<p>
You currently have <span class="post-uploads-remaining-count"><%= CurrentUser.upload_limit %></span> upload<%= CurrentUser.upload_limit!=1?"s":"" %> remaining.
<%# if current_user.pending_flagged_posts.count > 0 %>
<!-- This number will go up as some of your <%#= link_to "<span class='post-uploads-remaining-count'>#{current_user.pending_flagged_posts.count}</span> pending/flagged posts", action: "index",tags: "user:#{current_user.name} status:pending" %> are approved.-->
<%# end %>
<!-- </p>-->
<!-- You have <span class="post-uploads-remaining-count"><%#= current_user.post_upload_throttle %></span> uploads remaining this hour.-->
<!-- See <%#= link_to "here", controller: "user", action: "upload_limit" %> for more details.-->
<!-- </div>-->
<%# elsif current_user.post_upload_throttle <= 5 %>
<!-- <div id="post-uploads-remaining" class="section<%# if current_user.post_upload_throttle <= 0 %> sect_red<%# end %>" style="width:640px;">-->
<!-- You have <span class="post-uploads-remaining-count"><%#= current_user.post_upload_throttle %></span> uploads remaining this hour.-->
<!-- See <%#= link_to "here", controller: "user", action: "upload_limit" %> for more details.-->
<!-- </div>-->
<%# end %>
<% if @limit_pieces[:pending] > 0 %>
This number will go up as some of your <%= link_to "<span class='post-uploads-remaining-count'>#{@limit_pieces[:pending]}</span> pending/flagged posts".html_safe, posts_path(tags: "user:#{CurrentUser.name} status:pending") %> are approved.
<% end %>
</p>
You have <span class="post-uploads-remaining-count"><%= CurrentUser.post_upload_throttle %></span> uploads remaining this hour.
See <%= link_to "here", upload_limit_users_path %> for more details.
</div>
<% elsif CurrentUser.post_upload_throttle <= 5 %>
<div id="post-uploads-remaining" class="section<% if CurrentUser.post_upload_throttle <= 0 %> sect_red<% end %>" style="width:640px;">
You have <span class="post-uploads-remaining-count"><%= CurrentUser.post_upload_throttle %></span> uploads remaining this hour.
See <%= link_to "here", help_page_path(id: "upload_limit") %> for more details.
</div>
<% end %>
</div>
<script>
var uploaderSettings = {

View File

@ -7,7 +7,7 @@
<li>Approved: <%= @approved_count %></li>
<li>Deleted: <%= @deleted_count %></li>
<li>Pending/Flagged: <%= @pending_count %></li>
<li>Formula: <%= presenter.upload_limit(self)%></li>
<li>Formula: <%= @presenter.upload_limit(self)%></li>
</ul>
<p>
@ -29,7 +29,7 @@
<ul>
<li>Remaining hourly uploads: <%= CurrentUser.hourly_upload_limit %></li>
<% if !CurrentUser.is_privileged? %><li>Remaining hourly tag edits: <%= CurrentUser.post_edit_limit %></li><% end %>
<% if !CurrentUser.can_upload_free? %><li>Remaining hourly tag edits: <%= CurrentUser.post_edit_limit %></li><% end %>
</ul>
<% unless CurrentUser.can_upload_free? %>
@ -42,5 +42,3 @@
</p>
<% end %>
</div>
<%= render partial: "footer" %>

View File

@ -323,6 +323,7 @@ Rails.application.routes.draw do
collection do
get :home
get :search
get :upload_limit
get :custom_style
end
end