Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions contentcuration/contentcuration/api.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -173,3 +173,16 @@ def batch_add_tags(request):
ThroughModel.objects.bulk_create(bulk_list)

return HttpResponse("Tags are successfully saved.", status=200)


def add_editor_to_channel(invitation):

This comment was marked as spam.

if invitation.share_mode == models.VIEW_ACCESS:
if invitation.invited in invitation.channel.editors.all():
invitation.channel.editors.remove(invitation.invited)
invitation.channel.viewers.add(invitation.invited)
else:
if invitation.invited in invitation.channel.viewers.all():
invitation.channel.viewers.remove(invitation.invited)
invitation.channel.editors.add(invitation.invited)
invitation.channel.save()
invitation.delete()
5 changes: 4 additions & 1 deletion contentcuration/contentcuration/models.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,6 +22,9 @@
from rest_framework.authtoken.models import Token
from le_utils.constants import content_kinds,file_formats, format_presets, licenses, exercises

EDIT_ACCESS = "edit"

This comment was marked as spam.

VIEW_ACCESS = "view"

DEFAULT_USER_PREFERENCES = json.dumps({
'license': licenses.CC_BY,
'language': None,
Expand DownExpand Up@@ -611,7 +614,7 @@ class Invitation(models.Model):
""" Invitation to edit channel """
id = UUIDField(primary_key=True, default=uuid.uuid4)
invited = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, null=True, related_name='sent_to')
share_mode = models.CharField(max_length=50, default='edit')
share_mode = models.CharField(max_length=50, default=EDIT_ACCESS)
email = models.EmailField(max_length=100, null=True)
sender = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, related_name='sent_by', null=True)
channel = models.ForeignKey('Channel', on_delete=models.SET_NULL, null=True, related_name='pending_editors')
Expand Down
8 changes: 7 additions & 1 deletion contentcuration/contentcuration/serializers.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -620,6 +620,12 @@ class Meta:
fields = ('email', 'first_name', 'last_name', 'id')

class InvitationSerializer(BulkSerializerMixin, serializers.ModelSerializer):
channel_name = serializers.SerializerMethodField('retrieve_channel_name')

This comment was marked as spam.

sender = UserSerializer(read_only=True)

def retrieve_channel_name(self, invitation):
return invitation.channel.name

class Meta:
model = Invitation
fields = ('id', 'invited', 'email', 'sender', 'channel', 'first_name', 'last_name', 'share_mode')
fields = ('id', 'invited', 'email', 'sender', 'channel', 'first_name', 'last_name', 'share_mode', 'channel_name')
Original file line numberDiff line numberDiff line change
Expand Up@@ -593,9 +593,7 @@ var FormatSlot = BaseViews.BaseListNodeItemView.extend({
},
file_failed:function(file, error){
var self = this;
dialog.dialog("Error Uploading File", error, {
"OK":function(){}
}, function(){
dialog.alert("Error Uploading File", error, function(){
self.render();
self.set_uploading(false);
self.containing_list_view.update_metadata();
Expand DownExpand Up@@ -832,8 +830,7 @@ var ThumbnailUploadView = BaseViews.BaseView.extend({
},
image_completed:function(){
if(this.image_error){
var self = this;
dialog.dialog("Image Error", this.image_error, { "OK":function(){} }, null);
dialog.alert("Image Error", this.image_error);
if(this.onerror){ this.onerror(); }
}else{
if(this.onsuccess){ this.onsuccess(this.image, this.image_formatted_name, this.image_url); }
Expand DownExpand Up@@ -1008,7 +1005,7 @@ var ImageUploadView = BaseViews.BaseModalView.extend({
},
file_complete:function(){
if(this.file_error){
dialog.dialog("Image Error", this.file_error, { "OK":function(){} }, null);
dialog.alert("Image Error", this.file_error);
}
this.render_dropzone();
}
Expand Down
Loading