Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add custom realm emoji feature to admin
- Loading branch information
Showing
11 changed files
with
253 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{{#with emoji}} | ||
<tr class="emoji_row" id="emoji_{{name}}"> | ||
<td> | ||
<span class="emoji_name">{{name}}</span> | ||
</td> | ||
<td> | ||
<span class="emoji_image"><img src="{{url}}" alt="{{name}}" /></span> | ||
</td> | ||
<td> | ||
<button class="btn delete btn-danger" data-emoji-name="{{name}}"> | ||
Delete | ||
</button> | ||
</td> | ||
</tr> | ||
{{/with}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import models, migrations | ||
import django.core.validators | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('zerver', '0009_add_missing_migrations'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='realmemoji', | ||
name='img_url', | ||
field=models.URLField(), | ||
), | ||
migrations.AlterField( | ||
model_name='realmemoji', | ||
name='name', | ||
field=models.TextField(validators=[django.core.validators.MinLengthValidator(1), django.core.validators.RegexValidator(regex=b'^[0-9a-zA-Z_\\-\\.]*$')]), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from django.core.exceptions import ValidationError | ||
from django.views.decorators.csrf import csrf_exempt | ||
|
||
from zerver.lib.response import json_success, json_error | ||
from zerver.lib.actions import do_add_realm_emoji, do_remove_realm_emoji | ||
|
||
from zerver.lib.rest import rest_dispatch as _rest_dispatch | ||
rest_dispatch = csrf_exempt((lambda request, *args, **kwargs: _rest_dispatch(request, globals(), *args, **kwargs))) | ||
|
||
|
||
def list_emoji(request, user_profile): | ||
return json_success({'emoji': user_profile.realm.get_emoji()}) | ||
|
||
def upload_emoji(request, user_profile): | ||
emoji_name = request.POST.get('name', None) | ||
emoji_url = request.POST.get('url', None) | ||
try: | ||
do_add_realm_emoji(user_profile.realm, emoji_name, emoji_url) | ||
except ValidationError as e: | ||
return json_error(e.message_dict) | ||
return json_success() | ||
|
||
def delete_emoji(request, user_profile, emoji_name): | ||
do_remove_realm_emoji(user_profile.realm, emoji_name) | ||
return json_success({}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters