euscanwww: use maintainers names, not ids
Signed-off-by: Corentin Chary <corentin.chary@gmail.com>
This commit is contained in:
parent
808acfe13a
commit
5a8d7e8932
@ -97,8 +97,12 @@ class PackagesHandler(AnonymousBaseHandler):
|
||||
herd = Herd.objects.get(herd=kwargs['herd'])
|
||||
packages = Package.objects.for_herd(herd, last_versions=True)
|
||||
data = {'herd': herd}
|
||||
elif 'maintainer_id' in kwargs:
|
||||
elif 'maintainer_id' in kwargs or 'maintainer_email' in kwargs:
|
||||
if 'maintainer_id' in kwargs:
|
||||
maintainer = Maintainer.objects.get(id=kwargs['maintainer_id'])
|
||||
elif 'maintainer_email' in kwargs:
|
||||
maintainer = Maintainer.objects.get(email=kwargs['maintainer_email'])
|
||||
|
||||
packages = Package.objects.for_maintainer(
|
||||
maintainer,
|
||||
last_versions=True
|
||||
|
@ -24,6 +24,8 @@ urlpatterns = patterns('djeuscan.api.views',
|
||||
|
||||
url(r'^1.0/packages/by-maintainer/(?P<maintainer_id>\d+)\.(?P<emitter_format>.+)$',
|
||||
packages_handler, name='api.views.packages'),
|
||||
url(r'^1.0/packages/by-maintainer/(?P<maintainer_email>[^/]+)\.(?P<emitter_format>.+)$',
|
||||
packages_handler, name='api.views.packages'),
|
||||
url(r'^1.0/packages/by-herd/(?P<herd>[\@\{\}\w+.-]*)\.(?P<emitter_format>.+)?$',
|
||||
packages_handler, name='api.views.packages'),
|
||||
url(r'^1.0/packages/by-category/(?P<category>[\w+][\w+.-]*)\.(?P<emitter_format>.+)?$',
|
||||
|
@ -146,9 +146,16 @@ class PackageFeed(BaseFeed):
|
||||
class MaintainerFeed(BaseFeed):
|
||||
feed_type = Atom1Feed
|
||||
|
||||
def get_object(self, request, maintainer_id):
|
||||
def get_object(self, request, maintainer_id=None, maintainer_email=None):
|
||||
print maintainer_id, maintainer_email
|
||||
if maintainer_id:
|
||||
obj = get_object_or_404(Maintainer, id=maintainer_id)
|
||||
else:
|
||||
obj = get_object_or_404(Maintainer, email=maintainer_email)
|
||||
|
||||
print obj
|
||||
return {
|
||||
"obj": get_object_or_404(Maintainer, id=maintainer_id),
|
||||
"obj": obj,
|
||||
"options": request.GET,
|
||||
}
|
||||
|
||||
@ -159,8 +166,7 @@ class MaintainerFeed(BaseFeed):
|
||||
return "Last changes for %s" % data["obj"]
|
||||
|
||||
def link(self, data):
|
||||
return reverse('djeuscan.views.maintainer',
|
||||
kwargs={'maintainer_id': data["obj"].id})
|
||||
return reverse('djeuscan.views.maintainer', args=[data["obj"].email])
|
||||
|
||||
def _items(self, data):
|
||||
return VersionLog.objects.for_maintainer(data["obj"]), 50
|
||||
|
@ -18,7 +18,7 @@
|
||||
{% for maintainer in maintainers %}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{% url "maintainer" maintainer.maintainers__id %}">
|
||||
<a href="{% url "maintainer" maintainer.maintainers__email %}">
|
||||
{% if maintainer.maintainers__name != maintainer.maintainers__email %}
|
||||
{{ maintainer.maintainers__name }} <{{ maintainer.maintainers__email }}>
|
||||
{% else %}
|
||||
@ -31,8 +31,8 @@
|
||||
|
||||
{% if extras %}
|
||||
<td>
|
||||
<img src="{% url "chart_maintainer" maintainer.maintainers__id 'packages-monthly-small' %}" />
|
||||
<img src="{% url "chart_maintainer" maintainer.maintainers__id 'versions-monthly-small' %}" />
|
||||
<img src="{% url "chart_maintainer" maintainer.maintainers__email 'packages-monthly-small' %}" />
|
||||
<img src="{% url "chart_maintainer" maintainer.maintainers__email 'versions-monthly-small' %}" />
|
||||
</td>
|
||||
{% endif %}
|
||||
|
||||
|
@ -33,12 +33,12 @@
|
||||
{% for maintainer in package.maintainers.all %}
|
||||
<p>
|
||||
{% if maintainer.name != maintainer.email %}
|
||||
<a href="{% url "maintainer" maintainer.id %}">
|
||||
<a href="{% url "maintainer" maintainer.email %}">
|
||||
{{ maintainer.name }}
|
||||
</a>
|
||||
<{{ maintainer.email }}>
|
||||
{% else %}
|
||||
<a href="{% url "maintainer" maintainer.id %}">
|
||||
<a href="{% url "maintainer" maintainer.email %}">
|
||||
{{ maintainer.email }}
|
||||
</a>
|
||||
{% endif %}
|
||||
|
@ -75,7 +75,7 @@
|
||||
Hot maintainers:
|
||||
<ul>
|
||||
{% for c in maintainers|slice:":3" %}
|
||||
<li><a href="{% url "maintainer" c.maintainers__id %}">{{ c.maintainers__name }}</a> ({{ c.n_versions|sub:c.n_packaged|sub:c.n_overlay }})</li>
|
||||
<li><a href="{% url "maintainer" c.maintainers__email %}">{{ c.maintainers__name }}</a> ({{ c.n_versions|sub:c.n_packaged|sub:c.n_overlay }})</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</li>
|
||||
|
@ -11,7 +11,7 @@
|
||||
{{ block.super }}
|
||||
<li>
|
||||
<img src="{{ STATIC_URL }}/img/feed.png" alt="feed" />
|
||||
<a title="{{ maintainer.name }} Feed" href="{% url "maintainer_feed" maintainer.id %}">
|
||||
<a title="{{ maintainer.name }} Feed" href="{% url "maintainer_feed" maintainer.email %}">
|
||||
{{ maintainer.name|truncatechars:15 }}
|
||||
</a>
|
||||
</li>
|
||||
@ -22,10 +22,10 @@
|
||||
Maintainer: {{ maintainer.name }} <{{ maintainer.email }}>
|
||||
{% if user.is_authenticated %}
|
||||
<span class="pull-right">
|
||||
<button class="btn favourite-button {% if favourited %}hide{% endif %}" data-url="{% url "favourite_maintainer" maintainer.id %}">
|
||||
<button class="btn favourite-button {% if favourited %}hide{% endif %}" data-url="{% url "favourite_maintainer" maintainer.email %}">
|
||||
<img src="{{ STATIC_URL}}/img/watch-icon.png" alt="Watch" />
|
||||
</button>
|
||||
<button class="btn unfavourite-button {% if not favourited %}hide{% endif %}" data-url="{% url "unfavourite_maintainer" maintainer.id %}">
|
||||
<button class="btn unfavourite-button {% if not favourited %}hide{% endif %}" data-url="{% url "unfavourite_maintainer" maintainer.email %}">
|
||||
<img src="{{ STATIC_URL}}/img/unwatch-icon.png" alt="Unwatch" />
|
||||
</button>
|
||||
</span>
|
||||
@ -37,19 +37,19 @@
|
||||
<h3>Statistics</h3>
|
||||
<h4>Current statistics</h4>
|
||||
<p>
|
||||
<img alt="pie versions" src="{% url "chart_maintainer" maintainer.id 'pie-versions' %}" />
|
||||
<img alt="pie packages" src="{% url "chart_maintainer" maintainer.id 'pie-packages' %}" />
|
||||
<img alt="pie versions" src="{% url "chart_maintainer" maintainer.email 'pie-versions' %}" />
|
||||
<img alt="pie packages" src="{% url "chart_maintainer" maintainer.email 'pie-packages' %}" />
|
||||
</p>
|
||||
|
||||
<h4>All Time</h4>
|
||||
<p>
|
||||
<img alt="version weekly" src="{% url "chart_maintainer" maintainer.id 'versions-weekly' %}" />
|
||||
<img alt="versions monthly" src="{% url "chart_maintainer" maintainer.id 'versions-monthly' %}" />
|
||||
<img alt="version weekly" src="{% url "chart_maintainer" maintainer.email 'versions-weekly' %}" />
|
||||
<img alt="versions monthly" src="{% url "chart_maintainer" maintainer.email 'versions-monthly' %}" />
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<img alt="packages weekly" src="{% url "chart_maintainer" maintainer.id 'packages-weekly' %}" />
|
||||
<img alt="packages monthly" src="{% url "chart_maintainer" maintainer.id 'packages-monthly' %}" />
|
||||
<img alt="packages weekly" src="{% url "chart_maintainer" maintainer.email 'packages-weekly' %}" />
|
||||
<img alt="packages monthly" src="{% url "chart_maintainer" maintainer.email 'packages-monthly' %}" />
|
||||
</p>
|
||||
|
||||
<script type="text/javascript">
|
||||
@ -77,9 +77,9 @@ $(document).ready(function () {
|
||||
<div class="menu rounded notfirst-menu">
|
||||
<dl>
|
||||
<dt>Versions</dt>
|
||||
<dd><img alt="versions" src="{% url "chart_maintainer" maintainer.id 'versions-monthly-small' %}" /></dd>
|
||||
<dd><img alt="versions" src="{% url "chart_maintainer" maintainer.email 'versions-monthly-small' %}" /></dd>
|
||||
<dt>Packages</dt>
|
||||
<dd><img alt="packages" src="{% url "chart_maintainer" maintainer.id 'packages-monthly-small' %}" /></dd>
|
||||
<dd><img alt="packages" src="{% url "chart_maintainer" maintainer.email 'packages-monthly-small' %}" /></dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
|
@ -55,16 +55,13 @@ herds_patterns = patterns('djeuscan.views',
|
||||
url(r'^$', 'herds', name="herds"),
|
||||
)
|
||||
|
||||
prefix = '^((?P<maintainer_id>\d+)|(?P<maintainer_email>[^/]+))'
|
||||
maintainers_patterns = patterns('djeuscan.views',
|
||||
url(r'^(?P<maintainer_id>\d+)/(view/)?$', 'maintainer', name="maintainer"),
|
||||
url(r'^(?P<maintainer_id>\d+)/feed/$', MaintainerFeed(),
|
||||
name='maintainer_feed'),
|
||||
url(r'^(?P<maintainer_id>\d+)/charts/(?P<chart>[\w\-]+).png$',
|
||||
'chart_maintainer', name="chart_maintainer"),
|
||||
url(r'^(?P<maintainer_id>\d+)/favourite/$',
|
||||
'favourite_maintainer', name="favourite_maintainer"),
|
||||
url(r'^(?P<maintainer_id>\d+)/unfavourite/$',
|
||||
'unfavourite_maintainer', name="unfavourite_maintainer"),
|
||||
url(prefix + r'/(view/)?$', 'maintainer', name="maintainer"),
|
||||
url(prefix + r'/feed/$', MaintainerFeed(), name='maintainer_feed'),
|
||||
url(prefix + r'/charts/(?P<chart>[\w\-]+).png$', 'chart_maintainer', name="chart_maintainer"),
|
||||
url(prefix + r'/favourite/$', 'favourite_maintainer', name="favourite_maintainer"),
|
||||
url(prefix + r'/unfavourite/$', 'unfavourite_maintainer', name="unfavourite_maintainer"),
|
||||
url(r'^$', 'maintainers', name="maintainers"),
|
||||
)
|
||||
|
||||
|
@ -122,9 +122,15 @@ def maintainers(request):
|
||||
return {'maintainers': maintainers, 'last_scan': last_scan}
|
||||
|
||||
|
||||
def get_maintainer_or_404(id=None, email=None):
|
||||
if id:
|
||||
return get_object_or_404(Maintainer, pk=id)
|
||||
else:
|
||||
return get_object_or_404(Maintainer, email=email)
|
||||
|
||||
@render_to('euscan/maintainer.html')
|
||||
def maintainer(request, maintainer_id):
|
||||
maintainer = get_object_or_404(Maintainer, pk=maintainer_id)
|
||||
def maintainer(request, maintainer_id=None, maintainer_email=None):
|
||||
maintainer = get_maintainer_or_404(maintainer_id, maintainer_email)
|
||||
packages = Package.objects.for_maintainer(maintainer, last_versions=True)
|
||||
|
||||
try:
|
||||
@ -337,10 +343,10 @@ def chart(request, **kwargs):
|
||||
|
||||
chart = kwargs['chart'] if 'chart' in kwargs else None
|
||||
|
||||
if 'maintainer_id' in kwargs:
|
||||
kwargs['maintainer'] = get_object_or_404(
|
||||
Maintainer,
|
||||
id=kwargs['maintainer_id']
|
||||
if 'maintainer_id' in kwargs or 'maintainer_email' in kwargs:
|
||||
kwargs['maintainer'] = get_maintainer_or_404(
|
||||
kwargs.get('maintainer_id'),
|
||||
kwargs.get('maintainer_email')
|
||||
)
|
||||
if 'herd' in kwargs:
|
||||
kwargs['herd'] = get_object_or_404(Herd, herd=kwargs['herd'])
|
||||
@ -550,8 +556,8 @@ def unfavourite_herd(request, herd):
|
||||
@login_required
|
||||
@require_POST
|
||||
@ajax_request
|
||||
def favourite_maintainer(request, maintainer_id):
|
||||
obj = get_object_or_404(Maintainer, pk=maintainer_id)
|
||||
def favourite_maintainer(request, maintainer_id=None, maintainer_email=None):
|
||||
obj = get_maintainer_or_404(maintainer_id, maintainer_email)
|
||||
get_profile(request.user).maintainers.add(obj)
|
||||
return {"success": True}
|
||||
|
||||
@ -559,8 +565,8 @@ def favourite_maintainer(request, maintainer_id):
|
||||
@login_required
|
||||
@require_POST
|
||||
@ajax_request
|
||||
def unfavourite_maintainer(request, maintainer_id):
|
||||
maintainer = get_object_or_404(Maintainer, pk=maintainer_id)
|
||||
def unfavourite_maintainer(request, maintainer_id=None, maintainer_email=None):
|
||||
obj = get_maintainer_or_404(maintainer_id, maintainer_email)
|
||||
get_profile(request.user).maintainers.remove(maintainer)
|
||||
return {"success": True}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user