mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-26 15:26:19 +00:00
payment
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
|
|
||||||
import seaserv
|
import seaserv
|
||||||
from seaserv import get_binding_peerids, get_orgs_by_user
|
from seaserv import get_binding_peerids
|
||||||
|
|
||||||
from seahub.notifications.models import Notification
|
from seahub.notifications.models import Notification
|
||||||
from seahub.notifications.utils import refresh_cache
|
from seahub.notifications.utils import refresh_cache
|
||||||
@@ -9,6 +9,10 @@ try:
|
|||||||
from seahub.settings import CLOUD_MODE
|
from seahub.settings import CLOUD_MODE
|
||||||
except ImportError:
|
except ImportError:
|
||||||
CLOUD_MODE = False
|
CLOUD_MODE = False
|
||||||
|
try:
|
||||||
|
from seahub.settings import MULTI_TENANCY
|
||||||
|
except ImportError:
|
||||||
|
MULTI_TENANCY = False
|
||||||
|
|
||||||
class BaseMiddleware(object):
|
class BaseMiddleware(object):
|
||||||
"""
|
"""
|
||||||
@@ -16,19 +20,20 @@ class BaseMiddleware(object):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def process_request(self, request):
|
def process_request(self, request):
|
||||||
if CLOUD_MODE:
|
username = request.user.username
|
||||||
request.cloud_mode = True
|
|
||||||
|
|
||||||
# Get all orgs user created.
|
|
||||||
# orgs = get_orgs_by_user(request.user.username)
|
|
||||||
# request.user.orgs = orgs
|
|
||||||
else:
|
|
||||||
request.cloud_mode = False
|
|
||||||
|
|
||||||
request.user.org = None
|
request.user.org = None
|
||||||
request.user.orgs = None
|
request.user.orgs = None
|
||||||
|
|
||||||
username = request.user.username
|
if CLOUD_MODE:
|
||||||
|
request.cloud_mode = True
|
||||||
|
|
||||||
|
if MULTI_TENANCY:
|
||||||
|
orgs = seaserv.get_orgs_by_user(username)
|
||||||
|
if orgs:
|
||||||
|
request.user.org = orgs[0]
|
||||||
|
else:
|
||||||
|
request.cloud_mode = False
|
||||||
|
|
||||||
request.user.joined_groups = seaserv.get_personal_groups_by_user(username)
|
request.user.joined_groups = seaserv.get_personal_groups_by_user(username)
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
@@ -21,5 +21,5 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if ENABLE_PAYMENT %}
|
{% if ENABLE_PAYMENT %}
|
||||||
<a class="item" href="{% url 'plan' %}">{% trans "Payment" %}</a>
|
<a class="item" href="{{ payment_url }}">{% trans "Payment" %}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@@ -1359,6 +1359,20 @@ def space_and_traffic(request):
|
|||||||
if stat:
|
if stat:
|
||||||
traffic_stat = stat['file_view'] + stat['file_download'] + stat['dir_download']
|
traffic_stat = stat['file_view'] + stat['file_download'] + stat['dir_download']
|
||||||
|
|
||||||
|
payment_url = ''
|
||||||
|
ENABLE_PAYMENT = getattr(settings, 'ENABLE_PAYMENT', False)
|
||||||
|
if ENABLE_PAYMENT:
|
||||||
|
if is_org_context(request):
|
||||||
|
if request.user.org and bool(request.user.org.is_staff) is True:
|
||||||
|
# payment for org admin
|
||||||
|
payment_url = reverse('org_plan')
|
||||||
|
else:
|
||||||
|
# no payment for org members
|
||||||
|
ENABLE_PAYMENT = False
|
||||||
|
else:
|
||||||
|
# payment for personal account
|
||||||
|
payment_url = reverse('plan')
|
||||||
|
|
||||||
ctx = {
|
ctx = {
|
||||||
"CALC_SHARE_USAGE": CALC_SHARE_USAGE,
|
"CALC_SHARE_USAGE": CALC_SHARE_USAGE,
|
||||||
"quota": quota,
|
"quota": quota,
|
||||||
@@ -1368,7 +1382,8 @@ def space_and_traffic(request):
|
|||||||
"rates": rates,
|
"rates": rates,
|
||||||
"TRAFFIC_STATS_ENABLED": TRAFFIC_STATS_ENABLED,
|
"TRAFFIC_STATS_ENABLED": TRAFFIC_STATS_ENABLED,
|
||||||
"traffic_stat": traffic_stat,
|
"traffic_stat": traffic_stat,
|
||||||
"ENABLE_PAYMENT": getattr(settings, 'ENABLE_PAYMENT', False),
|
"ENABLE_PAYMENT": ENABLE_PAYMENT,
|
||||||
|
"payment_url": payment_url,
|
||||||
}
|
}
|
||||||
|
|
||||||
html = render_to_string('snippets/space_and_traffic.html', ctx,
|
html = render_to_string('snippets/space_and_traffic.html', ctx,
|
||||||
|
Reference in New Issue
Block a user